I have a device based on the Cypress PSoC 4 BLE Pioneer Kit, which has been a trial-by-fire crash-course in learning about the BLE stack. One thing I learned about is BLE event callbacks, meaning if something changes in the status of the BLE connection, e.g. disconnects, write requests and so on, the stack calls a custom routine in the firmware with a code indicating what the event was. Then you can code the callback function to do things like start advertising again immediately after a disconnect, for example.
I was wondering if there is anything like this on the client/central/app side in the Evothings world. I sometimes find that my device and its app just seem to loose contact. I can always push the reset button on the device, but sometimes it seems I need to reset the app as well. Right now I do that by going back to the Evothings client start page and reloading the app, but it would be nice if I could handle that with something like a callback.
If it isn't easy for me to get a callback working in relatively short order, is there an easy way to include a RESET button right in the app?
Thanks,
Don
BLE Events Callback? Or Reset Button in App?
Re: BLE Events Callback? Or Reset Button in App?
If you check the cordova-ble documentation you'll see the values of the "state" parameter of the ble.connect() callback. Normally the underlying system tries to automatically reconnect if it loses connection, but if that doesn't work, you can monitor the connection state and reconnect manually instead.
As for a reset button, you can always press the RUN button on the Evothings Workbench on your PC.
Or, if you prefer to do it from the phone, call window.location.reload() in Javascript.
As for a reset button, you can always press the RUN button on the Evothings Workbench on your PC.
Or, if you prefer to do it from the phone, call window.location.reload() in Javascript.
Re: BLE Events Callback? Or Reset Button in App?
Thank you. I've now got some reference material to help develop better long-term solutions as well as a quick fix for my immediate problem.
I was thinking of having a button to re-run app.startScan() function from app.js, but I wasn't sure that would clean out all remnants of any prior connections. We are hosting this app online for a client and connecting through a URL in the Evothings Client app, so pressing RUN in the Workbench isn't an option. I had been backing out of the app to the Client start page and connecting to the app again to reset it. Having a button in the app to call window.location.reload() seems like a cleaner solution.
I was thinking of having a button to re-run app.startScan() function from app.js, but I wasn't sure that would clean out all remnants of any prior connections. We are hosting this app online for a client and connecting through a URL in the Evothings Client app, so pressing RUN in the Workbench isn't an option. I had been backing out of the app to the Client start page and connecting to the app again to reset it. Having a button in the app to call window.location.reload() seems like a cleaner solution.
Re: BLE Events Callback? Or Reset Button in App?
startScan() has nothing to do with connections. To close an existing connection, call evothings.ble.close();
Return to “Questions and answers”
Who is online
Users browsing this forum: No registered users and 49 guests