I am unable to read integer value on my app at all. I am using RegisterforIntegers and then using block whenIntegersReceived and I am printing random text inside a text box to see if I am receiving anything. But it seems like nothing is received as integer.
Whereas in the same app I am also using RegisterforFloats and whenFloatRecieved and this is working perfect I can receive all the float number every time.
I have tried bytes, uint32, uint16, uint8, int, signed, unsigned and bytes but nothing is working for whenIntegersReceived.
Can somebody help me what I am missing or doing wrong in reading an integer?
I have checked in nrf connect app and I can see the data coming from my board but in app inventor it shows nothing is received in the whenIntegersReceived.
Note that RegisterForIntegers is expecting 32-bit integers. If you're changing to int16 or int8, you'll need to use RegisterForShorts or RegisterForBytes, respectively. Furthermore, because RegisterForIntegers is expecting 32-bit ints, you need to send 4 bytes at a time. If you only send 1 byte (because your value is 5, for example), then it will be waiting for 3 more bytes before continuing.
If you have example code from the peripheral device showing how you're sending the data that might be helpful to the folks on this forum who can help you debug what's going on.
Thank you for reply. I get indication on my peripheral side that show the notification for Integer is enabled.
I am using nrf to send the Integer using notification as bt_gatt_notify_uuid(NULL, &time_char_uuid.uuid, NULL, time_value, sizeof(time_value));
Where time_value = 4111111111 is declared as uint32_t time_value.
One thing would be to double-check that the service UUID and the characteristic UUID are correct. Otherwise, you'll end up registering for integers on a service/characteristic that doesn't exist.
UUIDs are correct because I change the same blocks to float and also on the peripheral side and it worked perfectly. It only stop working at when I use Integer.
I have tried RegisterForBytes and RegisterForShorts but it do not register notifications on peripheral side. It only register notifcations on peripheral side if I use RegisterForIntegers but then the IntegersRecived never get executed.
But if I use nrf connect for mobile app it shows that integers are received from peripheral side.
A soon as the connection is made, i try to read the values of all my cractristics.
I used Labels to check if the blocks are used, unfortunately only the block dealing with bytes is triggered.
The arduino board send some booleans, the app can't received them in this form. I understood that they are cas into a byte.
i was trying to test their value; 1 = True
By the way i tried to find some answers into the doc at MIT App Inventor + Internet of Things, but i find it quite incomplete. Do you have a better source?
The IntegersRecived block is still not triggered.
When i read the doc, for every Ble.somethingRecived, there is a list of data waiting to be proced.
In a block i specified witch Bytes, integers... i want to get with the UUids (service & Carac), but what's inside this list?
Since you are still in the first stages of trying to receive data, you need good input stream logging.
In the Designer, add a Debugging Vertical Arrangement with these Labels:
ReceivedServiceUUID
ReceivedCharacteristicUUID
ReceivedByteValues
ReceivedIntValues
At the top of each of your When ... Received events,
fill those Labels from the incoming event variables,
without any attempt to filter them.
When all mysteries are solved, set the Arrangement invisible.