I have tried so may ways to get this to work but it's not and not even getting an error message.
I looked through topics from 2025 and found nothing conclusive.
Has anyone actually been able to connect with the BLE.ConnectToDeviceWithServiceAndName call?
If so, do you need to scan for devices first?
Is the Name parameter the name that the device advertises?
Here are relevant parts of the ESP32 device code:
BLEDevice::init("PropBal");
BLEService* pService = pServer->createService(BLEUUID(SERVICE_UUID), 50);
BLEAdvertising* pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
so the device is definitely advertising both Name and ServiceUUID.
Note that I previously was able to connect (and use blocks with the ServiceUUID parameter) with
The DeviceList contains MAC address, device Name and a negative number.
If you can show me how to make this into a string I can check if ServiceID exists in it:
All I get when putting it into a label text is "" (square brackets). I don't know what "triplets" are and how to make it into a string. I don't have nRF.
EDIT: Installed nRF. All it shows is Name, MAC address and signal level in dBm. So that's what the negative number is.
Will nRF show ServiceID if advertised?
EDIT EDIT: I added.stop():
BLEAdvertising* pAdvertising = BLEDevice::getAdvertising();
pAdvertising->stop();
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->setScanResponse(false);
pAdvertising->setMinPreferred(0x0);
BLEDevice::startAdvertising();
Serial.println("Waiting for client...");
But the only way I see the ServiceID in nRF is if I click CONNECT.
Does that mean that BLE in ESP32 does not in fact support SERVICE_UUID advertising in spite of accepting pAdvertising->addServiceUUID(SERVICE_UUID); ?
This will depend on a lot of things, including what type of UUID you are using. But yes, the advertising packet has a certain length and so there are tradeoffs in terms of the service UUIDs, device info, etc.
Please get this. I'm not talking about .Initialize executing twice. I'm talking about it not executing the second action (AttemptConnect). It executes Call.setBLE_Status but not Call.AttemptConnect. Please see my blocks in post #10.
I use .BackPressed because Call AttemptConnect does NOT execute in .Initialize.
I Googled this and people responding keeps missing the point that any second action in .Initialize does not excute and instead say that of course .Initialize does not execute twice.
Must be a bug in App Inventor that .Initialize can only execute one (the first) action.
EDIT: Yes I could move "call set_BLE_status" down to the AttemptConnect procedure but that does not handle the bug in App Inventor.