how to turn Bluetooth on/off with J2ME? - java-me

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

Related

Is it possible to command the Nintendo switch's joy cons with a PC?

I want to create a TAS that can play the Nintendo Switch games that are only compatible with the joy cons.
There are turbo pro controllers in the market but there is no turbo joy cons, so my next idea is one of two:
To use the Bluetooth to connect a devise that I could control with my PC and can be connected to the Nintendo switch via Bluetooth (or USB) and trick it into thinking that it is a joy con and not a pro controller.
Use the idea above but the devise is the joy con itself, in this case, I would have to connect the joy cont to the PC and command it while it is still paired with the Nintendo Switch
Is there any way to achieve what i'm looking for? Thanks in advise.
Also, if there is a better branch in stack-overflow to post this question I will move it.
Looks like it's already been done, and you'll need a product called vJoy.
https://www.pcgamesn.com/nintendo/nintendo-switch-joy-con-pc-guide
Looks like you'd need to reverse engineer the communication protocol used by those controllers and then emulate that protocol with software. Here is a resource I have found regarding RE bluetooth. Another one I have found here. Redfang may help you in that endeavor, it is software that helps you find bluetooth addresses of devices that you you can't discover normally.
Another idea I would have is to open your controller and solder on some wires to a micro controller, such as an Arduino, Raspberry or something similar to the buttons and analogue controllers and 'input' the commands that way.
Unfortunately I can not offer you any more advice. I hope this helps in some way.
One possible way is to use JoyCon Droid app in Android to controll the Nintendo Switch. If this app can work, it should be possible to make one as PC software too.
Luckily, there are a few easy ways to control Android from PC such as using AirDroid which allows you to touch the Android screen from PC. You can refer to How to remote control Android device from a computer with AirDroid?. It can both mirror the screen and give you the touchscreen control, which you can utilize it to control the JoyCon Droid app.
I've just found another way which is to use a microcontroller as a USB controller here.

Is there a way to connect to iBeacon while my Bluetooth device is invisible?

I'm researching iBeacons. Can I connect to iBeacons while my Bluetooth is invisible (to be protected from hacks)?
I don't have beacons to test myself and can't find any clear explanation online.
iBeacons connect to mobile phones using Bluetooth, so it is essential to have that turned on. You also need to have installed an app with iBeacon support in order to receive communication from them.
If you'd wish to use a solution that does not utilize Bluetooth, you could try out IndoorAtlas. It's an indoor navigation technology based on Earth's geomagnetic fields. It's also completely hardware-free solution, just requires you to collect fingerprints in the area you are going to use for your project.
Three points:
iBeacon technology does not rely on a bluetooth connection to your phone. Beacons are one way transmitters. They do not listen to or otherwise receive any info from your device. Beacon technology following this model is inherently privacy friendly.
Mobile devices cannot detect Bluetooth beacons with the Bluetooth radio turned off. Sorry, it is just not possible.
Properly built beacon apps will not expose your mobile device's Bluetooth info because they are receive only. Of course, other apps on your phone might use bluetooth for other purposes, so your best bet is to audit apps using bluetooth and remove any that are not doing what you want.
I just bought some beacons and tested that, The answer is YES. it is possible to read beacons mac addresses while using the phone's Bluetooth connection as invisible. Using this you will get access to your beacon in any open place without getting hacked through Bluetooth.
Thanks all for your answers.

Bluetooth A2DP SINK in Windows 8.1

I know Microsoft doesn't allow the streaming of music from phones to Windows 8 PC's or the use of the PC as hands free, but has anyone found a way around this yet?
Are there any modified drivers or ways to modify the current drivers?
Any help would be appreciated.
www.bluesoleil.com offer a custom bluetooth driver that will make your pc show up as a Bluetooth headset to other devices. It will also allow you to choose which audio device the audio is repeated repeat to.
Product is not free but is the only solution is managed to find after half an afternoon looking. Works great as well.

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.

Midlet wake up from bluetooth connection

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.

Resources