Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 8 for Windows
E50624-01
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

5 Working with Devices

This chapter describes the Oracle Java ME SDK 8 components that enable you to work effectively with devices, including making device connections, creating, configuring, and customizing devices, and detecting external embedded devices.

The Device Manager is an Oracle Java ME SDK 8 service used to manage both emulated and external devices. As soon as you install the Java ME SDK, the Device Manager automatically starts to detect available devices (including any connected hardware devices).

Alternatively, run the device-manager.exe file under bin in the Java ME SDK installation directory. For example, you can use the following command:

C:\> Java_ME_platform_SDK_8.0\bin\device-manager.exe

Oracle Java ME SDK 8 provides several components for working with emulated and external devices. This chapter contains the following sections:

Using the Device Connections Manager

The Device Manager is started automatically when Oracle Java ME SDK 8 is installed. However, it is primarily used for external embedded hardware attached to the computer.

To start the Device Connections Manager, right-click the Oracle Java ME SDK 8.0 Device Manager icon in the notification area of the Windows taskbar and select Manage Device Connections.

To add a new device connection, click Add, enter an IP address or host name, and click OK. The Java ME SDK automatically detects available devices, listing them in the IP Address or Host Name drop-down list. If an embedded hardware device is attached, you can select a COM port for the hardware connection in the Select COM Port drop-down list.

If you have an address you no longer want to detect, select the address and click Remove. The device will no longer be displayed in the Device Connections Manager.

To see a list of registered devices and their configuration information, right-click the Oracle Java ME SDK 8.0 Device Manager icon in the notification area of the Windows taskbar and select Registered Devices.

Using the Device Selector

The Device Selector lists the devices detected by the Device Manager, grouped by platform. The Device Selector can be opened as a tab in NetBeans IDE, or as a separate window.

To access the Device Selector tab in NetBeans IDE, open the Tools menu, select Java ME, and then Device Selector.

To open the Device Selector in a separate window, run the device-selector.exe file under bin in the Java ME SDK installation directory. For example, you can use the following command:

C:\> Java_ME_platform_SDK_8.0\bin\device-selector.exe

The list in the Device Selector matches the list displayed in the Registered Devices window.


Note:

When an external hardware device is detected, such as a Raspberry Pi or Qualcomm IoE (MB997B) embedded board, it appears in the Device Selector window with a sequential number on the end, for example, ExternalEmbeddedDevice1, ExternalEmbeddedDevice2, and so on.


Viewing Platform and Device Properties

To access the Properties tab in NetBeans IDE, open the Window menu, select IDE Tools, and then Properties. You can now select the platform or device node in the Device Selector tab to view the properties of the platform or device in the Properties tab.

To view platform or device properties in a separate window, right-click the platform or device node in the Device Selector tab and select Properties.

To view the platform or device properties in the standalone Device Selector window, select the platform or device node. The properties are displayed in the right pane of the window.

Changing Platform and Device Properties

Properties displayed in gray font or on a gray background cannot be changed. You can adjust properties displayed in black font on a white background. Only MEEP options can be adjusted.

When viewing properties in NetBeans IDE, if you select a property, a short explanation is displayed in the description area below the Properties table.

Device properties consist of the following categories:

  • General

    The following general properties can be changed:

    • Remove IMlet Suite in execution mode: If this option is selected, the IMlet suite and resources created by the IMlet are removed when you exit the IMlet (assuming the IMlet was started in execution mode).

      You should select the execution mode for a project by right-clicking a project, selecting Properties, opening the Run category, and selecting the Regular Execution option under Run Method.

      To run a standalone application (not a NetBeans project) in execution mode, you should use the -Xdescriptor option when running the emulator. For example, you can run the DataCollectionDemo application on the Qualcomm_IoE_Device emulator using the following command:

      > emulator.exe -Xdevice:Qualcomm_IoE_Device -Xdescriptor:DataCollectionDemo.jad
      
    • Phone Number: You can set the phone number to any appropriate sequence, considering country codes, area codes, and so on. If you change this value, the setting will be applied to future instances. The number is a base value for the selected device.

    • Heapsize: The heap is the memory allocated on a device to store your application objects. Select the maximum heap size from the drop-down list.

    • Memory Limit Per Suite in KB: This property enables you to define how much memory in kilobytes an IMlet suite is allocated when started. Unlimited means the IMlet can use as much memory as is required to run, but not more than the size of the heap specified by the Heapsize value.

    • JAM storage size in KB: The amount of storage space in kilobytes available for applications installed over the air.

    • Locale: The locale as defined in the ME Embedded Profile specification at https://jcp.org/aboutJava/communityprocess/edr/jsr361/index.html

  • Monitor

    Selecting the Trace GC, Trace Class Loading, Trace Exceptions, and Trace Method Calls activates tracing for the corresponding device the next time the emulator is started. The trace output is displayed in the Device Log window.


    Note:

    Trace Method Calls returns a lot of messages, which can affect emulator performance.


  • SATSA

    Security and Trust Services (SATSA) provide the ability to define security settings. You can define the host name of a Java Card emulator, and port numbers for slots 0 and 1.

  • Location Provider #1 and Location Provider #2

    The properties in these categories determine the selection of a location provider. Two providers are available so that your application can be tested matching the location provider criteria.

    For more information about these properties, see the Location API at http://jcp.org/en/jsr/detail?id=179

  • Landmark Editor

    This category contains only one property (Max length of input) that defines the maximum length of input for landmarks.

Viewing Device Information

To view the device information in NetBeans IDE, double-click a device node in the Device Selector tab. The Device Information tab opens with detailed information about the device.

To view the device information in the standalone Device Selector window, select a device node. Device information is displayed in the right pane of the window along with the properties.

The Device Information window contains details about the device, such as the supported runtime, supported Java ME extensions, supported optional packages, and other capabilities, such as power management or cellular support.

Editing the Security Configuration

The security configuration for a device is set at the time the device is created using the Client Security Model (CSM). For more information about CSM, see the JSR 361: Java ME Embedded Profile at https://jcp.org/en/jsr/detail?id=361. For more information about how CSM is implemented for Java ME SDK, see Chapter 14, "Security and IMlet Signing".

To edit the security configuration for a device:

  1. Right-click the device node in the Device Selector window and select Security Configuration.

  2. At the top of the Security Configuration window, specify the custom security providers implementation JAR file, and the class names for the custom authentication and security policy providers. For more information about creating custom providers, see Chapter 15, "Custom Security Policy and Authentication Providers".

  3. Select a client in the Clients pane and view its permissions and certificates in the panes to the right.

  4. To add a client, click Add in the Client pane, specify the name, and then click OK. To remove a client, select it and click Remove.

  5. To add a permission, click Add in the Permissions pane, select a permission from the drop-down list, specify a protected resource name, and then click OK. To edit or remove a permission, select it and click Edit or Remove.

  6. To add a certificate, click Add in the Certificates pane, select a certificate from the list, and click OK. To remove a certificate, select it and click Remove.

  7. Click OK to apply changes to the security configuration.

Using the Custom Device Editor

The Custom Device Editor can be used to create custom devices. The appearance of a custom device is generic, but the functionality can be configured according to your specifications.

To run the Custom Device Editor in NetBeans IDE, open the Tools menu, select Java ME, and then Custom Device Editor.

To run the Custom Device Editor in a separate window, run the device-editor.exe file under bin in the Java ME SDK installation directory. For example, you can use the following command:

C:\> Java_ME_platform_SDK_8.0\bin\device-editor.exe

Creating a Custom Device

To create a custom device:

  1. In the Custom Device Editor, select a platform (for example, MEEP) and click New.

  2. Specify a name and description of the device.

  3. Ensure that the Device Configuration and Device Profile match the specifications for your new device.

  4. Select optional packages that provide additional functionality for your device, corresponding to the required configuration.

  5. Define properties for the interfaces and protocols supported by your custom device under the corresponding tabs.

  6. Click OK to create and add the device to the custom device tree.

The created device appears in the Device Selector, and the device definition is saved under \toolkit-lib\devices in the Java ME SDK installation directory. You can run projects from the NetBeans IDE or from the command line on this device.

Setting Custom Device Properties

When you create a new embedded device using the Custom Device Editor, you can use the default implementation or create your own custom implementation for the interfaces discussed in this section.

You can set device properties when you create the custom device, or define device properties later, by selecting your custom device in the Custom Device Editor and clicking Edit.

This section briefly describes the tabs in the custom device properties. For more information about custom device protocols and property settings, see the corresponding help topic by pressing F1 with the necessary tab open.

For each custom device, you can configure properties in the following tabs:

  • GPIO: The General Purpose Input/Output (GPIO) ports are groupings of GPIO pins that can be configured for output, input, or bidirectional.

  • I2C and SPI: The Inter-Integrated Circuit (I2C) and the Serial Peripheral Interface (SPI) tabs are similar. Each one can be used to simulate a simple peripheral slave device that echoes back data sent to it.

  • MMIO: The Memory-Mapped Input/Output (MMIO) tab can be used to emulate the MMIO interface bus. It facilitates I/O between the CPU, memory, and peripheral devices.

  • ADC: The Analog-to-Digital Converter (ADC) tab can be used to set up the conversion of an input analog stream to a sequence of digital numbers.

  • DAC: The Digital-to-Analog Converter (DAC) tab can be used to set up the conversion of a sequence of digital numbers to an analog stream.

  • PWM: The Pulse Width Modulation (PWM) tab can be used to set up the conformance of a digital signal's width based on its duration.

  • Pulse Counters: The Pulse Counters tab can be used to set up pulse counters that track the number of pulses sent to a device.

  • Line-Oriented Displays: The Line-Oriented Displays tab can be used to configure a line-oriented display that provides a simple user interface in emulation.

  • Headless Input Devices: The Headless Input Devices tab can be used to configure input devices not connected to a monitor, such as buttons.

Managing Custom Devices

Custom devices should be managed using the Custom Device Editor. Using the tool ensures that your device can be detected and integrated with Oracle Java ME SDK 8.

To clone a device, select it and click Clone. Provide a unique name to prevent confusion.

To remove a device, select it and click Remove. This completely deletes the device.

To save the device configuration as a ZIP file, select it and click Export. Specify the path and name in the file system explorer.

To load a device configuration from a previously exported ZIP file, click Import and select the file in the file system explorer.

Making Device Connections

The configuration of all peripherals, except Universal Asynchronous Receiver/Transmitter (UART), ATCommands devices, and WatchDog timers, can be inspected in the emulator main window. The configuration of UART is defined by the hardware configuration of the COM ports on your PC.

For more information about connecting to a UART Device, see Connecting to a UART Device.

To open a serial port, such as COM1 or COM2, in Windows, use the Device Connections Manager. You can use the following code in the application:

Connector.open("comm:COM1")

Connecting to a UART Device

To use the UART functionality, you must configure the daapi_config.json file located under runtimes\meep\lib in the Java ME SDK installation directory. For example, the default location is:

C:\Java_ME_platform_SDK_8.0\runtimes\meep\lib\daapi_config.json

The configuration of the hardware device name for the UART ports in Windows is made up of two settings:

  • The deviceNumber property of UARTDeviceConfiguration

  • The system property of device.uart.prefix

For example, if UARTDeviceConfiguration.deviceNumber = 1 and device.uart.prefix = COM, then the hardware device name is COM1.

For an already opened UART, you can add it to the peripheral manager by calling DeviceManager.open with the configuration object.

Additional Peripherals

The EmbeddedDevice1 emulator provides support for additional peripherals: ATDevice and Watchdog timers. Use the following configuration settings to open them using the device manager: