Title: MCS M2M Java training
1MCS M2M Java training
MCS - Mixe Communication Solutions M2M
Solutions Java training
Timo Medvedev (timo_at_mcs-nl.com)
2Training overview
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Java History and Introduction
- Java crash course
- Java software Siemens module JDK installation
- Application programming
- Autostart/OTAP
- Questions discussion future application
3Java History Past, Present, Future
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Birth December, 1990. The originalname was Oak.
- April, 1995 Netscape announces Java embedded
browsers, Java released tothe masses. - 2000 Java is used as e-business platform for
secuire transactions. - 2002-now Java grows exponentialy in mobile
market, see the chart on the right.
4Java Introduction What is JAVA?
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Programming Language
- Platform independent Write once, run anywhere
(on different platforms, Windows, Unix, Linux,
etc..) - Java Virtual Machine (JVM) - Runs Java programs
- 66 Java Technologies and 50 Java Technologies
in development - Open Architecture license
- Free usage, free IDEs available
- Intellectual property free
5Java Introduction platform and technology
MCS - Mixe Communication Solutions M2M
Solutions Java training
- J2EE Java for server applications (backoffice)
- J2SE Java for desktop (PC applications)
- J2ME Java for mobile handsets (Phones, PDAs,
washing machine
6Java Introduction platform advantages
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Cost
- Java is free regardless of total number of users
- Free tools Editors Enterprise Servers (Jboss,
Tomcat) - Free tools free language gt more free tools
- Portability
- Write code once and run everywhere
- Re-usability
- Using past code in current problems.
- Some one has done your work. Use others work.
7Java Introduction JAVA v.s. C
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Java is becoming more and more popular in
embedded device programming. - Portability of Java code, write once and run
everywhere (plaform independent)! - Java Virtual Machine is handling memory
management and garbage collecting. - Java Virtual Machine prevents direct access to
memory and resources,sandbox. - Less technical knowledge is needed when
programming with Java v.s. C
8Training overview
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Java History and Introduction
- Java crash course
- Java software Siemens module JDK installation
- Application programming
- Autostart/OTAP
- Questions discussion future application
9Java course - Basics (general)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Java is case- sensitive
- MyVar is different to myVar!
- Spaces are not allowed in variables
- My Var is illegal variable name!
- Each statement has to finish with
- MyVar 150
- Each function has to have parenthesis
- getTime(), add(parameter)
- Boolean values are only true and false, you
cannot use 1 and 0
10Java course - Basics (language types)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Primitive Types
- float / double 1.43, 3.6E18, -14.0
- int 12, 16384, -5000
- boolean true or false
- byte represents signed byte as integer between
-127 0 .. 128 - char represents characters in java a, b, c, 1,
2, 3, ., , . - Compound Types Classes
- String represents textual strings, e. g.
MSFT, Hi there!, etc - ATCommand is used for working with AT interface
on TC65 - many others. See Java Class References.
11Java course - Basics (Operators)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- TypesArithmetic operations
- Notation , , , / , (remainder)
- In integer divisions, the fraction part is lost,
e. g. 3 / 2 equals 1, and 2 / 3 equals 0 - The operator allows operands of type String
(concatanating Strings) - Comparison operations
- Notation gt , gt , lt , lt , (equal) , !
(unequal) - Boolean operations
- Notation (AND), (OR), ! (NOT)
- Conditional operator
- Notation condition ? value- if- true value-
if- false(short notation for if-else) - Assignments and shortcuts
- Notation , , - , , / , , , --
- Example a b is equivalent to a a b
12Java course - Basics (classes and objects)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Most classes require to create an object of their
typeClassName variable new ClassName() - or in two linesClassName variable
nullvariable new ClassName() - or if class has constructor which requires
parametersClassName variable new
ClassName(parameter1, parameter2) - When classes have static method than it is no
need to create an object. ClassName.someMethod()
Example System.out.print(Hello world)
Calendar mijn Calendar.getInstance()
13Java course Control structures (1)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- IF / ELSEif ( a gt b ) System.out.println(a)
else System.out.println(b) - SWITCH / CASEswitch ( n ) case 1
System.out.println("one") break
case 2 System.out.println("two")
break default System.out.println(nothing
selected")
14Java course Loop structures (2)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- FORfor ( int i0 iltn i )
System.out.println( i ) - REVERSED FOR for ( int in-1 igt0 i-- )
System.out.println( i ) - DUAL FORfor ( int i 0 ,j 0 iltn i ,j
) System.out.println( i j )
- WHILE while ( moreData() ) readIt(byte
data) - DO / WHILE do readIt() if ( done() )
break if ( bypassThisOne() ) continue
15Java course Inheritance
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Inheritance mechanism for extending behavior of
classes leads to construction of hierarchy of
classes. - What happens when class B extends class D
- Inherits instance variables
- Inherits static variables
- Inherits instance methods
- Inherits static methods
- B can
- Add new instance variables
- Add new methods (static and dynamic)
- Modify methods (only implementation)
- Cannot delete anything
16Java course Inheritance (example)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- public class ComPort()
- public byte read() // read data from COM
port - public void write(byte data) // write data
to COM port -
- public class GpsReader extends ComPort
- public String getPosition()
- byte data super.read()
- // use functionality of ComPort to read data
and do high level processing here -
-
- public class DeviceReader extends ComPort
- public String getMeterData(int meterNumber)
- byte data super.read()
- // use functionality of ComPort to read data
and do high level processing here -
- public void setMeterConfiguration(String config)
17Java course Threads
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Threads in Java
- Java is multitasking oriented!
- Java manages and schedules threads
- Java provides synchronize to help coordinate
multiple threads and access to data
18Java course Threads (example)
MCS - Mixe Communication Solutions M2M
Solutions TC65 Java training
- public class MyThread extends Thread
- public MyThread(String threadName)
- super(threadName)
-
-
- public void run()
- // Execute some task here.
-
-
- public class ThreadTest
- public static void main(String args)
-
- MyThread t new MyThread(argsi)
- t.start()
-
19Java course Handling exceptions/errors
MCS - Mixe Communication Solutions M2M
Solutions Java training
-
- public void processData()
-
- try
-
- readDataFrom(file) // this code might throw
an Exception -
- catch ( IOException e )
-
- System.out.println(e.getMessage())
- // handle the situation
-
- finally
-
- file.close() // always executed
-
20Java course - Classes documentation
MCS - Mixe Communication Solutions M2M
Solutions Java training
All Java classes are documented in so called
javadocs style. Siemens module classes and
methods are documented in HTML pages, see
ltYourDirgt/wtk/docs/
21Java course Sources of information
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Siemens modules API Specification
- ltYourDirgt/wtk/docs/index.html
- Books on Java and J2ME
- J2ME in a Nutshell (by Kim Kepley)
- Wireless Java Programming with J2ME (Dr. Jun Zhu)
- Online information sources
- MCS M2M forum (www.mcs-nl.com/support)
- Siemens Mobile forum (www.benqmobile.com/developer
)
22Training overview
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Java History and Introduction
- Java crash course
- Java software Siemens module JDK installation
- Application programming
- Autostart/OTAP
- Questions discussion future application
23Installation Java Eclipse IDE (1)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Run from CD \...\JDK 1.4\j2sdk-1_4_2_09-windows-i
586-p.exe - Copy Eclipse archive from CD \...\Eclipse\eclips
e-sdk-3.1.2-win32.zip to C\programs\ on your
harddrive. - Unzip archive, this will put Eclipse in
C\programs\eclipse - Start Eclipse by running \programs\eclipse\eclips
e.exe
Siemenspresentation
24Installation Siemens SDK Toolkit CD
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Start setup.exe in SDK toolkit directory on CD
- The setup software will install
- Java SDK environment version 1.4.2_07 if needed
- Sun One Studio Mobility IDE if chosen (Eclipse
needs to be installed manually!) - MES software is needed
- Setup integration of TC65 in existing IDEs
(JBuilder, Eclipse, Sun One Studio).
25Installation Module Exchange Suite
MCS - Mixe Communication Solutions M2M
Solutions Java training
- View the Flash file system from Windows
Explorer. - Make sure that the module is connected to the COM
port that the Module Exchange Suite is configured
to. - Module should be in normal mode and and
hyperterminal is not active on the same COM port.
26Installation File transfer to module
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Windows Based
- To transfer a file to the module, simply use
- your Windows Explorer.
- Command Line Based
- A suite of command line tools is available for
accessing - the modules Flash file system. MESdel, MEScopy,
- MESxcopy, MESdir, MESmkdir, MESrmdir, MESport,
MESclose and MESformat.
27Programming Platform architecture
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Software Architecture
- Based on Java Platform Micro Edition (J2ME)
- Provided by SUN Microsystems Inc.
http//java.sun.com/j2me/ - Information Module Profile (IMP-NG)
- Device specific platform for modules
- IMP-NG MIDP 2.0 LCDUI ( Standard MIDP
without grafical Interface)
28Programming Sand Box Model
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Application runs in Sand Box. This
- means that access to modules
- resource is only possible through
- provided APIs.
- APIs
- (Application Program Interface)
- RS232 API
- AT-Command API
- File I/O API
- IMP 2.0
TC65
Sand Box
Application
Java Virtual Machine
Frame Work
IMP 2.0
RS232 API
AT-CommandAPI
File I/O API
CLDC 1.1 Connected
Limited Device Config.
TC/IP Stack
Firmware
GSM/GPRS Services
PINs of I/O
ASC 1
ASC 0
29Programming - MIDlet application
MCS - Mixe Communication Solutions M2M
Solutions Java training
- The J2ME Mobile Information Device Profile
(MIDP) provides a targeted Java API for writing
wireless applications. - MIDP applications are referred to as MIDlets.
MIDlets are controlled by the mobile device
implementation that supports the CLDC and MIDP.
Since IMP-NG is a subset of MIDP 2.0, IMP
includes MIDlets. - The MIDlet class in the MIDlet package provides
methods to manage a MIDlets life cycle.
30Programming - MIDlet application life cycle
MCS - Mixe Communication Solutions M2M
Solutions Java training
- The MIDlet life cycle defines the protocol
between a MIDlet and its environment. - A MIDlet has three valid states
- Paused The MIDlet is initialised and is
quiescent.(It should not be holding or using any
shared resources). - Active The MIDlet is functioning normally.
- Destroyed The MIDlet has released all of its
resources and terminated. This state is only
entered once.
Siemenspresentation
31Programming - MIDlet application structure
MCS - Mixe Communication Solutions M2M
Solutions Java training
import javax.microedition.midlet. public class
HelloWorld extends MIDlet public
HelloWorld() public void startApp()
throws MIDletStateChangeException // put
here your application code
destroyApp(true) public void pauseApp()
public void destroyApp(boolean
cond) notifyDestroyed()
32Programming Application (executable)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- JAR ? Java Archive
- The JAR file is a compressed file, which contains
the java program(MIDlet all the other Classes
and resources created by the user). - JAD ?Java Application Descriptor
- The JAD file describes the JAR file and its
properties (name, size, version, application
parameters) - Besides class files JAR can contain other
resources (images, data files, configuration
files).
EclipseDemo
33Training overview
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Java History and Introduction
- Java crash course
- Java software Siemens JDK installation
- Autostart/OTAP
- Questions discussion future application
34Autostart Application automatic start
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Most applications are required to autostart when
module is powered up - Setup appliaction nameATSCFGUserware/Autostar
t/AppName,ltpasswordgt,a/ltdirgt/ltapp.jadgt - Setup application autostart delay (in steps of
100ms)ATSCFGUserware/Autostart/Delay,
ltpasswordgt,100(start application 10 seconds
after power up) - Setup application autostart ON/OFFATSCFGUserw
are/Autostart, ltpasswordgt,1 (Use 0 to
switch autostart off)
35Autostart Switch off automatic start
MCS - Mixe Communication Solutions M2M
Solutions Java training
- There are two methods for switching off the
autostart feature - the atscfg AT command, or
- the autostart_off.exe tool (included in the
Installation CD software under wtk/bin) - To disable the automatic start of a user
application follow these steps - 1. Connect the module to the PC
- 2. Make sure, that the module is switched off
- 3. Start the Autostart_Off program
- 4. Select the COM-Port
- 5. Press the Autostart Off button
36OTAP Over The Air Provisioning overview
MCS - Mixe Communication Solutions M2M
Solutions Java training
- OTAP is a mechanism to install, update and delete
JAVA applications over the air. - OTAP is a common practice in the Java world
- OTAP can be fully controlled over SMS and also
via AT commands - Requirements for OTAP
- Web server wich contains .jad and .jar files
- OTAP Controller or SMS Sender
37OTAP Over The Air Provisioning (AT)
MCS - Mixe Communication Solutions M2M
Solutions Java training
- To initiate OTAP with AT command use the
following steps - Setup OTAP parametersATSJOTAPltpasswordgt,http
//www.someserver.com/app.jad,a/ltdirgt/,lthttp_u
sergt, http_password, ltgprs/csdgt,
ltAPN/Tel.numbergt gprs_user,gprs_password - Initiate OTAPATSJOTAP enter
- Trace/Log OTAP processATSCFG"Trace/Syslog/OTAP
","1 (Notice the module wont except any AT
commands after this command is performed).
38OTAP Over The Air Provisioning (SMS) 1
MCS - Mixe Communication Solutions M2M
Solutions Java training
- To initiate OTAP with SMS command (somewhat more
complicated) - Two types of OTAP operations
- Install/Update
- Delete
PDU Generator
39OTAP Over The Air Provisioning (SMS) 2
MCS - Mixe Communication Solutions M2M
Solutions TC65 Java training
The first line is required it is used to
identify an OTAP SM. All other lines are optional
and their order is insignificant, each line is
terminated with an LF '\n including the last
one.
OTAP install/update SMS OTAP_IMPNG PWDsecret JAD
URLhttp//www.some.com/mega.jad APPDIRa/work/ap
pdir HTTPUSERuser HTTPPWDanothersecret BEARERgp
rs APNORNUMaccess.to-thenet.net NETUSERnobody NE
TPWDnothing STARTinstall
OTAP delete SMS OTAP_IMPNG PWDsecret APPDIRa/w
ork/appdir STARTdelete
40OTAP Trace OTAP procedure
MCS - Mixe Communication Solutions M2M
Solutions TC65 Java training
- For easy debugging of the OTAP scenario, the OTAP
procedure can be - traced over the serial interface.
- ATSCFGTrace/Syslog/OTAP,1
41Questions Discussion
MCS - Mixe Communication Solutions M2M
Solutions Java training
- Questions?
- Customer application discussion?