Jacques Dumarest

unread,
Feb 2, 2018, 9:50:35 AM2/2/18
to MIT App Inventor Forum
 I wanted to provide feedback on https://groups.google.com/forum/#!searchin/mitappinventortest/ble$20notification%7Csort:date/mitappinventortest/5wJzbL2pWVo/0SVdRA9OAQAJ  but it is closed.

 I have enabled "RegisterForStrings", but I do not get notification. My understanding is that I need to enable Notification on my device, and I need to send a command to enable it as decribed in: : https://groups.google.com/forum/#!searchin/mitappinventortest/ble$20notification%7Csort:date/mitappinventortest/mpjmiByWWlE/ZfKU3BuABgAJ or in: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#notification

 WHat is the right way to send this ENable Notification command to the BLE device?

 Thanks

 Jacques

gerrikoio

unread,
Feb 3, 2018, 5:53:47 AM2/3/18
to MIT App Inventor Forum
Not sure what notification you are expecting, but when you "RegisterForStrings" all new data arrives in the "when BluetoothLE1.StringsReceived" event handler. The "enabling" happens automatically within the app. If you want to have some sort of notification outside the app then you need to use an external push notification service. Also worth remembering that AI2 apps cannot run in the background.

Jacques Dumarest

unread,
Feb 5, 2018, 3:02:38 AM2/5/18
to MIT App Inventor Forum
I understand that's I'll receive notification in BluetoothLE1.StringsReceived" event handler, my question is regarding the BLE device, and by default, it does NOT send back notification, and this must be enabled on the BLE device. The command to be sent is described here: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#notification

Is there a way to send this command from AI2?

Thanks


2018-02-05_085232.jpg

gerrikoio

unread,
Feb 5, 2018, 5:33:29 AM2/5/18
to MIT App Inventor Forum
It is my understanding, but I could well be mistaken, is that when you use any of the "RegisterFor..." methods it is using that function to ask the device to notify your app when the characteristic changes on the device.

What is not available within AI2 is the ability to deregister from notifications.

Hope that helps. If not, maybe others can contribute.

Neil Kenyon

unread,
Feb 5, 2018, 2:27:43 PM2/5/18
to MIT App Inventor Forum
You can indeed register to receive updates for Bytes, Floats,Integers, Shorts and Strings and unregister ie stop receiving updates using a single method:

Hope this helps

Neil
Reply all
Reply to author
Forward
0 new messages