Siemens TC65 manual Programming the MIDlet, Threads, Example

Models: TC65

1 90
Download 90 pages 14.61 Kb
Page 88
Image 88

TC65 JAVA User's Guide

Strictly confidential / Released

s

12.2Programming the MIDlet

The life cycle and structure of MIDlets are described in Chapter 6. Since the MIDlets will run on J2ME™, all of J2ME™’s features, including threads, are available. Small applications, such as those without any timer functions or those used only for tests and simple examples, can be written without using threads. Longer applications should be implemented with threads.

12.2.1Threads

Although small applications can be written without using threads longer applications should use them. The Java programming language is naturally multi-threaded which can make a substantial difference in the performance of your application. Therefore we recommend referring to Java descriptions on threads before making any choices about threading models. Threads can be created in two ways. A class can be a subclass of Thread or it can implement Runnable.

For example, threads can be launched in startApp() and destroyed in destroyApp(). Note that destroying Java threads can be tricky. It is recommended that the developer read the Java documentation on threads. It may be necessary to poll a variable within the thread to see if it is still alive.

12.2.2Example

/* This example derives a class from Thread and creates two instances

*of the subclass. One thread instance finishes itself, the other one

*is stopped by the main application. */

package example.threaddemo;

import javax.microedition.midlet.*;

public class

ThreadDemo extends

MIDlet {

 

/* Member variables */

// Flag for stopping

threads

boolean

runThreads = true;

DemoThread

thread1;

//

First instance of

DemoThread

DemoThread

thread2;

//

Second instance of DemoThread

/* Private class implementing the thread to be started by the * main application */

private class DemoThread extends Thread { int loops;

public DemoThread(int waitTime) {

/* Store number of loops to execute */ loops = waitTime; System.out.println("Thread(" + loops + "): Created");

}

public void run() { System.out.println("Thread(" + loops + "): Started"); for (int i = 1; i <= loops; i++) {

/* Check if main application asked thread to die */ if (runThreads != true) {

System.out.println("Thread(" + loops + "): Stopped from outside"); /* Leave thread */

return;

}

/* Print loop counter and wait 1 second,

*do something useful here instead */ System.out.println("Thread(" + loops + "): Loop " + i);

TC65 JAVA User's Guide_V05

Page 88 of 90

26.09.2005

Page 88
Image 88
Siemens TC65 manual Programming the MIDlet, Threads, Example

TC65 specifications

The Siemens TC65 is a compact and powerful GSM/GPRS module designed for a wide range of mobile communication applications. With its robust features, the TC65 perfectly meets the growing demands for connectivity in various industries, including automotive, telematics, and industrial automation.

A standout feature of the TC65 is its compact size, allowing it to be easily integrated into various devices without compromising on performance. The module supports GSM (Global System for Mobile Communications) and GPRS (General Packet Radio Service), providing reliable and efficient voice and data transmission.

One of the key technologies incorporated in the TC65 is its integrated TCP/IP stack, which allows for seamless internet connectivity and enables application developers to create IoT solutions with ease. This capability is essential for remote monitoring, data logging, and other applications that require continuous data exchange.

The TC65 also boasts extensive multimedia capabilities, including support for SMS, MMS, and voice calls. This makes it suitable for applications that require not only data transmission but also communication features. Additionally, it supports various codecs for voice compression, ensuring high-quality audio in voice applications.

Enhanced security features are another highlight of the TC65. It incorporates comprehensive security protocols to safeguard data transmission, making it suitable for sensitive applications in finance, healthcare, and other critical sectors. The module also includes an integrated SIM application toolbox that supports the development of secure and customizable applications.

For developers, the TC65 offers an easy-to-use software development kit (SDK), simplifying the process of application development. This means that businesses can quickly create and deploy solutions tailored to their specific needs.

The module operates across a wide voltage range and is designed to tolerate challenging environmental conditions, making it ideal for industrial use. It supports various interfaces, including UART, GPIO, and I2C, enabling it to connect with a variety of peripherals and sensors, thus expanding its usability.

In summary, the Siemens TC65 combines compact design, versatile communication capabilities, advanced security features, and developer-friendly resources, making it an excellent choice for anyone looking to implement reliable and sophisticated GSM/GPRS communication in their applications. The TC65 is a valuable asset in the evolving landscape of connected devices and IoT solutions.