BLE WriteStrings not sending. Able to receive device UUID information

I have set up a simple application to test sending some commands to a device we have developed. I am able to read the device information(UUID's). I am also able to ReadStrings from the device buffer(message sent from last send command when sending commands through nRF) with the Service and Char UUID's. It appears that the issue is in the WriteStrings command for BLE. I am able to send the strings via nRF and the device is able to receive with no problem. I have the 20200828 BLE extension. I have spent a lot of time debugging on the device and application. I am starting to lose it. As you can see in the code I am writing the strings upon connection to the device as well as the ability to write on the command button. S3Renew (2).aia (334.2 KB)

You are also receiving them at the same time, which is likely the cause of the issue.

Instead, try this:

Snap5

By registering for Strings, the App will receive them whenever they arrive. If you trigger a Clock Timer from the same Block (Connected) you can allow a reasonable length of time to pass before a string is sent out to the device.

With that in place, your Button "Command" should then work.

So I've tried your recommendation and I still am not able to get device to receive anything from the application. I can connect with nRF and there is no issues with communication back and forth. I am uploading a screenshot to this for clarification. When I send through the App Inventor app nothing is received. Is this possibly something to do with the handling of the bluetooth packet within the application itself? I have running in circles still. Any help would be appreciated. S3Renew (3).aia (334.5 KB)

What exactly isn't working? ReadString or WriteString?

Hi Noah

  1. What is the actual device you are communicating with? I ask because the text sent by the command button is:
    a) Probably too long (unless the device has an extended MTU)
    b) Highly unusual - you would normally send a code that the device would interpret, for example, you send '1' and the device "knows" this means {"action":"start","zones":[1,0,0,0,0,0,0,0,0],"duration":100} https://www.professorcad.co.uk/appinventortips#TipsBluetooth

  2. Your Service UUID and Characteristic UUID bare no resemblance to each other which is unusual. They would normally be similar...however, from your notes, they work.

  3. The Clock Timer is enabled but not instructed to do anything.

  4. Best not to have a variable named "String", it can be used in the underlying language. Also, you have initialised it as a List, but do not split the incoming data into a List. It might be in the form of a list but the code does not know that.

By the way, when naming components, do not remove their type!
https://www.professorcad.co.uk/appinventortips#TipsGui

Is the Screen "checkinguuid" just an experiment?

S3Renew_Edit1.aia (335 KB)

This is a generic Template Project that others have used (butchered!) for their own App, typically communicating with a microcontroller such as Arduino.

BLE_SEND_RECEIVE.aia (197.1 KB)

Encoding type, once utf8, once utf16 is not a problem here?

Thank you all for getting back to me. I am connecting to a BGM113 Bluegecko bluetooth module on a custom board. The code was originally set up to take in a hex string but that was changed later to take it as a json style string. It was no problem for the other applications to send it will no issue. I was able to get the device to receive the string finally with WriteStringswithResponse command. Although it is sending in two seperate blocks. The interupt on the device only looks at the first block which is half of the command and it errors out. I know this may seem like a dumb question but is there any way to send longs through ble. It appears that I am only able to send 16 chars at a time? I have reduced the sizze of what i am sending to simple letters to reduce but I need a little more to specify zone in an array image

Can you change the MTU size? If so, you can send much larger data packets (std is 32 bytes, max for BLE v5 is 247 bytes).

The MTU of the device is set to 35 (32 bytes allowed for transmission). It appears the app itself is only capable of sending 16 bytes at a time in one string message. I have attached a screen shot of what is being received by the app onto the device and also the string that I was trying to write to the device from the app. You can see that the end is being cut off in the transmission. I have no problem when sending the full packet through nRF.

image

You can change the MTU for the APP (with the MTU Block).