ESP32  1.0.4
BLEDevice クラス

#include <BLEDevice.h>

静的公開メンバ関数

static BLEClientcreateClient ()
 Create a new instance of a client. [詳解]
 
static BLEServercreateServer ()
 Create a new instance of a server. [詳解]
 
static BLEAddress getAddress ()
 Get the BLE device address. [詳解]
 
static BLEScangetScan ()
 Retrieve the Scan object that we use for scanning. [詳解]
 
static std::string getValue (BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID)
 Get the value of a characteristic of a service on a remote device. [詳解]
 
static void init (std::string deviceName)
 Initialize the BLE environment. [詳解]
 
static void setPower (esp_power_level_t powerLevel)
 Set the transmission power. The power level can be one of: [詳解]
 
static void setValue (BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value)
 Set the value of a characteristic of a service on a remote device. [詳解]
 
static std::string toString ()
 Return a string representation of the nature of this device. [詳解]
 
static void whiteListAdd (BLEAddress address)
 Add an entry to the BLE white list. [詳解]
 
static void whiteListRemove (BLEAddress address)
 Remove an entry from the BLE white list. [詳解]
 
static void setEncryptionLevel (esp_ble_sec_act_t level)
 
static void setSecurityCallbacks (BLESecurityCallbacks *pCallbacks)
 
static esp_err_t setMTU (uint16_t mtu)
 
static uint16_t getMTU ()
 
static bool getInitialized ()
 
static BLEAdvertisinggetAdvertising ()
 
static void startAdvertising ()
 
static std::map< uint16_t, conn_status_tgetPeerDevices (bool client)
 
static void addPeerDevice (void *peer, bool is_client, uint16_t conn_id)
 
static void updatePeerDevice (void *peer, bool _client, uint16_t conn_id)
 
static void removePeerDevice (uint16_t conn_id, bool client)
 
static BLEClientgetClientByGattIf (uint16_t conn_id)
 
static void setCustomGapHandler (gap_event_handler handler)
 
static void setCustomGattcHandler (gattc_event_handler handler)
 
static void setCustomGattsHandler (gatts_event_handler handler)
 
static void deinit (bool release_memory=false)
 de-Initialize the BLE environment. [詳解]
 

静的公開変数類

static uint16_t m_appId = 0
 
static uint16_t m_localMTU = 23
 
static esp_ble_sec_act_t m_securityLevel = (esp_ble_sec_act_t)0
 
static gap_event_handler m_customGapHandler = nullptr
 
static gattc_event_handler m_customGattcHandler = nullptr
 
static gatts_event_handler m_customGattsHandler = nullptr
 

詳解

BLEDevice.h31 行目に定義があります。

関数詳解

◆ addPeerDevice()

void BLEDevice::addPeerDevice ( void *  peer,
bool  is_client,
uint16_t  conn_id 
)
static

BLEDevice.cpp592 行目に定義があります。

592  {
593  log_i("add conn_id: %d, GATT role: %s", conn_id, _client? "client":"server");
595  .peer_device = peer,
596  .connected = true,
597  .mtu = 23
598  };
599 
600  m_connectedClientsMap.insert(std::pair<uint16_t, conn_status_t>(conn_id, status));
601 }
#define log_i(format,...)
def status(msg)

◆ createClient()

BLEClient * BLEDevice::createClient ( )
static

Create a new instance of a client.

戻り値
A new instance of the client.

BLEDevice.cpp59 行目に定義があります。

59  {
60  log_v(">> createClient");
61 #ifndef CONFIG_GATTC_ENABLE // Check that BLE GATTC is enabled in make menuconfig
62  log_e("BLE GATTC is not enabled - CONFIG_GATTC_ENABLE not defined");
63  abort();
64 #endif // CONFIG_GATTC_ENABLE
65  m_pClient = new BLEClient();
66  log_v("<< createClient");
67  return m_pClient;
68 } // createClient
#define log_e(format,...)
A model of a BLE client.
Definition: BLEClient.h:31
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ createServer()

BLEServer * BLEDevice::createServer ( )
static

Create a new instance of a server.

戻り値
A new instance of the server.

BLEDevice.cpp75 行目に定義があります。

75  {
76  log_v(">> createServer");
77 #ifndef CONFIG_GATTS_ENABLE // Check that BLE GATTS is enabled in make menuconfig
78  log_e("BLE GATTS is not enabled - CONFIG_GATTS_ENABLE not defined");
79  abort();
80 #endif // CONFIG_GATTS_ENABLE
81  m_pServer = new BLEServer();
82  m_pServer->createApp(m_appId++);
83  log_v("<< createServer");
84  return m_pServer;
85 } // createServer
The model of a BLE server.
Definition: BLEServer.h:63
#define log_e(format,...)
static uint16_t m_appId
Definition: BLEDevice.h:53
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ deinit()

void BLEDevice::deinit ( bool  release_memory = false)
static

de-Initialize the BLE environment.

引数
release_memoryrelease the internal BT stack memory

BLEDevice.cpp615 行目に定義があります。

615  {
616  if (!initialized) return;
617 
622 #ifdef ARDUINO_ARCH_ESP32
623  if (release_memory) {
624  esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); // <-- require tests because we released classic BT memory and this can cause crash (most likely not, esp-idf takes care of it)
625  } else {
626  initialized = false;
627  }
628 #endif
629 }
esp_err_t esp_bluedroid_disable(void)
Disable bluetooth, must prior to esp_bluedroid_deinit()
esp_err_t esp_bluedroid_deinit(void)
Deinit and free the resource for bluetooth, must be after every bluetooth stuff
bool initialized
Definition: BLEDevice.cpp:44
esp_err_t esp_bt_controller_disable(void)
Disable BT controller
esp_err_t esp_bt_controller_deinit(void)
De-initialize BT controller to free resource and delete task.
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
esp_bt_controller_mem_release release the controller memory as per the mode

◆ getAddress()

BLEAddress BLEDevice::getAddress ( )
static

Get the BLE device address.

戻り値
The BLE device address.

BLEDevice.cpp288 行目に定義があります。

288  {
289  const uint8_t* bdAddr = esp_bt_dev_get_address();
291  memcpy(addr, bdAddr, sizeof(addr));
292  return BLEAddress(addr);
293 } // getAddress
A BLE device address.
Definition: BLEAddress.h:21
uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN]
Bluetooth device address
Definition: esp_bt_defs.h:105
endr Lperloop blti Lstart_memw memw movi Lperloop *linesize bltu Lstart_cachex endif endm macro cache_hit_region addr
Definition: cacheasm.h:208
__uint8_t uint8_t
Definition: stdint.h:21
const uint8_t * esp_bt_dev_get_address(void)
Get bluetooth device address. Must use after "esp_bluedroid_enable".

◆ getAdvertising()

BLEAdvertising * BLEDevice::getAdvertising ( )
static

BLEDevice.cpp551 行目に定義があります。

551  {
552  if(m_bleAdvertising == nullptr) {
553  m_bleAdvertising = new BLEAdvertising();
554  log_i("create advertising");
555  }
556  log_d("get advertising");
557  return m_bleAdvertising;
558 }
#define log_i(format,...)
Perform and manage BLE advertising.
#define log_d(format,...)
Definition: esp32-hal-log.h:92

◆ getClientByGattIf()

BLEClient * BLEDevice::getClientByGattIf ( uint16_t  conn_id)
static

BLEDevice.cpp572 行目に定義があります。

572  {
573  return (BLEClient*)m_connectedClientsMap.find(conn_id)->second.peer_device;
574 }
A model of a BLE client.
Definition: BLEClient.h:31

◆ getInitialized()

bool BLEDevice::getInitialized ( )
static

BLEDevice.cpp547 行目に定義があります。

547  {
548  return initialized;
549 }
bool initialized
Definition: BLEDevice.cpp:44

◆ getMTU()

uint16_t BLEDevice::getMTU ( )
static

BLEDevice.cpp543 行目に定義があります。

543  {
544  return m_localMTU;
545 }
static uint16_t m_localMTU
Definition: BLEDevice.h:64

◆ getPeerDevices()

std::map< uint16_t, conn_status_t > BLEDevice::getPeerDevices ( bool  client)
static

BLEDevice.cpp568 行目に定義があります。

568  {
569  return m_connectedClientsMap;
570 }

◆ getScan()

BLEScan * BLEDevice::getScan ( )
static

Retrieve the Scan object that we use for scanning.

戻り値
The scanning object reference. This is a singleton object. The caller should not try and release/delete it.

BLEDevice.cpp301 行目に定義があります。

301  {
302  //log_v(">> getScan");
303  if (m_pScan == nullptr) {
304  m_pScan = new BLEScan();
305  //log_d(" - creating a new scan object");
306  }
307  //log_v("<< getScan: Returning object at 0x%x", (uint32_t)m_pScan);
308  return m_pScan;
309 } // getScan
Perform and manage BLE scans.
Definition: BLEScan.h:49

◆ getValue()

std::string BLEDevice::getValue ( BLEAddress  bdAddress,
BLEUUID  serviceUUID,
BLEUUID  characteristicUUID 
)
static

Get the value of a characteristic of a service on a remote device.

引数
[in]bdAddress
[in]serviceUUID
[in]characteristicUUID

BLEDevice.cpp318 行目に定義があります。

318  {
319  log_v(">> getValue: bdAddress: %s, serviceUUID: %s, characteristicUUID: %s", bdAddress.toString().c_str(), serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
320  BLEClient* pClient = createClient();
321  pClient->connect(bdAddress);
322  std::string ret = pClient->getValue(serviceUUID, characteristicUUID);
323  pClient->disconnect();
324  log_v("<< getValue");
325  return ret;
326 } // getValue
const char *const string
Definition: cJSON.h:170
std::string toString()
Convert a BLE address to a string.
Definition: BLEAddress.cpp:86
A model of a BLE client.
Definition: BLEClient.h:31
static BLEClient * createClient()
Create a new instance of a client.
Definition: BLEDevice.cpp:59
std::string toString()
Get a string representation of the UUID.
Definition: BLEUUID.cpp:350
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ init()

void BLEDevice::init ( std::string  deviceName)
static

Initialize the BLE environment.

引数
deviceNameThe device name of the device.

BLEDevice.cpp333 行目に定義があります。

333  {
334  if(!initialized){
335  initialized = true; // Set the initialization flag to ensure we are only initialized once.
336 
337  esp_err_t errRc = ESP_OK;
338 #ifdef ARDUINO_ARCH_ESP32
339  if (!btStart()) {
340  errRc = ESP_FAIL;
341  return;
342  }
343 #else
344  errRc = ::nvs_flash_init();
345  if (errRc != ESP_OK) {
346  log_e("nvs_flash_init: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
347  return;
348  }
349 
350 #ifndef CLASSIC_BT_ENABLED
352 #endif
354  errRc = esp_bt_controller_init(&bt_cfg);
355  if (errRc != ESP_OK) {
356  log_e("esp_bt_controller_init: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
357  return;
358  }
359 
360 #ifndef CLASSIC_BT_ENABLED
362  if (errRc != ESP_OK) {
363  log_e("esp_bt_controller_enable: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
364  return;
365  }
366 #else
368  if (errRc != ESP_OK) {
369  log_e("esp_bt_controller_enable: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
370  return;
371  }
372 #endif
373 #endif
374 
376  if (bt_state == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
377  errRc = esp_bluedroid_init();
378  if (errRc != ESP_OK) {
379  log_e("esp_bluedroid_init: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
380  return;
381  }
382  }
383 
384  if (bt_state != ESP_BLUEDROID_STATUS_ENABLED) {
385  errRc = esp_bluedroid_enable();
386  if (errRc != ESP_OK) {
387  log_e("esp_bluedroid_enable: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
388  return;
389  }
390  }
391 
392  errRc = esp_ble_gap_register_callback(BLEDevice::gapEventHandler);
393  if (errRc != ESP_OK) {
394  log_e("esp_ble_gap_register_callback: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
395  return;
396  }
397 
398 #ifdef CONFIG_GATTC_ENABLE // Check that BLE client is configured in make menuconfig
399  errRc = esp_ble_gattc_register_callback(BLEDevice::gattClientEventHandler);
400  if (errRc != ESP_OK) {
401  log_e("esp_ble_gattc_register_callback: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
402  return;
403  }
404 #endif // CONFIG_GATTC_ENABLE
405 
406 #ifdef CONFIG_GATTS_ENABLE // Check that BLE server is configured in make menuconfig
407  errRc = esp_ble_gatts_register_callback(BLEDevice::gattServerEventHandler);
408  if (errRc != ESP_OK) {
409  log_e("esp_ble_gatts_register_callback: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
410  return;
411  }
412 #endif // CONFIG_GATTS_ENABLE
413 
414  errRc = ::esp_ble_gap_set_device_name(deviceName.c_str());
415  if (errRc != ESP_OK) {
416  log_e("esp_ble_gap_set_device_name: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
417  return;
418  };
419 
420 #ifdef CONFIG_BLE_SMP_ENABLE // Check that BLE SMP (security) is configured in make menuconfig
423  if (errRc != ESP_OK) {
424  log_e("esp_ble_gap_set_security_param: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
425  return;
426  };
427 #endif // CONFIG_BLE_SMP_ENABLE
428  }
429  vTaskDelay(200 / portTICK_PERIOD_MS); // Delay for 200 msecs as a workaround to an apparent Arduino environment issue.
430 } // init
#define portTICK_PERIOD_MS
Definition: portmacro.h:298
Controller config options, depend on config mask. Config mask indicate which functions enabled,...
Definition: esp_bt.h:134
esp_err_t esp_ble_gap_set_device_name(const char *name)
Set device name to the local device
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
Enable BT controller. Due to a known issue, you cannot call esp_bt_controller_enable() a second time ...
#define ESP_OK
Definition: esp_err.h:27
esp_err_t nvs_flash_init(void)
Initialize the default NVS partition.
esp_err_t esp_bluedroid_enable(void)
Enable bluetooth, must after esp_bluedroid_init()
esp_bluedroid_status_t
Bluetooth stack status type, to indicate whether the bluetooth stack is ready
Definition: esp_bt_main.h:27
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT()
Definition: esp_bt.h:106
esp_err_t esp_bluedroid_init(void)
Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff
bool btStart()
Definition: esp32-hal-bt.c:80
esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback)
This function is called to register application callbacks with BTA GATTS module.
uint8_t esp_ble_io_cap_t
static const char * errorToString(esp_err_t errCode)
Convert an ESP error code to a string.
#define ESP_IO_CAP_NONE
bool initialized
Definition: BLEDevice.cpp:44
esp_bluedroid_status_t esp_bluedroid_get_status(void)
Get bluetooth stack status
#define ESP_FAIL
Definition: esp_err.h:28
#define log_e(format,...)
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
This function is called to occur gap event, such as scan result
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type, void *value, uint8_t len)
Set a GAP security parameter value. Overrides the default value.
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
esp_bt_controller_mem_release release the controller memory as per the mode
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
This function is called to register application callbacks with GATTC module.
void vTaskDelay(const TickType_t xTicksToDelay) PRIVILEGED_FUNCTION
int32_t esp_err_t
Definition: esp_err.h:24
__uint8_t uint8_t
Definition: stdint.h:21
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
Initialize BT controller to allocate task and other resource. This function should be called only onc...

◆ removePeerDevice()

void BLEDevice::removePeerDevice ( uint16_t  conn_id,
bool  client 
)
static

BLEDevice.cpp603 行目に定義があります。

603  {
604  log_i("remove: %d, GATT role %s", conn_id, _client?"client":"server");
605  if(m_connectedClientsMap.find(conn_id) != m_connectedClientsMap.end())
606  m_connectedClientsMap.erase(conn_id);
607 }
#define log_i(format,...)

◆ setCustomGapHandler()

void BLEDevice::setCustomGapHandler ( gap_event_handler  handler)
static

BLEDevice.cpp631 行目に定義があります。

631  {
632  m_customGapHandler = handler;
633 }
static gap_event_handler m_customGapHandler
Definition: BLEDevice.h:92

◆ setCustomGattcHandler()

void BLEDevice::setCustomGattcHandler ( gattc_event_handler  handler)
static

BLEDevice.cpp635 行目に定義があります。

635  {
636  m_customGattcHandler = handler;
637 }
static gattc_event_handler m_customGattcHandler
Definition: BLEDevice.h:93

◆ setCustomGattsHandler()

void BLEDevice::setCustomGattsHandler ( gatts_event_handler  handler)
static

BLEDevice.cpp639 行目に定義があります。

639  {
640  m_customGattsHandler = handler;
641 }
static gatts_event_handler m_customGattsHandler
Definition: BLEDevice.h:94

◆ setEncryptionLevel()

void BLEDevice::setEncryptionLevel ( esp_ble_sec_act_t  level)
static

BLEDevice.cpp512 行目に定義があります。

512  {
514 }
static esp_ble_sec_act_t m_securityLevel
Definition: BLEDevice.h:65

◆ setMTU()

esp_err_t BLEDevice::setMTU ( uint16_t  mtu)
static

BLEDevice.cpp528 行目に定義があります。

528  {
529  log_v(">> setLocalMTU: %d", mtu);
531  if (err == ESP_OK) {
532  m_localMTU = mtu;
533  } else {
534  log_e("can't set local mtu value: %d", mtu);
535  }
536  log_v("<< setLocalMTU");
537  return err;
538 }
esp_err_t esp_ble_gatt_set_local_mtu(uint16_t mtu)
This function is called to set local MTU, the function is called before BLE connection.
#define ESP_OK
Definition: esp_err.h:27
static uint16_t m_localMTU
Definition: BLEDevice.h:64
#define log_e(format,...)
u16_t mtu
Definition: netif.h:319
int32_t esp_err_t
Definition: esp_err.h:24
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ setPower()

void BLEDevice::setPower ( esp_power_level_t  powerLevel)
static

Set the transmission power. The power level can be one of:

  • ESP_PWR_LVL_N14
  • ESP_PWR_LVL_N11
  • ESP_PWR_LVL_N8
  • ESP_PWR_LVL_N5
  • ESP_PWR_LVL_N2
  • ESP_PWR_LVL_P1
  • ESP_PWR_LVL_P4
  • ESP_PWR_LVL_P7
    引数
    [in]powerLevel.

BLEDevice.cpp446 行目に定義があります。

446  {
447  log_v(">> setPower: %d", powerLevel);
449  if (errRc != ESP_OK) {
450  log_e("esp_ble_tx_power_set: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
451  };
452  log_v("<< setPower");
453 } // setPower
#define ESP_OK
Definition: esp_err.h:27
static const char * errorToString(esp_err_t errCode)
Convert an ESP error code to a string.
#define log_e(format,...)
int32_t esp_err_t
Definition: esp_err.h:24
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
Set BLE TX power Connection Tx power should only be set after connection created.
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ setSecurityCallbacks()

void BLEDevice::setSecurityCallbacks ( BLESecurityCallbacks pCallbacks)
static

BLEDevice.cpp520 行目に定義があります。

520  {
521  BLEDevice::m_securityCallbacks = callbacks;
522 }

◆ setValue()

void BLEDevice::setValue ( BLEAddress  bdAddress,
BLEUUID  serviceUUID,
BLEUUID  characteristicUUID,
std::string  value 
)
static

Set the value of a characteristic of a service on a remote device.

引数
[in]bdAddress
[in]serviceUUID
[in]characteristicUUID

BLEDevice.cpp462 行目に定義があります。

462  {
463  log_v(">> setValue: bdAddress: %s, serviceUUID: %s, characteristicUUID: %s", bdAddress.toString().c_str(), serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
464  BLEClient* pClient = createClient();
465  pClient->connect(bdAddress);
466  pClient->setValue(serviceUUID, characteristicUUID, value);
467  pClient->disconnect();
468 } // setValue
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
std::string toString()
Convert a BLE address to a string.
Definition: BLEAddress.cpp:86
A model of a BLE client.
Definition: BLEClient.h:31
static BLEClient * createClient()
Create a new instance of a client.
Definition: BLEDevice.cpp:59
std::string toString()
Get a string representation of the UUID.
Definition: BLEUUID.cpp:350
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ startAdvertising()

void BLEDevice::startAdvertising ( )
static

BLEDevice.cpp560 行目に定義があります。

560  {
561  log_v(">> startAdvertising");
562  getAdvertising()->start();
563  log_v("<< startAdvertising");
564 } // startAdvertising
void start()
Start advertising. Start advertising.
static BLEAdvertising * getAdvertising()
Definition: BLEDevice.cpp:551
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ toString()

std::string BLEDevice::toString ( void  )
static

Return a string representation of the nature of this device.

戻り値
A string representation of the nature of this device.

BLEDevice.cpp475 行目に定義があります。

475  {
476  std::string res = "BD Address: " + getAddress().toString();
477  return res;
478 } // toString
const char *const string
Definition: cJSON.h:170
static BLEAddress getAddress()
Get the BLE device address.
Definition: BLEDevice.cpp:288
std::string toString()
Convert a BLE address to a string.
Definition: BLEAddress.cpp:86

◆ updatePeerDevice()

void BLEDevice::updatePeerDevice ( void *  peer,
bool  _client,
uint16_t  conn_id 
)
static

BLEDevice.cpp576 行目に定義があります。

576  {
577  log_d("update conn_id: %d, GATT role: %s", conn_id, _client? "client":"server");
578  std::map<uint16_t, conn_status_t>::iterator it = m_connectedClientsMap.find(ESP_GATT_IF_NONE);
579  if (it != m_connectedClientsMap.end()) {
580  std::swap(m_connectedClientsMap[conn_id], it->second);
581  m_connectedClientsMap.erase(it);
582  }else{
583  it = m_connectedClientsMap.find(conn_id);
584  if (it != m_connectedClientsMap.end()) {
585  conn_status_t _st = it->second;
586  _st.peer_device = peer;
587  std::swap(m_connectedClientsMap[conn_id], _st);
588  }
589  }
590 }
void * peer_device
Definition: BLEServer.h:29
#define ESP_GATT_IF_NONE
#define log_d(format,...)
Definition: esp32-hal-log.h:92

◆ whiteListAdd()

void BLEDevice::whiteListAdd ( BLEAddress  address)
static

Add an entry to the BLE white list.

引数
[in]addressThe address to add to the white list.

BLEDevice.cpp485 行目に定義があります。

485  {
486  log_v(">> whiteListAdd: %s", address.toString().c_str());
487  esp_err_t errRc = esp_ble_gap_update_whitelist(true, *address.getNative()); // True to add an entry.
488  if (errRc != ESP_OK) {
489  log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
490  }
491  log_v("<< whiteListAdd");
492 } // whiteListAdd
#define ESP_OK
Definition: esp_err.h:27
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda)
Add or remove device from white list
static const char * errorToString(esp_err_t errCode)
Convert an ESP error code to a string.
#define log_e(format,...)
std::string toString()
Convert a BLE address to a string.
Definition: BLEAddress.cpp:86
esp_bd_addr_t * getNative()
Return the native representation of the address.
Definition: BLEAddress.cpp:70
int32_t esp_err_t
Definition: esp_err.h:24
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ whiteListRemove()

void BLEDevice::whiteListRemove ( BLEAddress  address)
static

Remove an entry from the BLE white list.

引数
[in]addressThe address to remove from the white list.

BLEDevice.cpp499 行目に定義があります。

499  {
500  log_v(">> whiteListRemove: %s", address.toString().c_str());
501  esp_err_t errRc = esp_ble_gap_update_whitelist(false, *address.getNative()); // False to remove an entry.
502  if (errRc != ESP_OK) {
503  log_e("esp_ble_gap_update_whitelist: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
504  }
505  log_v("<< whiteListRemove");
506 } // whiteListRemove
#define ESP_OK
Definition: esp_err.h:27
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda)
Add or remove device from white list
static const char * errorToString(esp_err_t errCode)
Convert an ESP error code to a string.
#define log_e(format,...)
std::string toString()
Convert a BLE address to a string.
Definition: BLEAddress.cpp:86
esp_bd_addr_t * getNative()
Return the native representation of the address.
Definition: BLEAddress.cpp:70
int32_t esp_err_t
Definition: esp_err.h:24
#define log_v(format,...)
Definition: esp32-hal-log.h:84

メンバ詳解

◆ m_appId

uint16_t BLEDevice::m_appId = 0
static

BLEDevice.h53 行目に定義があります。

◆ m_customGapHandler

gap_event_handler BLEDevice::m_customGapHandler = nullptr
static

BLEDevice.h92 行目に定義があります。

◆ m_customGattcHandler

gattc_event_handler BLEDevice::m_customGattcHandler = nullptr
static

BLEDevice.h93 行目に定義があります。

◆ m_customGattsHandler

gatts_event_handler BLEDevice::m_customGattsHandler = nullptr
static

BLEDevice.h94 行目に定義があります。

◆ m_localMTU

uint16_t BLEDevice::m_localMTU = 23
static

BLEDevice.h64 行目に定義があります。

◆ m_securityLevel

esp_ble_sec_act_t BLEDevice::m_securityLevel = (esp_ble_sec_act_t)0
static

BLEDevice.h65 行目に定義があります。


このクラス詳解は次のファイルから抽出されました: