ESP32  1.0.4
BLEServiceMap クラス

A data structure that manages the BLE servers owned by a BLE server. [詳解]

#include <BLEServer.h>

公開メンバ関数

BLEServicegetByHandle (uint16_t handle)
 Return the service by handle. [詳解]
 
BLEServicegetByUUID (const char *uuid)
 Return the service by UUID. [詳解]
 
BLEServicegetByUUID (BLEUUID uuid, uint8_t inst_id=0)
 Return the service by UUID. [詳解]
 
void handleGATTServerEvent (esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
 
void setByHandle (uint16_t handle, BLEService *service)
 Set the service by handle. [詳解]
 
void setByUUID (const char *uuid, BLEService *service)
 
void setByUUID (BLEUUID uuid, BLEService *service)
 Set the service by UUID. [詳解]
 
std::string toString ()
 Return a string representation of the service map. [詳解]
 
BLEServicegetFirst ()
 Get the first service in the map. [詳解]
 
BLEServicegetNext ()
 Get the next service in the map. [詳解]
 
void removeService (BLEService *service)
 Removes service from maps. [詳解]
 
int getRegisteredServiceCount ()
 Returns the amount of registered services [詳解]
 

詳解

A data structure that manages the BLE servers owned by a BLE server.

BLEServer.h38 行目に定義があります。

関数詳解

◆ getByHandle()

BLEService * BLEServiceMap::getByHandle ( uint16_t  handle)

Return the service by handle.

引数
[in]handleThe handle to look up the service.
戻り値
The service.

BLEServiceMap.cpp44 行目に定義があります。

44  {
45  return m_handleMap.at(handle);
46 } // getByHandle

◆ getByUUID() [1/2]

BLEService * BLEServiceMap::getByUUID ( const char *  uuid)

Return the service by UUID.

引数
[in]UUIDThe UUID to look up the service.
戻り値
The characteristic.

BLEServiceMap.cpp19 行目に定義があります。

19  {
20  return getByUUID(BLEUUID(uuid));
21 }
A model of a BLE UUID.
Definition: BLEUUID.h:18
BLEService * getByUUID(const char *uuid)
Return the service by UUID.

◆ getByUUID() [2/2]

BLEService * BLEServiceMap::getByUUID ( BLEUUID  uuid,
uint8_t  inst_id = 0 
)

Return the service by UUID.

引数
[in]UUIDThe UUID to look up the service.
戻り値
The characteristic.

BLEServiceMap.cpp28 行目に定義があります。

28  {
29  for (auto &myPair : m_uuidMap) {
30  if (myPair.first->getUUID().equals(uuid)) {
31  return myPair.first;
32  }
33  }
34  //return m_uuidMap.at(uuid.toString());
35  return nullptr;
36 } // getByUUID

◆ getFirst()

BLEService * BLEServiceMap::getFirst ( )

Get the first service in the map.

戻り値
The first service in the map.

BLEServiceMap.cpp101 行目に定義があります。

101  {
102  m_iterator = m_uuidMap.begin();
103  if (m_iterator == m_uuidMap.end()) return nullptr;
104  BLEService* pRet = m_iterator->first;
105  m_iterator++;
106  return pRet;
107 } // getFirst
The model of a BLE service.
Definition: BLEService.h:49

◆ getNext()

BLEService * BLEServiceMap::getNext ( )

Get the next service in the map.

戻り値
The next service in the map.

BLEServiceMap.cpp113 行目に定義があります。

113  {
114  if (m_iterator == m_uuidMap.end()) return nullptr;
115  BLEService* pRet = m_iterator->first;
116  m_iterator++;
117  return pRet;
118 } // getNext
The model of a BLE service.
Definition: BLEService.h:49

◆ getRegisteredServiceCount()

int BLEServiceMap::getRegisteredServiceCount ( )

Returns the amount of registered services

戻り値
amount of registered services

BLEServiceMap.cpp133 行目に定義があります。

133  {
134  return m_handleMap.size();
135 }

◆ handleGATTServerEvent()

void BLEServiceMap::handleGATTServerEvent ( esp_gatts_cb_event_t  event,
esp_gatt_if_t  gatts_if,
esp_ble_gatts_cb_param_t param 
)

BLEServiceMap.cpp87 行目に定義があります。

90  {
91  // Invoke the handler for every Service we have.
92  for (auto &myPair : m_uuidMap) {
93  myPair.first->handleGATTServerEvent(event, gatts_if, param);
94  }
95 }
null_event event
Definition: event.hpp:36

◆ removeService()

void BLEServiceMap::removeService ( BLEService service)

Removes service from maps.

戻り値
N/A.

BLEServiceMap.cpp124 行目に定義があります。

124  {
125  m_handleMap.erase(service->getHandle());
126  m_uuidMap.erase(service);
127 } // removeService
uint16_t getHandle()
Get the handle associated with this service.
Definition: BLEService.cpp:208

◆ setByHandle()

void BLEServiceMap::setByHandle ( uint16_t  handle,
BLEService service 
)

Set the service by handle.

引数
[in]handleThe handle of the service.
[in]serviceThe service to cache.
戻り値
N/A.

BLEServiceMap.cpp66 行目に定義があります。

66  {
67  m_handleMap.insert(std::pair<uint16_t, BLEService*>(handle, service));
68 } // setByHandle

◆ setByUUID() [1/2]

void BLEServiceMap::setByUUID ( const char *  uuid,
BLEService service 
)

◆ setByUUID() [2/2]

void BLEServiceMap::setByUUID ( BLEUUID  uuid,
BLEService service 
)

Set the service by UUID.

引数
[in]uuidThe uuid of the service.
[in]characteristicThe service to cache.
戻り値
N/A.

BLEServiceMap.cpp55 行目に定義があります。

55  {
56  m_uuidMap.insert(std::pair<BLEService*, std::string>(service, uuid.toString()));
57 } // setByUUID
std::string toString()
Get a string representation of the UUID.
Definition: BLEUUID.cpp:350

◆ toString()

std::string BLEServiceMap::toString ( void  )

Return a string representation of the service map.

戻り値
A string representation of the service map.

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

75  {
76  std::string res;
77  char hex[5];
78  for (auto &myPair: m_handleMap) {
79  res += "handle: 0x";
80  snprintf(hex, sizeof(hex), "%04x", myPair.first);
81  res += hex;
82  res += ", uuid: " + myPair.second->getUUID().toString() + "\n";
83  }
84  return res;
85 } // toString
const char *const string
Definition: cJSON.h:170

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