I'm trying to write a simple app to scan and connect to bluetooth devices. Since the latest update, I have noticed that the bluetooth library does not work when installing it from the codename one preferences - it installs and I get no exceptions, but the bluetooth functions don't work. I've tried downloading the latest repo at https://github.com/codenameone/bluetoothle-codenameone and copying the bluetooth lib to my project, but I get the same results for both IOS and Android. I finally solved this by copying an old version of the bluetooth lib (which I installed using the old codename one preferences GUI) to the new project and it works perfectly fine on android.
On IOS however, I can successfully scan for devices, but I'm not able to connect to any device.
try {
bluetooth.connect(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
ToastBar.Status status = ToastBar.getInstance().createStatus();
status.setMessage("Connected");
status.show();
}
}, address);
} catch (IOException ex) {
ToastBar.Status status = ToastBar.getInstance().createStatus();
status.setMessage(ex.getMessage());
status.show();
}
I have the ios.NSBluetoothAlwaysUsageDescription build hint, and bluetooth seems to be working as I am able to scan, but when I try to connect the callback doesn't execute and no exceptions are thrown. I've tried initializing the bluetooth with all different combinations of the "request" and "statusReceiver" parameters but no luck. I've triple checked the addresses I tried connecting to. I've changed the callback method (in case the Toastbar has some issue) but I can see on the device I try to connect to that no connection is made. I've tried this on IOS 12 and 14, but both yield the same result
Firstly, does anyone know how to get the latest CN1 bluetooth lib working? And secondly, is there something I'm missing with IOS on connecting to ble devices? Any ideas to get IOS to connect to my device would be greatly appreciated
Looks like there were some issues with the builds of both the Bluetooth cn1lib and the CN1JSON cn1lib. Therse are now updated and fixed. You will need to update the library via Codename One preferences for this fix to take effect.