Midlet wake up from bluetooth connection - java-me

I'm trying to register a midlet for push registration, in order to wake up from a bluetooth connection.
The requested behavior is that the application will wake up when a car's kit (hands free) will be in the range of the device.
Is it possible at all?
If yes, how should it be done?
Thanks in advance,

I can confirm that it is possible to wakeup a MIDlet in Nokia Devices trough a registered service in the push-registry.
The registration can be defined in the JAD (static registration) or dynamically in the code.
Nokia phones S60 3ed and up and S40 3ed should support this functionality, on other phones (sony,samsung,motorola etc..) I didn't find this feature working.
Google this JAD attribute: MIDlet-Push-1
Good luck!

I don't think it's possible to start up a midlet when it comes into range of a device, even with Bluetooth push registry compatibility (were you to find a handset supporting it).
Your best bet might be to have a midlet running in the background, constantly checking which devices are in the vicinity. When it discovers your hands-free kit, you could bring it to the foreground (if the handset supports it; this is usually achieved by Display.setCurrent(null) for background, and Display.setCurrent(<Displayable instance>) for foreground).
JSR 82 provides the functionality you need.
Beware though, this constant Bluetooth polling will drain the device's battery!

This is advanced stuff. Nice.
While this can be available on mobile phones according to the JSR-118 and JSR-82 specifications, I suspect not many handset manufacturers have actually implemented it.
Symbian provided a TCK-compliant reference implementation for Java BlueTooth Push to its licensees but testing it is a nightmare and I don't know whether either Nokia, Motorola or Sony-Ericsson actually included the functionality in a phone.
My best guess of Symbian phones to try this on: Nokia N95, Sony-Ericsson P990 or W960, Motorola Z8. I would also advise trying on as recent a Bluetooth-enabled non Symbian Sony-Ericsson phone as you can find.
If you find a handset specification that actually says it supports J2ME BT Push, you then need to check whether that is supposed to work using RFComm, L2CAP or both. I don't know what your car kit uses.
As far as writing Java code to use Bt push, you can start by reading the example code in the 2 JSRs and the J2ME SDK from Sun Ltd.

Related

BLE on Android as Peripheral

I am developing an app that controls a product's operation. The communication is via BLE. My configuration is
App - Peripheral (iOS, Android)
Product - Central (uses Laird BT900 module)
iOS as a peripheral works fine (pairing and bonding) ; Android PIN pairing works fine, but subsequent bonding (or reconnect when in range) there are a lot of issues and termination of connection. I am using the supported list of devices for Android BLE and I also understand that there are many known issues that come with different manufacturers/chipset vendors
The issue I am getting is, as seen by nrfConnect, is with descriptors. Android app doesnt show descriptors when seen in nrfConnect whereas iOS shows. I do not know what is the difference
Is it a common practice to use a phone as a peripheral ? Or is it a risk - because this is a medical device.
Are there any best practices for Android as a peripheral ?
I have following back up plans in case Android issue is not resolved. I think following would work on any BLE supported phones without having any issues with the variability.
Plan A : PIN pairing on every connection with the product. This is the most secure and most annoying
Plan B : Implement just works pairing with a app layer password before taking control of the product.
Question : Is just works safe and encrypted ? Is it snoop-safe or MITM-safe ?
Thanks in advance!
A few thoughts from your questions:
1a. (From my Android experience) I think its uncommon to have the phone be the peripheral. To my knowledge all iOS devices support peripheral mode but only a very small subset of Android devices are able to support it. I say this because I've been experimenting with BTLE beacons using the AltBeacon library. From this work I have discovered that only certain Android phones can broadcast BTLE advertise packets. Given that BTLE advertising is the first step in initiating a BTLE session I imagine that this prevents many Android phones from being compatible with peripheral mode.
If all of your users can use an iOS device, then you're set, otherwise this may be a problem.
1b) I can't speak to the specific risk of using a mobile device with your medical device, that depends on what the medical device is doing and how you're using the mobile app.
2) See 1a
3) The specific encryption scheme you used is also based on your product's risk profile. I would say that Just Works is not an ideal solution. The just works pairing process is not snoop-safe and can be re-initiated via a MITM. Other than that I can't speak to the strength of BTLE encryption.

How do I change a Java ME device System time?

I'm developing an application that needs to synchronize the time on a server with the time on the device.
Blackberry devices have the net.rim.device.api.system.Device.setDateTime(long dateTimeMillis) method for this. I'm looking for something similar in Java ME devices.
I can live with manufacturer specific APIs - specialy nokia, sony ericsson and motorola ones, and most JSRs.
Does anyone know if there is any way to do this?
Most manufacturers, such as Nokia, don't have that functionality in Java. You may need to take a look into Symbian C++ and other platform specific development tools.
You can't do with Java-me for some security reasons. So you can't change the internal time of system. You can possible to get the current time only.

how to turn Bluetooth on/off with J2ME?

I want to write a program in J2ME to turn the Bluetooth on/off automaticly in a certain time without the user permission.
I'v been looking for a while but I couldn't find an answer.
Some phones will automatically switch bluetooth ON when a MIDlet starts using the Java ME Bluetooth API.
Other phones will not.
AFAIK, there is no Java ME API to switch bluetooth ON/OFF.
I have yet to find a mobile phone that automatically switches bluetooth OFF after some time of inactivity.
Any way you find to do this (I'm sure it's doable in Symbian OS C++, for example) will be platform-dependant.
There is definitely no way to programmatically switch your Bluetooth on and off in Java ME. However what may be useful is to switch between discoverable modes:
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
to be discoverable, and
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.NOT_DISCOVERABLE);
to hide from other devices. It doesn't save battery, but it does make things that little bit more secure I guess.
No way. We cannot be able to automatically turn on/off bluetooth in java & j2me. Better you refer to the documentation of JSR 82

Bluetooth support on Android Emulator

I want to know if the developer team which made the emulator have some information to make bluetooth work in the Android emulator, indicate some links about it, if they have some date for release or if they'll make it works in the future.
as far as I know there is no support in the emulator for bluetooth. And I will have to teach android and bluetooth in some classes. And the students will need to code stuff and test (guess it) in the android emulator.
So I came up with a bare-bone reimplementation of the android bluetooth API on top of tcp. You can find it on here on github.
Basically, you run a tcp-server on your machine, and the emulators will connect through it.
Instead of using the classes in the package android.bluetooth, you just need to use the classes in the package dk.itu.android.bluetooth (and other 2 little modifies).
As for now it supports:
switch on/off the "radio"
discovery devices (only other android emulators)
creating bluetooth services
connecting to bluetooth services
It's not much, but until we got some more from the android guys, I guess there is nothing else around.
Hope it'll be useful, cheers!
The documented bluetooth limitation appears inconsistent with the qemu -bt option. So, how is bluetooth enabled in the emulator so the -bt options can be used, or at least to know that bluetooth is supported?
The target/board/.../BoardConfig.mk having "BOARD_HAVE_BLUETOOTH := true" doesn't provide a bluetooth icon or enable bluetooth. So, how do we turn on bluetooth on the android qemu emulator?
What does it mean that bluetooth is not supported given the -bt option for emulating USB devices that were provided in 2008? The post and limitations are outdated.
The functional limitations of the emulator include:
No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however.
No support for USB connections
No support for device-attached headphones
No support for determining network connected state
No support for determining battery charge level and AC charging state
No support for determining SD card insert/eject
No support for Bluetooth
http://developer.android.com/tools/devices/emulator.html#limitations

mobile receipt printing with J2ME via Bluetooth

I need to make an app in J2ME that can be able to read a SMS and then print it on an epson tm-p60 printer(ESC/POS emulation) via bluetooth.
i looked at the epson supprt site but the only ADK/drivers they provide are for:
1.Sun Java2 SDK Standard Edition Version 1.4.2_10
2.Sun Java2 SDK Standard Edition Version 1.4.2_04
3.Sun Java SE Development Kit 6 Update 3
so i don't know how am i gonna be able to use ESC/POS commands inJ2ME.
I'm a bit clueless on how i will approach this project.. plus w/c would be better to use for this project? Netbeans or Eclipse?
Thanks!
SPP (Serial Port Profile) over Bluetooth means using an RFCOMM connection to send and receive data as if it were a physical serial connection. This is part of JSR 82, so you will be able to develop only on handsets that support this JSR.
You need to:
Figure out how to discover bluetooth devices, and scan for SPP services on a discovered device, then connect to one of those services, using one of the many JSR 82 tutorials out there.
Then send ESC/POS protocol data over that connection -- I assume you have the protocol specification available? Google turned up this application programming guide.
HTH.
JSR-82 Bluetooth API support L2CAP protocol, RFCOMM and OBEX profile. I don't know detail of Bluetooth basic printing profile (BPP) but, if you look into basic printing profile document you can find that BPP built on OBEX profile.
I can't find open source project for BPP on JSR-82. Please try to search it, but if you can't find one you might need to write your own.

Resources