chen-fishbein / bluetoothle-codenameone Goto Github PK
View Code? Open in Web Editor NEWbluetoothle library for codenameone
bluetoothle library for codenameone
Whenever I try to connect I get the error "Device previously connected, reconnect or close for new device". But there is no way to disconnect properly, and no way to find the address to actually disconnect from. And, I was never connected in the first place.
enable() doesnt actually do anything, only way to turn on bluetooth is intialise, this however then reloads the current form and hangs the app. Therefore the library will only work if bluetooth is already on before you load the app. I cannot get around this.
Since the UIWebView was deprecated and now forbidden, and the Cordova pod used by this app is based on UIWebView, any iOS apps using this extension will be rejected. It looks like Cordova has recently committed some updates to shift to WKWebView.
I think that I can add the Cordova callback implementation for the peripheral commands in Bluetooth.java. I would also like to add a soft fail for commands that are unsupported on a particular platform; that is examine the result code, return true on success, return false on failure making the error response available for inspection, and throw an exception where required. Mr. Almog suggested that I file and issue and open a pull request. I new at this and I would like to contribute these suggested changes.
Best regards,
Jeff Crump
Hi,
there are some methods in the plugin thar are not available in the cn1lib. For example startAdvertising or stopAdvertising.
Greetings
Maik
On multiple apps in development, after some builds, build errors (iOS)or app crashes (Android) begin. Initially, the apps were building and working OK, then after changing something not related to Bluetooth or JSON, builds begin failing. In the most recent case, the only item changed between a successful build and a failing build was changing the text on a UI label. Here is the iOS build error below, and the JSON extension has been installed since the beginning. The exception thrown on the screen when Android crashes is similar.
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:168:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[4].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:168:23: note: did you mean 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_HashMap'?
In file included from /var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:3:
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/ca_weblite_codename1_json_JSONObject.h:20:11: note: 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_HashMap' declared here
JAVA_VOID ca_weblite_codename1_json_JSONObject___INIT_____java_util_HashMap(CODENAME_ONE_THREAD_STATE, JAVA_OBJECT __cn1ThisObject, JAVA_OBJECT __cn1Arg1);
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:311:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[8].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:393:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[3].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:436:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[2].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:474:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[2].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:514:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[3].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:582:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[5].data.o); SP -= 1;
^
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build4705131409324966325xxx/dist/Obd2Relay-src/com_codename1_bluetoothle_Bluetooth.m:647:23: error: implicit declaration of function 'ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
/* CustomInvoke */ca_weblite_codename1_json_JSONObject___INIT_____java_util_Map(threadStateData, SP[-1].data.o, locals[7].data.o); SP -= 1;
^
8 errors generated.
The callback for connect() is never called.
No call back from enable(). This means if bluetooth is not on and gets enabled, the app wont proceed and needs to be restarted, a call back would fix this nicely.
Error compiling in the build server when add the Cn1Bluetooth.cn1lib
Device (Android) and emulator always gives this error when initialize or start scan is pressed.
java.lang.NoSuchMethodError: ca.weblite.codename1.json.JSONObject.(Ljava/util/Map;)V
[EDT] 0:0:23,97 - Exception: java.lang.NoSuchMethodError - ca.weblite.codename1.json.JSONObject.(Ljava/util/Map;)V
at com.codename1.bluetoothle.Bluetooth.initialize(Bluetooth.java:64)
at com.codename1.btle.BTDemo$2.actionPerformed(BTDemo.java:82)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349)
at com.codename1.ui.Button.fireActionEvent(Button.java:563)
at com.codename1.ui.Button.released(Button.java:605)
at com.codename1.ui.Button.pointerReleased(Button.java:709)
at com.codename1.ui.Form.pointerReleased(Form.java:3528)
at com.codename1.ui.Component.pointerReleased(Component.java:4629)
at com.codename1.ui.Display.handleEvent(Display.java:2249)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1212)
at com.codename1.ui.Display.mainEDTLoop(Display.java:1130)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
Bluetooth wont initialise, samsung s7, android 8.
W/System.err: java.io.IOException: Bluetooth not initialized
W/System.err: at com.codename1.cordova.Cordova.execute(Cordova.java:33)
W/System.err: at com.codename1.bluetoothle.Bluetooth.enable(Bluetooth.java:83)
W/System.err: at userclasses.MainForm.startBluetooth(MainForm.java:67)
W/System.err: at userclasses.StateMachine.onMain_BtScanAction(StateMachine.java:71)
W/System.err: at generated.StateMachineBase.handleComponentAction(StateMachineBase.java:250)
W/System.err: at com.codename1.ui.util.UIBuilder$FormListener.actionPerformed(UIBuilder.java:2835)
W/System.err: at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349)
W/System.err: at com.codename1.ui.Button.fireActionEvent(Button.java:571)
W/System.err: at com.codename1.ui.Button.released(Button.java:605)
W/System.err: at com.codename1.ui.Button.pointerReleased(Button.java:709)
W/System.err: at com.codename1.ui.Form.pointerReleased(Form.java:3528)
W/System.err: at com.codename1.ui.Component.pointerReleased(Component.java:4629)
W/System.err: at com.codename1.ui.Display.handleEvent(Display.java:2249)
W/System.err: at com.codename1.ui.Display.edtLoopImpl(Display.java:1212)
W/System.err: at com.codename1.ui.Display.mainEDTLoop(Display.java:1130)
W/System.err: at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
W/System.err: at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
W/System.err: at java.lang.Thread.run(Thread.java:764)
D/HobMonitor_V1: [EDT] 0:21:45,924 - MainForm##### IOException Bluetooth not initialized
Getting this error with the bluetooth lib on Android (samsung s7 - Android 8.0)
W/System.err: java.io.IOException: Bluetooth not initialized
W/System.err: at com.codename1.cordova.Cordova.execute(Cordova.java:33)
W/System.err: at com.codename1.bluetoothle.Bluetooth.enable(Bluetooth.java:85)
W/System.err: at userclasses.MainForm.startBluetooth(MainForm.java:55)
W/System.err: at com.pippa.hobmonitor.MyApplication.start(MyApplication.java:41)
W/System.err: at com.pippa.hobmonitor.MyApplicationStub.run(MyApplicationStub.java:163)
W/System.err: at com.pippa.hobmonitor.MyApplicationStub$1.run(MyApplicationStub.java:107)
W/System.err: at com.codename1.ui.Display.processSerialCalls(Display.java:1298)
W/System.err: at com.codename1.ui.Display.mainEDTLoop(Display.java:1093)
W/System.err: at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
W/System.err: at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
W/System.err: at java.lang.Thread.run(Thread.java:764)
I am currently running Android 11 and using this plugin. I can send text data correctly, but cannot receive any text data from a BLE RX/TX device. I am able to correctly "subscribe" to service, but it does seem the callback method is called when text data is sent from the device to the phone. Using another application I am able to both send and receive text data no problem to that service so not a hardware problem. I think it may be an issue with the Cordava plugin somewhere.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.