What is the difference between CLDC and MIDP for Java Mobile? - java-me

Could anyone explain what the difference is between CLDC and MIDP?

Java Mobile Edition has two different components.
The first, configuration, is the JVM and the core classes for running a virtual machine such as IO, collection classes, dates, strings, ext. CLDC is a configuration
The other, profile, contains classes for that are more utilities that are built on top of this, such as UI, encryption, persisting local data, ect. MIDP is a profile

J2ME technology is made up of two configurations: the Connected Limited Device Configuration(CLDC) and the Connected Device Configuration(CDC).
Connected Limited Device Configuration (CLDC) is for devices with very constrained resources, like 160-512 KB of memory, limited bandwidth connectivity and 16-bit or 32-bit processor. CLDC does not supports full featured Java virtual machine. It does not supports floating point numbers, Thread groups, Object finalization, JNI, reflection, User class loaders.
Connected Device Configuration (CDC) is for devices with 2MB or more for Java platform, high bandwidth network connectivity and 32-bit processor. CDC supports a complete, full featured Java virtual machine.

Related

WebUSB API, for pushing commands/configuration to the device through webApp

I am doing some research on the WebUSB API for our company because we are going to start to manufacture devices in house.
Our current device manufacture comes with an application so the team can plug the device into a computer and diagnose it. Their application allows us to read outputs from the device, as well as pushing commands/configuration to the device over a wired connection.
Since this device is 100% ours, we are also responsible for building out the diagnostic tooling. We need some sort of interface that allows a user to read outputs and send commands/configuration to the device over a wired USB connection.
Is the webUSB the correct API? If not, what are some suggestions for accomplishing the requirement? Are we limited to building some sort of desktop or mobile application?
I would recommend resources below to read to help you understand if the WebUSB API fits your needs or not:
https://web.dev/devices-introduction/ helps you pick the appropriate API to communicate with a hardware device of your choice.
https://web.dev/build-for-webusb/ explains how to build a device to take full advantage of the WebUSB API.
From what you describe, WebUSB isn't strictly required but won't hurt either.
First and foremost, you will need to implement the USB interfaces reading data and sending configurations. It will be a custom protocol, and not one of the standard USB device classes such as HID, video or mass storage. The details of the protocol and if you use control, interrupt or bulk transfers is your choice.
I'm assuming you will connect the devices to Windows PCs, and you likely don't want to put money into writing device drivers. If so, the easiest approach is to add the required descriptors and control requests required for Microsoft OS 2.0 Descriptors. That way, the WinUSB driver will be installed automatically when the device is plugged in.
Using the WinUSB API, a Windows application will then be able to communicate with the USB device. No additional drivers are needed. (On macOS and Linux it's even easier as you don't need the Microsoft OS 2.0 Descriptors in the first place.)
On top of that you can implement the additional descriptors and control requests for WebUSB. It will provide the additional benefit that you can write a web application (instead of a native application) for communicating with the USB device. (Currently, you are restricted to the Chrome browser.) WebUSB devices should implement the WinUSB descriptors as the alternative (.INF files, manual installation process) is a pain.
The already mentioned web page https://web.dev/build-for-webusb/ is a complete example of how to implement it.

Is it a good idea to advertise a Bluetooth GATT Service solely via the 'service data' data type?

We're designing a Bluetooth LE peripheral that implements some primary GATT service and needs to advertise the existence of the service as well as a few bytes of data related to the service. The device is intended to connect to arbitrary consumer smartphones (therefore mostly Android and iOS). We use a 16-bit service UUID and plan to advertise the related data via the advertising data type 0x16 (Service Data - 16 bit UUID). Due to the limited size of the advertising PDU, we'd like to avoid any additional advertising data, most notably we'd like to avoid advertising the same UUID also via data type 0x03 (Complete List of 16-bit UUIDs).
As the device should be used with consumer smartphones, compatibility is a major concern and therefore the compliance with relevant standards is as well. A critical aspect seems to be that the smartphone OSes should be able to do efficient filtering for devices advertising our service, so the app may run and listen in the background.
A safe approach would be to advertise both, 'service data' as well as 'complete list of UUIDs', because all OSes are certainly able to filter for UUIDs advertised in the latter, but this would exceed the size of the advertising PDU. We could also configure the mobile's BLE scanner to return all BLE devices nearby, without any filtering and do the filtering in our own code, but this wouldn't be efficient and wouldn't allow to run in the background.
We did some testing with different smartphones (Android and iPhones, older and newer ones) and at the first glance filtering for service UUIDs when only the service data type is advertised, seems to work just fine. However, we couldn't find any documentation (neither for Android nor for iOS) that definitely states that this is a supported scenario, so we can't be sure that it works on all phones and also in the future.
The Apple Accessory Design Guidelines section 36.4 refers to the Bluetooth Core Specification Supplement, Part A and states the following:
The advertising data sent by the accessory should contain at least the following information as described in the Bluetooth Core Specification Supplement, Part A:
Flags
TX Power Level
Local Name
Services
[...]
The primary services should always be advertised in the advertising PDU.
However, this doesn't make clear which kind of advertising data type should be used and the same is true for the Android documentation.
With this context my questions are:
Is it a good idea to advertise the primary GATT service solely via the 'service data' data type?
Would this even comply to the Bluetooth Core Specification?
Is there any documentation for Android and iOS that makes clear, whether this is a supported scenario from the OS standpoint (I actually don't mean the OS source code)?
Are there any Android (>= 5.0) or iOS (>= 11) devices that would not be able to filter for service UUIDs advertised via the 'service data' data type?
What is the best practice in such a case, given the limited size of the advertising PDU?
Thank you for your thoughts!

J2ME architecture

I was reading about the J2ME architecture where it was written that there are 3 layers
1) Configuration Layer: It has JVM and interacts with the OS
2) Profile layer: Minimum set of API's for small device
3) MIDP layer: Contains Java API's
The book is J2ME: The Complete Reference
QUESTIONS
1) Do every phone have an OS? If not what is the first layer doing in that case?
2) What is API's for small device?
3) MIDP is itself a profile which means it should be at second layer then how come it is at third layer?
Configurations and profiles are the main elements that comprise J2ME’s modular design. These two elements enable support for the plethora of devices that
J2ME supports.
A J2ME configuration defines a minimum Java platform for a family of devices.
Members of a given family all have similar requirements for memory and processing power.
A configuration is really a specification that identifies the systemlevel facilities available, such as a
set of Java language features,
the characteristics and features of the virtual machine present,
and the minimum Java libraries that are supported.
Software developers can expect a certain level of system support
to be available for a family of devices that uses a particular configuration.
A configuration also specifies a minimum set of features for a category of devices.
Device manufacturers implement profiles to provide a real platform for a family
of devices that have the capabilities that a given configuration specifies.
The other J2ME building block, the profile, specifies the application-level interface
for a particular class of devices. A profile implementation consists of a set of Java
class libraries that provide this application-level interface. Thus, a profile theoretically could specify all kinds of functionality and services.
This is not the intention of its creators, however. The creators of J2ME intend that
a profile should address the needs of a specific device category or vertical market
pertaining to that device category. The idea is not to place a plethora of unrelated
application level features in a profile. Rather, the main goal is to guarantee interoperability—which doesn’t necessarily imply compatibility between different manufacturers’ implementations—between all devices of the same category or vertical
market family to define a standard platform for Java application development.
For example, a profile might support a network communication facility for the
popular Short Message Service (SMS) standard widely used by mobile phones.
Because the SMS standard is a ubiquitous feature of mobile telephony, it makes
sense to define this service in a profile that targets mobile phones, rather than to
build it into a configuration.
A profile is implemented on top of a configuration, one step closer to the implementation of real-world applications.
Typically, a profile includes libraries that are
more specific to the characteristics of the category of devices they represent than
are the libraries that comprise configurations.
Applications are then built on top
of the configuration and profile; they can use only the class libraries provided by
these two lower-level specifications. Profiles can be built on top of one another. A
J2ME platform implementation, however, can contain only one configuration.
Figure 1.1 shows the conceptual layers that comprise the J2ME platform.
So far, these notions of configurations, profiles, and platform definitions is somewhat abstract. The next section gives you a more concrete description of the characteristics of actual environments.
Configurations and Profiles
A configuration specifies three basic elements:
• a set of Java programming language features
• a set of Java virtual machine features
• a set of supported Java libraries and application programming
interfaces (APIs)
Hope this will help you to understand J2ME Architecture.
Answers are as follows,
Yes, Every Phone has Operating System.
API's for small device(mobile phone) is depends on the oprating system loaded into the device.
MIDP is made up of Libraries, this is the reason it is on third layer as shown in the picture in above answer of Sajid.

Health Device Profile in Windows

I am going to have a project that can get data from devices that support Health Device Profile(HDP) in Windows.
I find Bluez but it is only available in Linux. Is there any alternative in Windows? Thank You
There are multiple suppliers of Bluetooth stack for desktop Windows. The only one that I know supports HDP directly is Toshiba (though I've no experience with it). So, instead once can add the HDP support outside of the stack software. However, HDP[1] uses the L2CAP protocol which is lower level that RFCOMM protocol that most apps use, and unfortunately Microsoft's Bluetooth stack does not provide a user-level L2CAP API. I started work on a driver to allow user-mode access to the kernel-level API (provided by MSFT in Vista and later) but never finished it. For the other main stacks BlueSoleil doesn't provide a L2CAP API, but Widcomm does.
[1] http://www.alanjmcf.me.uk/comms/bluetooth/Bluetooth%20Profiles%20and%2032feet.NET.html#_Toc266869895

How to run the embedded application

For example, I just developed an embedded SWT application which require CDC/FP1.0 j2se1.3 (I use the eclipse IDE), but how to test this application to see if it is can really run on embedded environment?
Thanks
Not many phones with a proper CDC stack have actually been produced as far as I know.
There was a port of the reference implementation of at least one CDC profile to UIQ 3.x that can be installed on a Sony-Ericsson P990 (and maybe Sony-Ericsson M600, W960 and Motorola Z8) phone.
Presumably, the Sun Java Toolkit for CDC contains an emulator that can run your application.
If none of that works, I would advise searching for what the companies on the two JSRs (JSR 36: Connected Device Configuration and JSR 46: Foundation Profile) expert groups did with CDC and FP.

Resources