enforce pin being used for ble pairing on esp32
This commit is contained in:
@@ -12,13 +12,13 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
|
|||||||
|
|
||||||
// Create the BLE Device
|
// Create the BLE Device
|
||||||
BLEDevice::init(device_name);
|
BLEDevice::init(device_name);
|
||||||
BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT);
|
BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT_MITM);
|
||||||
BLEDevice::setSecurityCallbacks(this);
|
BLEDevice::setSecurityCallbacks(this);
|
||||||
BLEDevice::setMTU(MAX_FRAME_SIZE);
|
BLEDevice::setMTU(MAX_FRAME_SIZE);
|
||||||
|
|
||||||
BLESecurity sec;
|
BLESecurity sec;
|
||||||
sec.setStaticPIN(pin_code);
|
sec.setStaticPIN(pin_code);
|
||||||
sec.setAuthenticationMode(ESP_LE_AUTH_REQ_SC_BOND);
|
sec.setAuthenticationMode(ESP_LE_AUTH_REQ_SC_MITM_BOND);
|
||||||
|
|
||||||
//BLEDevice::setPower(ESP_PWR_LVL_N8);
|
//BLEDevice::setPower(ESP_PWR_LVL_N8);
|
||||||
|
|
||||||
@@ -31,11 +31,11 @@ void SerialBLEInterface::begin(const char* device_name, uint32_t pin_code) {
|
|||||||
|
|
||||||
// Create a BLE Characteristic
|
// Create a BLE Characteristic
|
||||||
pTxCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
|
pTxCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
|
||||||
pTxCharacteristic->setAccessPermissions(ESP_GATT_PERM_READ_ENCRYPTED);
|
pTxCharacteristic->setAccessPermissions(ESP_GATT_PERM_READ_ENC_MITM);
|
||||||
pTxCharacteristic->addDescriptor(new BLE2902());
|
pTxCharacteristic->addDescriptor(new BLE2902());
|
||||||
|
|
||||||
BLECharacteristic * pRxCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX, BLECharacteristic::PROPERTY_WRITE);
|
BLECharacteristic * pRxCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX, BLECharacteristic::PROPERTY_WRITE);
|
||||||
pRxCharacteristic->setAccessPermissions(ESP_GATT_PERM_WRITE_ENCRYPTED);
|
pRxCharacteristic->setAccessPermissions(ESP_GATT_PERM_WRITE_ENC_MITM);
|
||||||
pRxCharacteristic->setCallbacks(this);
|
pRxCharacteristic->setCallbacks(this);
|
||||||
|
|
||||||
pServer->getAdvertising()->addServiceUUID(SERVICE_UUID);
|
pServer->getAdvertising()->addServiceUUID(SERVICE_UUID);
|
||||||
|
|||||||
Reference in New Issue
Block a user