Skip to content
Snippets Groups Projects
Commit 91943e5c authored by thiebolt's avatar thiebolt
Browse files

update

parent 56d0344a
No related branches found
No related tags found
No related merge requests found
/* /*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
Ported to Arduino ESP32 by pcbreflux Ported to Arduino ESP32 by pcbreflux
*/
/*
Create a BLE server that will send periodic iBeacon frames. Create a BLE server that will send periodic iBeacon frames.
The design of creating the BLE server is: The design of creating the BLE server is:
1. Create a BLE Server 1. Create a BLE Server
...@@ -13,6 +10,8 @@ ...@@ -13,6 +10,8 @@
4. wait 4. wait
5. Stop advertising. 5. Stop advertising.
6. deep sleep 6. deep sleep
TBC: Tx power changed ... check it works !
*/ */
#include "sys/time.h" #include "sys/time.h"
...@@ -51,6 +50,7 @@ void setBeacon() { ...@@ -51,6 +50,7 @@ void setBeacon() {
oBeacon.setProximityUUID(BLEUUID(BEACON_UUID)); oBeacon.setProximityUUID(BLEUUID(BEACON_UUID));
oBeacon.setMajor((bootcount & 0xFFFF0000) >> 16); oBeacon.setMajor((bootcount & 0xFFFF0000) >> 16);
oBeacon.setMinor(bootcount&0xFFFF); oBeacon.setMinor(bootcount&0xFFFF);
// ### TODO: add oBeacon.Txpower ??
BLEAdvertisementData oAdvertisementData = BLEAdvertisementData(); BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
BLEAdvertisementData oScanResponseData = BLEAdvertisementData(); BLEAdvertisementData oScanResponseData = BLEAdvertisementData();
...@@ -87,6 +87,11 @@ void setup() { ...@@ -87,6 +87,11 @@ void setup() {
// Create the BLE Device // Create the BLE Device
BLEDevice::init(""); BLEDevice::init("");
// [sep.22] Increase TX POWER ?
esp_err_t errRc=esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT,ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN ,ESP_PWR_LVL_P9);
// Create the BLE Server // Create the BLE Server
// BLEServer *pServer = BLEDevice::createServer(); // <-- no longer required to instantiate BLEServer, less flash and ram usage // BLEServer *pServer = BLEDevice::createServer(); // <-- no longer required to instantiate BLEServer, less flash and ram usage
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
Ported to Arduino ESP32 by Evandro Copercini Ported to Arduino ESP32 by Evandro Copercini
Changed to a beacon scanner to report iBeacon, EddystoneURL and EddystoneTLM beacons by beegee-tokyo Changed to a beacon scanner to report iBeacon, EddystoneURL and EddystoneTLM beacons by beegee-tokyo
TBC: Tx power changed ... check it works !
*/ */
#include <Arduino.h> #include <Arduino.h>
...@@ -140,6 +143,12 @@ void setup() ...@@ -140,6 +143,12 @@ void setup()
Serial.println("Scanning..."); Serial.println("Scanning...");
BLEDevice::init(""); BLEDevice::init("");
// [sep.22] Increase TX POWER ?
esp_err_t errRc=esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT,ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);
esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN ,ESP_PWR_LVL_P9);
pBLEScan = BLEDevice::getScan(); //create new scan pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment