Create and send BLE advertisements

Hi,
I am trying to create and send bluetooth advertisements using the StartAdvertising API in the latest BLE extension (version 20200828). However, I don't see any advertisements from my device (Samsung Galaxy Note 5, Android 7.0). The app contains 2 blocks - one to start advertising and one to stop advertising. The start advertising block uses the following values:
inData: "Test"
serviceUuid: "45dfefc1-96d2-43ae-9466-91c5dcd557eb"

Here is a snapshot of the code

Steps taken to debug the issue so far:

  • Confirmed that no errors are generated while running the app.
  • Installed a third party app, nRF Connect to send out custom advertisement and that works. So, the android version and the hardware of the device is capable of sending out custom advertisements.

Can someone suggest what I might be missing?

Thanks

I am trying to do the same thing, but also having no luck and can not find any other examples that use .StartAdvertising

Hi @ewpatton or @TIMAI2 any ideas? or able to point us towards someone who might be able to assist?
would be much appreciated..

Please wait for Evan's reply :owl:

1 Like

Same, the advertisement does not show in my esp32 scan

I'm happy to wait.. just wanted to know if this was being looked at, solved, not on the table etc... this is the last piece of my app puzzle and without the ability to advertise, I am at a dead end.

I don't think that part of the extension has been looked at in quite some time. I can try to make some time to look at it tomorrow but I can't guarantee when we might have a fix available.

1 Like

Here's a test version of the extension that should work with advertisements. Note that the Android BLE subsystem expects 16-bit UUIDs. I've also added some additional error messages that will get reported via the screen's ErrorOccurred event.

2 Likes

Thx Evan. With the test version, I was able start and stop the advertisements. I will test it with more devices. May be we will hear from others too...

Thx. for last version.
I'm still have a problem with AdvertisementData return null all the time :frowning:

Hi Evan. I also am able to advertise now. This lets me achieve what I set out to do. I appreciate you setting sometime aside to look at this. Without hijacking the original post, I noticed you can read Tx power but correct me if I'm wrong, there is currently no way to set the TX power?

1 Like

@Zivo Not that I am an expert, but can you post the relevant blocks.. If you do not use a 16-bit UUID it will not work.


My Slave device (HM-10) is set to 16-bit UUID (AAA0).
Running these blocks, AdvertiserServiceUuids return 128-bit (0000aaa0-0000-1000-8000-00805f9b34fb).
At this example I'm using as it's it, and getting null.
If I'm changing the AdvertisementData serviceUuid to use global variable with just 16-bit, AAA0, I'm getting "Invalid String"

I thought you were talking about creating advertisements on Inventor, not receiving them... (this post was about creating and advertising from your app)

if u can, post your block for the advert. Thanks

image

I'm trying with a lot of numbers with no success. I`m not seeing the adv anywhere and the return from is adv= false.

All help is welcome. :smile:

Here you go.

I don't think "inData" can be text I found.. I could be wrong.

1 Like

After I updated the plug in, it worked for a little bit and the this happened:


Was working fine, then the session ended and puff...

The issue is that with the device name and a 128-bit UUID there isn't much if any room left in the advertising packet for data. You'll have better success if you use a 16-bit UUID. The Android docs also state that the UUID should be a 16-bit UUID.

You probably have both the old and new BLE extensions in your project. They use different names for various functions, and this disabling effect happens due to the collision where the functions are present in one but not the other and a conflict occurs. You'll need to take apart your project file, remove the older extension, and then reload the project in App Inventor.

1 Like