Skip Headers
Oracle® Java ME Embedded Getting Started Guide for the Windows Platform
Release 8 EA 2 for NetBeans on Windows
E48511-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

Beta Draft: 2014-02-15

5 Working With Devices

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

The Oracle Java ME SDK 8 EA 2 provides three components for working with emulated and external devices in the NetBeans 8.0 Beta IDE:

The Device Connections Manager is started automatically when Oracle Java ME SDK 8 EA 2 is installed. However, its primary usefulness is for external embedded hardware is attached to the Windows 7 PC running

The Device Manager

The Device Manager icon is put on your desktop when you first install Oracle Java ME SDK 8 EA 2, as shown in Figure 5-1. It's located in your Windows 7 system tray and can be run without starting the NetBeans 8.0 Beta.

Figure 5-1 The Device Connections Manager Icon

Description of Figure 5-1 follows
Description of "Figure 5-1 The Device Connections Manager Icon"

The Device Manager is an Oracle Java ME SDK 8 EA 2 service used to manage both emulators and external devices. The Device Manager automatically detects available devices (including any connected hardware devices) and lists those devices in the Device Selector window.

To use the Device Manager:

  1. If not already running, the Device Manager can be started in two ways:

    • From NetBeans 8.0 Beta, select Tools > Java ME > Active Device Manager > Oracle Java(TM) ME SDK 8.0 EA

    • From the Windows command line. Type:

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

  2. When the Device Manager is in the Windows system tray, right-click the icon. This displays the Device Connections Manager menu, as shown in Figure 5-2.

    Figure 5-2 The Device Connections Manager Menu

    Description of Figure 5-2 follows
    Description of "Figure 5-2 The Device Connections Manager Menu"

  3. Select Manage Device Connections to display the Device Connections Manager screen, as shown in Figure 5-3.

    Figure 5-3 The Device Connections Manager Screen

    Description of Figure 5-3 follows
    Description of "Figure 5-3 The Device Connections Manager Screen"

  4. To add a new device connection, click Add. This displays the Add Device Connection box, as shown in Figure 5-4.

    Figure 5-4 The Add Device Connection Form

    Description of Figure 5-4 follows
    Description of "Figure 5-4 The Add Device Connection Form"

  5. Enter an IP Address or Host Name (for example, localhost). Click OK.

    If an embedded hardware device is attached, you can select a COM port for the hardware connection in the Select COM Port field.

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

To see a list of registered devices and their configuration information, right-click the Device Manager icon in the system tray and select Registered Devices, as shown in Figure 5-5.

Figure 5-5 The Registered Devices Screen

Description of Figure 5-5 follows
Description of "Figure 5-5 The Registered Devices Screen"

Using the Device Selector

The Device Selector lists the devices currently available in NetBeans 8.0 Beta, grouped by platform, as shown in Figure 5-6. If the Device Selector is not visible, click on the Device Selector tab, or select Tools > Java ME > Device Selector.

The list in the Device Selector matches the list displayed in the Registered Devices window, as shown in Figure 5-6.


Note:

The ExternalEmbeddedDevice1 only appears as a configured device when an external hardware device is detected, such as a Raspberry Pi or Qualcomm Orion IoE (MB997B) embedded board.


Figure 5-6 The Device Selector

Description of Figure 5-6 follows
Description of "Figure 5-6 The Device Selector"

The Device Selector can also be launched from the Windows command line. Enter the following:

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

This displays the standalone Device Selector, as shown in Figure 5-7.

Figure 5-7 The Standalone Device Selector

Description of Figure 5-7 follows
Description of "Figure 5-7 The Standalone Device Selector"

Viewing Properties

Using the Device Selector, you can view properties information for a platform or a device.

The Properties window is, by default, located on the right side of the NetBeans 8.0 Beta user interface. If the Properties window is not visible, select Windows > IDE Tools >Properties

Instances of similar devices (for example, EmbeddedDevice1 and EmbeddedDevice2) have the same properties and capabilities, but unique names and phone numbers. This makes it easy for you to test communication between devices of the same type.

Viewing Platform Properties

To view platform properties from the Device Selector, click on the platform name (for example, CLDC, Oracle Java ME SDK 8 EA 2). To view the platform properties in a separate window, right-click the platform node and select Properties. This displays the Platform Properties in a pop-up window, as shown in Figure 5-8.

Figure 5-8 Viewing Platform Properties

Description of Figure 5-8 follows
Description of "Figure 5-8 Viewing Platform Properties"

Viewing Device Information

In the Device Selector window, double-click on a device name (for example, EmbeddedDevice1). The Device Information tab opens in the Main window.

The Device Information window displays 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, as shown in Figure 5-9.

Figure 5-9 Viewing Device Information

Description of Figure 5-9 follows
Description of "Figure 5-9 Viewing Device Information"

Viewing Device Properties

In the Device Selector window, click a device name to display the properties for the device, as shown in Figure 5-10.

Figure 5-10 Viewing Device Properties

Description of Figure 5-10 follows
Description of "Figure 5-10 Viewing Device Properties"

Setting Device Properties

In the Device Selector window, right-click a device and select Properties. Any properties shown in gray font cannot be changed. You can adjust the device properties shown in black. Only MEEP options can be adjusted.

Setting General Properties

This section lists general properties that can be changed.

Remove IMlet Suite in execution mode. If this option is enabled, record stores and other resources created by the IMlet are removed when you exit the IMlet (assuming the IMlet was started in execution mode).

Phone Number. You can set the phone number to any appropriate sequence, considering country codes, area codes, and so forth. If you reset this value, the setting applies 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. The Heapsize property is the maximum heap size for the emulator. You can select a new maximum size from the drop down menu.

Memory Limit Per Suite. This property allows you to define how much memory an IMlet suite is allocated upon launch. Unlimited means the IMlet can use as much memory as required to run.

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

Locale. Type in the locale as defined in the ME Embedded Profile specification at:

https://jcp.org/aboutJava/communityprocess/edr/jsr361/index.html

Setting Monitor Properties

If enabled (checked), the Check boxes for Trace GC (garbage collection), Trace Class Loading, Trace Exceptions, and Trace Method Calls activate tracing for the selected device the next time the emulator is launched. The trace output is displayed at runtime in the user interface Output window.


Note:

Trace Method Calls returns many messages, and emulator performance can be affected.


Setting SATSA Properties

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

Setting Properties for Location Provider #1 and #2

These properties determine the selection of a location provider. Two providers are offered so that your application can be tested matching the location provider criteria.

If you select a property a short explanation is shown in the description area just below the Properties table. For more information on these values, see the Location API at:

http://jcp.org/en/jsr/detail?id=179.

Setting Landmark Editor Properties

The Landmark Editor has only one property, maximum length of input.

Setting Security Properties

Security properties for a device are set at the time the device is created, using the Client Security Model.

To edit security settings for a specific device in the Device Selector:

  1. Select a device from the list of available devices, for example, EmbeddedDevice1, as shown in Figure 5-11.

    Figure 5-11 The Device Selector Screen with a Selected Device

    Description of Figure 5-11 follows
    Description of "Figure 5-11 The Device Selector Screen with a Selected Device"

  2. Right click on the selected device to display the device menu. Scroll down and select Edit Security Policy.

  3. This displays the Security Policy screen, as shown in

    Figure 5-12 The Security Policy Screen

    Description of Figure 5-12 follows
    Description of "Figure 5-12 The Security Policy Screen"

  4. EmbeddedDevice1 is a Signed device. The specific permissions that are granted to it are defined in the Permissions category. The certificates that verify its signing are listed in the Certificates category.

    To edit the EmbeddedDevice1 security settings, do the following:

    1. To add a Client, click Add in the Clients category. This displays the Add Client form, as shown in Figure 5-13. Enter the new Client name and click OK.

      Figure 5-13 The Add Client Form

      Description of Figure 5-13 follows
      Description of "Figure 5-13 The Add Client Form"

    2. To add a Permission, click Add in the Permissions category. This displays the Add Permissions form, as shown in Figure 5-14. Select a permission from the drop down list in the Permission field, enter a Protected Resource Name, and click OK.

      Figure 5-14 The Add Permission Form

      Description of Figure 5-14 follows
      Description of "Figure 5-14 The Add Permission Form"

    3. To edit a Permission, click Edit in the Permissions category. This displays the Edit Permissions form, as shown in Figure 5-15. Select a permission from the drop down list in the Permission field, and make other edits, for example, to the Actions Requested list, and click OK.

      Figure 5-15 The Edit Permission Form

      Description of Figure 5-15 follows
      Description of "Figure 5-15 The Edit Permission Form"

    4. To add a Certificate, click Add in the Certificates category. This displays the Add Certificates form, as shown in Figure 5-16. Enter the certificate information and click OK.

      Figure 5-16 The Add Certificates Form

      Description of Figure 5-16 follows
      Description of "Figure 5-16 The Add Certificates Form"

    5. Once you have finished making Security Policy changes, click OK. The next time you start the configured device, your changes will take effect.

Click Remove in any category to remove a Client, Permission, or Certificate, and click OK for it to take effect.

For more detailed information on the Security Client Model, see the Java ME Embedded Profile (MEEP) Specification, at:

https://jcp.org/aboutJava/communityprocess/edr/jsr361/index.html

Using the Custom Device Editor

With the Custom Device Editor you can create your own devices. The appearance of a custom device is generic, but the functionality can be tailored to your own specifications.

Creating a Custom Device

Follow these steps to create a custom device in NetBeans 8.0 Beta:

  1. Select Tools > Java ME > Custom Device Editor

    The Custom Device Editor is shown in Figure 5-17. The custom device tree displays platforms and custom devices, if any. For example, the ME Embedded Platform (MEEP).

    Figure 5-17 The Custom Device Editor

    Description of Figure 5-17 follows
    Description of "Figure 5-17 The Custom Device Editor"

    To run a standalone Custom Device Editor, use the device-editor.exe command from the Windows command line. For example:

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

  2. Select a platform and click the New... button. This displays the New Device dialog box, as shown in Figure 5-18.

    Figure 5-18 The New MEEP Device Box

    Description of Figure 5-18 follows
    Description of "Figure 5-18 The New MEEP Device Box"

  3. Change the default Device Configuration or Device Profile to match the specifications for your new device.

  4. Select Optional Packages. Optional packages provide additional functionality to your device and can be individually selected to correspond to the configuration of your custom device, as shown in Figure 5-19.

    Figure 5-19 New Custom Device Optional Packages

    Description of Figure 5-19 follows
    Description of "Figure 5-19 New Custom Device Optional Packages"

  5. Define properties for the interfaces and protocols supported by your custom device, as shown in Figure 5-20. For more information on custom device protocols and property settings, see "Setting Custom Device Properties."

    Figure 5-20 New Custom Device Protocols

    Description of Figure 5-20 follows
    Description of "Figure 5-20 New Custom Device Protocols"

  6. Click OK.

    Your device is added to the custom device tree, as shown in Figure 5-21.

Figure 5-21 A Newly-Created Custom Device

Description of Figure 5-21 follows
Description of "Figure 5-21 A Newly-Created Custom Device"

Eventually, the newly-added device appears in the Device Selector. You can run projects from the IDE or from the command line for the custom device.

If you do not want a custom device to appear in the Device Selector, you must remove it from the custom device tree.

Once a newly created custom device is added to the Device Selector, the device definition is saved in:

<install_dir>\toolkit-lib\devices

Setting Custom Device Properties

When you create a new embedded device using the Custom Device Editor (Tools > Java ME > 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 first create your custom device. Or, you can define device properties later, by selecting your custom device in the Custom Device Editor, as shown in Figure 5-21, and clicking Edit.

General Purpose Input Output (GPIO)

A GPIO port is a platform-defined grouping of GPIO pins that may be configured for output, input, or bidirectional. The custom device GPIO screen is shown in Figure 5-22.

Figure 5-22 The GPIO Custom Device Screen

Description of Figure 5-22 follows
Description of "Figure 5-22 The GPIO Custom Device Screen"

To add a custom Pin:

  1. Click Add Pin to add a row to the Pins table.

  2. A new row is highlighted in the Pins table. To customize a field in the pin row, double-click in a cell and define the field for your custom device.

  3. For additional pins, click Add Pin again. A second row is added, allowing you to define a second pin for your custom device. Add as many rows as required for the number of pins defined for your custom device.

To add a custom Port:

  1. Click Add Port to add a row to the Ports table.

  2. A new row is highlighted in the Ports table. To customize a field in the port row, double-click in a cell and define the field for your custom device.

  3. For additional ports, click Add Port again. A second row is added, allowing you to define a second port for your custom device. Add as many rows as required for the number of ports defined for your custom device.

To remove a pin, highlight the row for the pin to be removed, and click Remove Pins. To remove a port, highlight the row for the port to be removed, and click Remove Ports.

When your custom device is fully configured, click OK to add it to the Custom Device Editor, as shown in Figure 5-21.

Inter-Integrated Circuit (I2C) and Serial Peripheral Interface (SPI)

The Inter-Integrated Circuit (I2C) and Serial Peripheral Interface (SPI) are very similar. Each simulates a simple peripheral slave device that echoes back data sent to it. The I2C and SPI custom screens are also very similar, as shown in Figure 5-23.

Figure 5-23 The I2C or SPI Custom Device Screen

Description of Figure 5-23 follows
Description of "Figure 5-23 The I2C or SPI Custom Device Screen"

To create a custom I2C or SPI interface for your custom device:

  1. Select Sample Echo to select the default bus. Or, select Custom to define your own bus implementation.

    If you select Custom:

    • Supply your bus implementation JAR file and the name of the Java class that implements the bus.

      For I2C, the bus is:

      com.oracle.jme.toolkit.deviceaccess.i2c.I2CSlaveBus

      For SPI, the bus is:

      com.oracle.jme.toolkit.deviceaccess.spi.SPISlaveBus

  2. To add Slaves, click Add and specify an ID and Name.

  3. When your I2C or SPI device is defined, click OK. This adds the I2C or SPI implementation to your custom device.

To remove a row, select the row and click Remove.

Memory-Mapped I/O (MMIO)

The MMIO tab emulates the Memory-Mapped I/O (MMIO) interface bus. It facilitates input/output between CPU memory and a peripheral device. To define a custom MMIO implementation use the MMIO custom device screen, as shown in Figure 5-24.

Figure 5-24 The MMIO Custom Device Screen

Description of Figure 5-24 follows
Description of "Figure 5-24 The MMIO Custom Device Screen "

If you want to provide your own MMIO emulation, you must specify a custom handler.

To create a custom MMIO implementation:

  1. Click Default to use the default handler JAR file. If you click Custom, you must specify a custom handler using the following fields:

    • Implementation JAR File. Supply a JAR file for your implementation.

    • Implementation Class Name. Supply the name of the Java class that implements com.oracle.jme.toolkit.deviceaccess.mmio.MMIOHandler.

    The default handler JAR file is:

    installdir\toolkit-lib\devices\Embeddedevice1\code\emulator_deviceaccess_mmio-sample-handler.jar

  2. Click Add Device. This adds a new row to the Devices table.

  3. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.

  4. To add memory, click Add Memory. This adds a row to the Device Memory Blocks and Registers table.

  5. When you are satisfied with your custom entries, click OK

To remove a device, select a row and click Remove Device. To remove memory, select a row and click Remove Memory.

Analog to Digital Conversion (ADC)

Analog to digital conversion takes an analog stream as input and converts it to a sequence of digital numbers. To specify a custom analog-to-digital conversion channel, you must add a channel to the Channels window, as shown in Figure 5-25.

Figure 5-25 The ADC Custom Device Screen

Description of Figure 5-25 follows
Description of "Figure 5-25 The ADC Custom Device Screen"

To add a custom ADC channel:

  1. Click Add. This adds a new row to the Channels table.

  2. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.

  3. When you are satisfied with your custom entries, click OK

To remove a channel, select a row and click Remove.

Digital to Analog Conversion (DAC)

Digital conversion takes a sequence of numbers as an input and converts it to an analog stream. To specify a custom digital-to-analog conversion channel, you must add a channel to the Channels window, as shown in Figure 5-25.

Figure 5-26 The DAC Custom Device Screen

Description of Figure 5-26 follows
Description of "Figure 5-26 The DAC Custom Device Screen"

To add a custom DAC channel:

  1. Click Add. This adds a new row to the Channels table.

  2. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.

  3. When you are satisfied with your custom entries, click OK

To remove a channel, select a row and click Remove.

Pulse Width Modulation (PWM)

Pulse width modulation conforms the width of a digital signal based on its duration. To specify a custom pulse width modulation channel, you must add a channel to the Channels window, as shown in Figure 5-27.

Figure 5-27 The PWM Custom Device Screen

Description of Figure 5-27 follows
Description of "Figure 5-27 The PWM Custom Device Screen"

To add a custom PWM channel:

  1. Click Add. This adds a new row to the Channels table.

  2. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.

  3. Once you are satisfied with your custom entries, click OK

To remove a channel, select a row and click Remove.

Pulse Counters

A pulse counter tracks the number of pulses sent to a device. To specify a custom pulse counter, you must add a channel to the Pulse Counters window, as shown in Figure 5-28.

Figure 5-28 The Pulse Counters Custom Device Screen

Description of Figure 5-28 follows
Description of "Figure 5-28 The Pulse Counters Custom Device Screen"

To add custom Pulse Counter:

  1. Click Add. This adds a new row to the Pulse Counters table.

  2. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.

  3. Once you are satisfied with your custom entries, click OK

To remove a channel, select a row and click Remove.

Line-Oriented Displays

Configuring a line-oriented display allows you to customize a simple user interface in emulation. To customize a line-oriented display, use the Line-Oriented Displays tab in the Custom Device Editor, as show in Figure 5-29.

Figure 5-29 The Line-Oriented Display Custom Device Screen

Description of Figure 5-29 follows
Description of "Figure 5-29 The Line-Oriented Display Custom Device Screen"

To configure a new Line-Oriented Display custom device:

  1. Set the following Standard Colors:

    • Standard Text Color. The default color for text is black (000000 in Hexadecimal). To change the text color, click on the rectangle. This displays the Standard Text Color form, as shown in Figure 5-30.

      To set text to a specific color, select the color square from the color map and click OK. Or, click on the following tabs to customize text color based on a variety of sliding-scale color values:

      • HSV. Allows you to customize Hue, Saturation, and Value fields.

      • HSL. Allows you to customize Hue, Saturation, and Lightness fields.

      • RGB. Allows you to customize Red, Green, and Blue fields.

      • CMYK. Allows you to customize Cyan, Magenta, and Yellow fields.

      Figure 5-30 The Standard Text Color Form

      Surrounding text describes Figure 5-30 .
    • Standard Background Color. The default background color for is white (FFFFFF in Hexadecimal). To change the background color, click on the rectangle. This displays the Standard Background Color form (same as the Standard Text Color form).

      Select a background color and click OK. When the color is changed, the new color value is displayed in Hex.

    • Standard Lighting Color. The default lighting (highlighting) color is white (FFFFFF in Hexadecimal). To change the lighting color, click on the rectangle. This displays the Standard Lighting Color form (same as the Standard Text Color form).

      Select a lighting color and click OK. When the color is changed, the new color value is displayed in Hex.

  2. Click Add. This adds a new row to the Line-Oriented Displays table.

  3. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.


    Note:

    The Line-Oriented Display Custom Device Screen has many settings that scroll to the right. To fully configure your custom implementation, ensure that all the cells in the new row have been defined.


  4. Once you are satisfied with your custom entries, click OK

To remove a Line-Oriented Displays, select a row and click Remove.

Headless Input Devices

A headless input device could be buttons, for example, on an embedded hardware device, or other entry devices not connected to a monitor or screen. To add a custom Headless Input Device, do the following:

  1. Click Add. This adds a new row to the Headless Input Devices table.

  2. To define individual settings in a row for your custom device, double-click in a cell to enter a value for that field.

  3. Once you are satisfied with your custom entries, click OK

To remove a channel, select a row and click Remove.

Managing Custom Devices

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

  • New. Select a platform and click New to add a new device.

  • Edit. Select a device to change, and click Edit.

  • Clone. Select a device to copy, and click Clone. To prevent confusion, be sure to provide a unique name.

  • Remove. Select a device to delete and click Remove. This action completely deletes the device.

  • Import. Select a .zip file created with the Export command and click Import.

  • Export. Select one or more devices to save, and click Export.

    An exported device is stored in a .zip file and saved to any location the user chooses.

Making Device Connections

The configuration of all peripherals, except UART, can be inspected in the emulator main window. The configuration of UART is defined by the hardware configuration of the COM ports on your Windows 7 PC.

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

To open a serial port, such as COM1 or COM2, in Windows you can use the Device Connections Manager. In application code, you can use Connector.open("comm:COM1")

Connecting to a UART Device

To utilize the Universal Asynchronous Receiver/Transmitter (UART) functionality, you need to create a configuration file as shown here:

javacall\configuration\ojwc\win32\properties_deviceaccess_at.xml

The configuration of the hardware device name for the UART ports on your Windows 7 PC 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 PeripheralManager.open with the configuration object.

Additional Peripherals

The Oracle Java ME SDK 8 EA 2 EmbeddedDevice1 emulator provides support for additional peripherals, ATDevice and Watchdog timers. Use the following configuration settings to open them using the PeripheralManager: