Reading Integers over BLE not working

Hi,

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?

Thank you

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.

1 Like

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.

Hi @ewpatton

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.

App blocks are as follows:

But it seems like the block IntegersRecived never get executed.

1 Like

Hi @ewpatton

Any suggestions?

Maybe try

This will confirm data size etc. as should receive a byte array.

Alternatively just try a manual read Integer and see if it responds with a 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.

1 Like

Hi, It seems i have the same program, any progress?

Post everything here.


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.

Every one of the circled if/then tests is wrong.

They all need those green '=' blocks, to compare against something to return a true/false value for the if/then test.

But you actually used a green '=' block in your service UUID test.

You're allowed to pull out more of them.


I think i followed your advice but it seems that the application behaviour hasn't changed.
Did i made another fault?

Okay, I glossed over another problem with your input testing.

byteValues is a LIST, and can not be directly compared against 0.

I don't know what you are fishing for in that data stream, so I will assume you just want to test the first item in that list against 0.

if 0 = (select item 1 from byteValues) then ....

30c4d5e151e9b1734e0c2488c3f401f6868a8ee4_2_690x322

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?

if 0 < (select item 1 of list byteValues) then
....
else
....

More BLE stuff:

image
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?

To différenciate witch is witch, i thought i could do some test at the beginning, but it seems that its not the right way to solve this problem.

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.

You can do this later, when you know you are fishing in the right stream.