BLE Transmissions slowing down

Got the same kind of problem. I've been developping a "GamePad controller" for the past few days to send value to Arduino R4 WiFI through BLE.
I made a few simple test with only one value sent and it worked pretty good, I could send this value every 100ms without any latency summing up.
So, i kept on developping the graphical interface with joysticks etc
Once I've put everything together, some latency started to sum up and the answer on the Arduino Serial Plotter is longer than 5sec, even when I send my data every 500ms.

So my question is the following : is 500ms a too short period for sending 4bytes of data over BLE ? Was there any recent changes in the MIT App Inventor framework that made the BLE be slower ? (because everything was working well up to the 15 January)

I join you a screenshot of my callback as well as the whole aia file.


Arduino_GAMEPAD_v2.aia (324.3 KB)

Thanks a lot

According to the BLE extension docs for your transmission block

  • WriteBytesWithResponse – Writes one or more 8-bit integer values to a connected BluetoothLE device and waits for an acknowledgement via the BytesWritten event. Service Unique ID and Characteristic Unique ID are required. The values parameter can either be a single numeric value or a list of values. If signed is true, the acceptable values are between -128 and 127. If signed is false, the acceptable values are between 0 and 255.Parameters:
    • serviceUuid (text) — The unique identifier of the service passed in the read or register call.
    • characteristicUuid (text) — The unique identifier of the characteristic in the read or register call.
    • signed (boolean) Interpret the bytes as signed (true) or unsigned (false).
    • values (list) — A list of values to write to the device.

call BluetoothLE1 WriteBytesWithResponseserviceUuidcharacteristicUuidsignedvalues

You should have a BLE event block to tell you that your WriteBytesWithResponse bytes have arrived okay.

You don't have such an event, but you are machine gunning your BLE Writes in a Clock Timer.

Why ask for a response without looking for the response and using it to ratchet your transmissions?

BTW, your list of values response formatting is crude. The Join With Separator ',' block is more direct and cleaner than picking JSON egg shells ["] out of your teeth.

Thank you very much for this quick answer !

This is actually my first experience with MIT App Inventor so most of what I did is kind of "trial and error", rather than the fruit of a long analysis and reflexion. I don't even know where to find most of the documentation : ).

I will change the "writeBytesWithResponse" to a "writeByte" and make the corresponding changes on the server side, as well as changing the clock logic by an event logic.

Hope this will allow to reach an acceptable latency !

Thanks again

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.