ESP32 - BLE not reachable with IOS but with Android

R1Snake
Posts: 2
Joined: Mon Apr 25, 2022 8:25 pm

ESP32 - BLE not reachable with IOS but with Android

Postby R1Snake » Mon Apr 25, 2022 8:38 pm

In my project i use BLE to send messages from the ESP to my Arduino device.

This works very well, but now i wanted to connect the ESP32 with the Iphone from my girlfriend and i do not see a device.

Is this a known issue or do is something wrong?

Here is my code where i intitialize the BLE Server

Code: Select all

NimBLEDevice::init(ble_device_id);
  /** Optional: set the transmit power, default is 3db */
  NimBLEDevice::setPower(ESP_PWR_LVL_P9);                             /** +9db */
  NimBLEDevice::setPower(ESP_PWR_LVL_P9, ESP_BLE_PWR_TYPE_ADV);       /** +9db */
  NimBLEDevice::setPower(ESP_PWR_LVL_P9, ESP_BLE_PWR_TYPE_CONN_HDL0); /** +9db */
  NimBLEDevice::setPower(ESP_PWR_LVL_P9, ESP_BLE_PWR_TYPE_CONN_HDL1); /** +9db */
  NimBLEDevice::setPower(ESP_PWR_LVL_P9, ESP_BLE_PWR_TYPE_CONN_HDL2); /** +9db */
  
  NimBLEDevice::setMTU(BLE_MTU);
  ble_mtu = NimBLEDevice::getMTU();
  
  log_d("BLE MTU set to: %d", ble_mtu);
  NimBLEDevice::setSecurityIOCap(BLE_HS_IO_NO_INPUT_OUTPUT);
  NimBLEDevice::setSecurityAuth(BLE_SM_PAIR_AUTHREQ_SC);

  // Create BLE Server
  pServer = NimBLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks(this));
  
  NimBLEService *pServiceGPS = pServer->createService(BLE_SERVICE_UUID);
  pCharacteristicGPS = pServiceGPS->createCharacteristic(BLE_CHARACTERISTIC_UUID, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
  pServiceGPS->start();

  NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(pServiceGPS->getUUID());

  NimBLEService *pServiceInfo = pServer->createService(DEVINFO_UUID);
  NimBLECharacteristic *pChar = pServiceInfo->createCharacteristic(DEVINFO_MANUFACTURER_UUID, NIMBLE_PROPERTY::READ);
  pChar->setValue(DEVICE_MANUFACTURER);
  pChar = pServiceInfo->createCharacteristic(DEVINFO_NAME_UUID, NIMBLE_PROPERTY::READ);
  pChar->setValue(DEVICE_NAME);
  pChar = pServiceInfo->createCharacteristic(DEVINFO_FWREV_UUID, NIMBLE_PROPERTY::READ);
  pChar->setValue(VEDEX_VERSION);
  pCharacteristicCommand = pServiceInfo->createCharacteristic(BLE_RECONFIG_CHARACTERISTIC_UUID, NIMBLE_PROPERTY::WRITE_NR);
  pCharacteristicCommand->setCallbacks(new MyCharacteristicCallbacks(this, wifi_Provider));
  pServiceInfo->start();
  pAdvertising->addServiceUUID(pServiceInfo->getUUID());
  
  NimBLEService *pServiceRC = pServer->createService(RCSERVICE_UUID);
  gpsMainCharacteristic = pServiceRC->createCharacteristic(GPSMAINCHARACTERISTIC, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
  gpsTimeCharacteristic = pServiceRC->createCharacteristic(GPSTIMECHARACTERISTIC, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
      
  
  pServiceRC->start();
  pAdvertising->addServiceUUID(pServiceRC->getUUID());
  
  
  pAdvertising->setAppearance(5186);
  pAdvertising->setMinPreferred(0x06);

  pAdvertising->start();
  digitalWrite(BLUELED, HIGH);
  log_i("Waiting a client connection to notify...");

Who is online

Users browsing this forum: axellin and 94 guests