iOS Question (solved) BLE - scan(serviceid) - scanning with parameter

machvd

New Member
Licensed User
I am trying to scan BLE device based on the BLE example for b4i.
The only thing I changed is in the btnScan_Click code - first 3 lines of code all the rest is as I downloaded the example.

The device I want to connect to is en ESP32 module that advertises its serviceid

The manager.scan(Null) works flawless. It discovers the device.
However if I try to scan with a parameter it seems not to find anything. I've copied/pasted the serviceid so I'm sure I didn't make a typing error.

Anyone an idea on what I do wrong.

Thanks.

code extract from BLE b4i example:
Sub btnScan_Click
    Dim test(1) As String
    test(0) = "f5...............................0e"
    manager.Scan(test)
    'manager.Scan(Null)
    ActivityIndicator1.Visible = True
End Sub

Arduino code - BLE device ESP32:
  /*
   * BLE setup
   */
  BLEDevice::init("Dispenser");
  BLEServer *pServer = BLEDevice::createServer();
 
  BLEService *pService = pServer->createService(SERVICE_UUID);
 
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  pCharacteristic->setCallbacks(new MyCallbacks());
  pCharacteristic->setValue("Dispenser gereed");

  pService->start();
 
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->start();
 

machvd

New Member
Licensed User
If found the issue. Apparently the serviceUUID was not published. On the Arduino code I added an addServiceUUID and that did the job.

B4X:
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->start();
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…