ESP32  1.0.4
BLECharacteristic クラス

The model of a BLE Characteristic. [詳解]

#include <BLECharacteristic.h>

公開メンバ関数

 BLECharacteristic (const char *uuid, uint32_t properties=0)
 Construct a characteristic [詳解]
 
 BLECharacteristic (BLEUUID uuid, uint32_t properties=0)
 Construct a characteristic [詳解]
 
virtual ~BLECharacteristic ()
 Destructor. [詳解]
 
void addDescriptor (BLEDescriptor *pDescriptor)
 Associate a descriptor with this characteristic. [詳解]
 
BLEDescriptorgetDescriptorByUUID (const char *descriptorUUID)
 Return the BLE Descriptor for the given UUID if associated with this characteristic. [詳解]
 
BLEDescriptorgetDescriptorByUUID (BLEUUID descriptorUUID)
 Return the BLE Descriptor for the given UUID if associated with this characteristic. [詳解]
 
BLEUUID getUUID ()
 Get the UUID of the characteristic. [詳解]
 
std::string getValue ()
 Retrieve the current value of the characteristic. [詳解]
 
uint8_tgetData ()
 Retrieve the current raw data of the characteristic. [詳解]
 
void indicate ()
 Send an indication. An indication is a transmission of up to the first 20 bytes of the characteristic value. An indication will block waiting a positive confirmation from the client. [詳解]
 
void notify (bool is_notification=true)
 Send a notify. A notification is a transmission of up to the first 20 bytes of the characteristic value. An notification will not block; it is a fire and forget. [詳解]
 
void setBroadcastProperty (bool value)
 Set the permission to broadcast. A characteristics has properties associated with it which define what it is capable of doing. One of these is the broadcast flag. [詳解]
 
void setCallbacks (BLECharacteristicCallbacks *pCallbacks)
 Set the callback handlers for this characteristic. [詳解]
 
void setIndicateProperty (bool value)
 Set the Indicate property value. [詳解]
 
void setNotifyProperty (bool value)
 Set the Notify property value. [詳解]
 
void setReadProperty (bool value)
 Set the Read property value. [詳解]
 
void setValue (uint8_t *data, size_t size)
 Set the value of the characteristic. [詳解]
 
void setValue (std::string value)
 Set the value of the characteristic from string data. We set the value of the characteristic from the bytes contained in the string. [詳解]
 
void setValue (uint16_t &data16)
 
void setValue (uint32_t &data32)
 
void setValue (int &data32)
 
void setValue (float &data32)
 
void setValue (double &data64)
 
void setWriteProperty (bool value)
 Set the Write property value. [詳解]
 
void setWriteNoResponseProperty (bool value)
 Set the Write No Response property value. [詳解]
 
std::string toString ()
 Return a string representation of the characteristic. [詳解]
 
uint16_t getHandle ()
 Get the handle of the characteristic. [詳解]
 
void setAccessPermissions (esp_gatt_perm_t perm)
 

静的公開変数類

static const uint32_t PROPERTY_READ = 1<<0
 
static const uint32_t PROPERTY_WRITE = 1<<1
 
static const uint32_t PROPERTY_NOTIFY = 1<<2
 
static const uint32_t PROPERTY_BROADCAST = 1<<3
 
static const uint32_t PROPERTY_INDICATE = 1<<4
 
static const uint32_t PROPERTY_WRITE_NR = 1<<5
 
static const uint32_t indicationTimeout = 1000
 

フレンド

class BLEServer
 
class BLEService
 
class BLEDescriptor
 
class BLECharacteristicMap
 

詳解

The model of a BLE Characteristic.

A BLE Characteristic is an identified value container that manages a value. It is exposed by a BLE server and can be read and written to by a BLE client.

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

構築子と解体子

◆ BLECharacteristic() [1/2]

BLECharacteristic::BLECharacteristic ( const char *  uuid,
uint32_t  properties = 0 
)

Construct a characteristic

引数
[in]uuid- UUID (const char*) for the characteristic.
[in]properties- Properties for the characteristic.

BLECharacteristic.cpp32 行目に定義があります。

32  : BLECharacteristic(BLEUUID(uuid), properties) {
33 }
A model of a BLE UUID.
Definition: BLEUUID.h:18
BLECharacteristic(const char *uuid, uint32_t properties=0)
Construct a characteristic

◆ BLECharacteristic() [2/2]

BLECharacteristic::BLECharacteristic ( BLEUUID  uuid,
uint32_t  properties = 0 
)

Construct a characteristic

引数
[in]uuid- UUID for the characteristic.
[in]properties- Properties for the characteristic.

BLECharacteristic.cpp40 行目に定義があります。

40  {
41  m_bleUUID = uuid;
42  m_handle = NULL_HANDLE;
43  m_properties = (esp_gatt_char_prop_t)0;
44  m_pCallbacks = &defaultCallback;
45 
46  setBroadcastProperty((properties & PROPERTY_BROADCAST) != 0);
47  setReadProperty((properties & PROPERTY_READ) != 0);
48  setWriteProperty((properties & PROPERTY_WRITE) != 0);
49  setNotifyProperty((properties & PROPERTY_NOTIFY) != 0);
50  setIndicateProperty((properties & PROPERTY_INDICATE) != 0);
51  setWriteNoResponseProperty((properties & PROPERTY_WRITE_NR) != 0);
52 } // BLECharacteristic
static const uint32_t PROPERTY_NOTIFY
void setBroadcastProperty(bool value)
Set the permission to broadcast. A characteristics has properties associated with it which define wha...
static const uint32_t PROPERTY_BROADCAST
#define NULL_HANDLE
void setWriteNoResponseProperty(bool value)
Set the Write No Response property value.
void setNotifyProperty(bool value)
Set the Notify property value.
static const uint32_t PROPERTY_READ
static const uint32_t PROPERTY_WRITE
static const uint32_t PROPERTY_INDICATE
void setReadProperty(bool value)
Set the Read property value.
static const uint32_t PROPERTY_WRITE_NR
uint8_t esp_gatt_char_prop_t
void setWriteProperty(bool value)
Set the Write property value.
void setIndicateProperty(bool value)
Set the Indicate property value.

◆ ~BLECharacteristic()

BLECharacteristic::~BLECharacteristic ( )
virtual

Destructor.

BLECharacteristic.cpp57 行目に定義があります。

57  {
58  //free(m_value.attr_value); // Release the storage for the value.
59 } // ~BLECharacteristic

関数詳解

◆ addDescriptor()

void BLECharacteristic::addDescriptor ( BLEDescriptor pDescriptor)

Associate a descriptor with this characteristic.

引数
[in]pDescriptor
戻り値
N/A.

BLECharacteristic.cpp67 行目に定義があります。

67  {
68  log_v(">> addDescriptor(): Adding %s to %s", pDescriptor->toString().c_str(), toString().c_str());
69  m_descriptorMap.setByUUID(pDescriptor->getUUID(), pDescriptor);
70  log_v("<< addDescriptor()");
71 } // addDescriptor
std::string toString()
Return a string representation of the descriptor.
std::string toString()
Return a string representation of the characteristic.
void setByUUID(const char *uuid, BLEDescriptor *pDescriptor)
Set the descriptor by UUID.
BLEUUID getUUID()
Get the UUID of the descriptor.
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ getData()

uint8_t * BLECharacteristic::getData ( )

Retrieve the current raw data of the characteristic.

戻り値
A pointer to storage containing the current characteristic data.

BLECharacteristic.cpp186 行目に定義があります。

186  {
187  return m_value.getData();
188 } // getData
uint8_t * getData()
Get a pointer to the data.
Definition: BLEValue.cpp:72

◆ getDescriptorByUUID() [1/2]

BLEDescriptor * BLECharacteristic::getDescriptorByUUID ( const char *  descriptorUUID)

Return the BLE Descriptor for the given UUID if associated with this characteristic.

引数
[in]descriptorUUIDThe UUID of the descriptor that we wish to retrieve.
戻り値
The BLE Descriptor. If no such descriptor is associated with the characteristic, nullptr is returned.

BLECharacteristic.cpp125 行目に定義があります。

125  {
126  return m_descriptorMap.getByUUID(BLEUUID(descriptorUUID));
127 } // getDescriptorByUUID
A model of a BLE UUID.
Definition: BLEUUID.h:18
BLEDescriptor * getByUUID(const char *uuid)
Return the descriptor by UUID.

◆ getDescriptorByUUID() [2/2]

BLEDescriptor * BLECharacteristic::getDescriptorByUUID ( BLEUUID  descriptorUUID)

Return the BLE Descriptor for the given UUID if associated with this characteristic.

引数
[in]descriptorUUIDThe UUID of the descriptor that we wish to retrieve.
戻り値
The BLE Descriptor. If no such descriptor is associated with the characteristic, nullptr is returned.

BLECharacteristic.cpp135 行目に定義があります。

135  {
136  return m_descriptorMap.getByUUID(descriptorUUID);
137 } // getDescriptorByUUID
BLEDescriptor * getByUUID(const char *uuid)
Return the descriptor by UUID.

◆ getHandle()

uint16_t BLECharacteristic::getHandle ( )

Get the handle of the characteristic.

戻り値
The handle of the characteristic.

BLECharacteristic.cpp144 行目に定義があります。

144  {
145  return m_handle;
146 } // getHandle

◆ getUUID()

BLEUUID BLECharacteristic::getUUID ( )

Get the UUID of the characteristic.

戻り値
The UUID of the characteristic.

BLECharacteristic.cpp169 行目に定義があります。

169  {
170  return m_bleUUID;
171 } // getUUID

◆ getValue()

std::string BLECharacteristic::getValue ( )

Retrieve the current value of the characteristic.

戻り値
A pointer to storage containing the current characteristic value.

BLECharacteristic.cpp178 行目に定義があります。

178  {
179  return m_value.getValue();
180 } // getValue
std::string getValue()
Get the current value.
Definition: BLEValue.cpp:98

◆ indicate()

void BLECharacteristic::indicate ( )

Send an indication. An indication is a transmission of up to the first 20 bytes of the characteristic value. An indication will block waiting a positive confirmation from the client.

戻り値
N/A

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

462  {
463 
464  log_v(">> indicate: length: %d", m_value.getValue().length());
465  notify(false);
466  log_v("<< indicate");
467 } // indicate
void notify(bool is_notification=true)
Send a notify. A notification is a transmission of up to the first 20 bytes of the characteristic val...
std::string getValue()
Get the current value.
Definition: BLEValue.cpp:98
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ notify()

void BLECharacteristic::notify ( bool  is_notification = true)

Send a notify. A notification is a transmission of up to the first 20 bytes of the characteristic value. An notification will not block; it is a fire and forget.

戻り値
N/A.

BLECharacteristic.cpp476 行目に定義があります。

476  {
477  log_v(">> notify: length: %d", m_value.getValue().length());
478 
479  assert(getService() != nullptr);
480  assert(getService()->getServer() != nullptr);
481 
482  m_pCallbacks->onNotify(this); // Invoke the notify callback.
483 
484  GeneralUtils::hexDump((uint8_t*)m_value.getValue().data(), m_value.getValue().length());
485 
486  if (getService()->getServer()->getConnectedCount() == 0) {
487  log_v("<< notify: No connected clients.");
488  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_NO_CLIENT, 0);
489  return;
490  }
491 
492  // Test to see if we have a 0x2902 descriptor. If we do, then check to see if notification is enabled
493  // and, if not, prevent the notification.
494 
495  BLE2902 *p2902 = (BLE2902*)getDescriptorByUUID((uint16_t)0x2902);
496  if(is_notification) {
497  if (p2902 != nullptr && !p2902->getNotifications()) {
498  log_v("<< notifications disabled; ignoring");
499  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_NOTIFY_DISABLED, 0); // Invoke the notify callback.
500  return;
501  }
502  }
503  else{
504  if (p2902 != nullptr && !p2902->getIndications()) {
505  log_v("<< indications disabled; ignoring");
506  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_INDICATE_DISABLED, 0); // Invoke the notify callback.
507  return;
508  }
509  }
510  for (auto &myPair : getService()->getServer()->getPeerDevices(false)) {
511  uint16_t _mtu = (myPair.second.mtu);
512  if (m_value.getValue().length() > _mtu - 3) {
513  log_w("- Truncating to %d bytes (maximum notify size)", _mtu - 3);
514  }
515 
516  size_t length = m_value.getValue().length();
517  if(!is_notification) // is indication
518  m_semaphoreConfEvt.take("indicate");
520  getService()->getServer()->getGattsIf(),
521  myPair.first,
522  getHandle(), length, (uint8_t*)m_value.getValue().data(), !is_notification); // The need_confirm = false makes this a notify.
523  if (errRc != ESP_OK) {
524  log_e("<< esp_ble_gatts_send_ %s: rc=%d %s",is_notification?"notify":"indicate", errRc, GeneralUtils::errorToString(errRc));
525  m_semaphoreConfEvt.give();
526  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_GATT, errRc); // Invoke the notify callback.
527  return;
528  }
529  if(!is_notification){ // is indication
530  if(!m_semaphoreConfEvt.timedWait("indicate", indicationTimeout)){
531  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_INDICATE_TIMEOUT, 0); // Invoke the notify callback.
532  } else {
533  auto code = (esp_gatt_status_t) m_semaphoreConfEvt.value();
534  if(code == ESP_GATT_OK) {
535  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::SUCCESS_INDICATE, code); // Invoke the notify callback.
536  } else {
537  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::ERROR_INDICATE_FAILURE, code);
538  }
539  }
540  } else {
541  m_pCallbacks->onStatus(this, BLECharacteristicCallbacks::Status::SUCCESS_NOTIFY, 0); // Invoke the notify callback.
542  }
543  }
544  log_v("<< notify");
545 } // Notify
#define log_w(format,...)
bool timedWait(std::string owner="<Unknown>", uint32_t timeoutMs=portMAX_DELAY)
Wait for a semaphore to be released in a given period of time by trying to take it and then releasing...
Definition: FreeRTOS.cpp:88
esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle, uint16_t value_len, uint8_t *value, bool need_confirm)
Send indicate or notify to GATT client. Set param need_confirm as false will send notification,...
uint32_t getConnectedCount()
Return the number of connected clients.
Definition: BLEServer.cpp:124
#define ESP_OK
Definition: esp_err.h:27
esp_gatt_status_t
GATT success code and error codes
BLEDescriptor * getDescriptorByUUID(const char *descriptorUUID)
Return the BLE Descriptor for the given UUID if associated with this characteristic.
void give()
Give a semaphore. The Semaphore is given.
Definition: FreeRTOS.cpp:142
__uint16_t uint16_t
Definition: stdint.h:33
virtual void onNotify(BLECharacteristic *pCharacteristic)
Callback function to support a Notify request.
static const uint32_t indicationTimeout
static void hexDump(const uint8_t *pData, uint32_t length)
Dump a representation of binary data to the console.
uint16_t getHandle()
Get the handle of the characteristic.
static const char * errorToString(esp_err_t errCode)
Convert an ESP error code to a string.
Descriptor for Client Characteristic Configuration.
Definition: BLE2902.h:23
#define log_e(format,...)
std::string getValue()
Get the current value.
Definition: BLEValue.cpp:98
bool getIndications()
Get the indications value.
Definition: BLE2902.cpp:36
bool getNotifications()
Get the notifications value.
Definition: BLE2902.cpp:27
BLEServer * getServer()
Get the BLE server associated with this service.
Definition: BLEService.cpp:409
#define assert(__e)
Definition: assert.h:16
uint32_t value()
Definition: FreeRTOS.h:44
char const int length
Definition: cJSON.h:161
virtual void onStatus(BLECharacteristic *pCharacteristic, Status s, uint32_t code)
Callback function to support a Notify/Indicate Status report.
int32_t esp_err_t
Definition: esp_err.h:24
#define log_v(format,...)
Definition: esp32-hal-log.h:84
bool take(std::string owner="<Unknown>")
Take a semaphore. Take a semaphore and wait indefinitely.
Definition: FreeRTOS.cpp:188
__uint8_t uint8_t
Definition: stdint.h:21

◆ setAccessPermissions()

void BLECharacteristic::setAccessPermissions ( esp_gatt_perm_t  perm)

BLECharacteristic.cpp148 行目に定義があります。

148  {
149  m_permissions = perm;
150 }

◆ setBroadcastProperty()

void BLECharacteristic::setBroadcastProperty ( bool  value)

Set the permission to broadcast. A characteristics has properties associated with it which define what it is capable of doing. One of these is the broadcast flag.

引数
[in]valueThe flag value of the property.
戻り値
N/A

BLECharacteristic.cpp555 行目に定義があります。

555  {
556  //log_d("setBroadcastProperty(%d)", value);
557  if (value) {
558  m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_BROADCAST);
559  } else {
560  m_properties = (esp_gatt_char_prop_t)(m_properties & ~ESP_GATT_CHAR_PROP_BIT_BROADCAST);
561  }
562 } // setBroadcastProperty
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST
uint8_t esp_gatt_char_prop_t

◆ setCallbacks()

void BLECharacteristic::setCallbacks ( BLECharacteristicCallbacks pCallbacks)

Set the callback handlers for this characteristic.

引数
[in]pCallbacksAn instance of a callbacks structure used to define any callbacks for the characteristic.

BLECharacteristic.cpp569 行目に定義があります。

569  {
570  log_v(">> setCallbacks: 0x%x", (uint32_t)pCallbacks);
571  if (pCallbacks != nullptr){
572  m_pCallbacks = pCallbacks;
573  } else {
574  m_pCallbacks = &defaultCallback;
575  }
576  log_v("<< setCallbacks");
577 } // setCallbacks
__uint32_t uint32_t
Definition: stdint.h:45
#define log_v(format,...)
Definition: esp32-hal-log.h:84

◆ setIndicateProperty()

void BLECharacteristic::setIndicateProperty ( bool  value)

Set the Indicate property value.

引数
[in]valueSet to true if we are to allow indicate messages.

BLECharacteristic.cpp601 行目に定義があります。

601  {
602  //log_d("setIndicateProperty(%d)", value);
603  if (value) {
604  m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_INDICATE);
605  } else {
606  m_properties = (esp_gatt_char_prop_t)(m_properties & ~ESP_GATT_CHAR_PROP_BIT_INDICATE);
607  }
608 } // setIndicateProperty
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
#define ESP_GATT_CHAR_PROP_BIT_INDICATE
uint8_t esp_gatt_char_prop_t

◆ setNotifyProperty()

void BLECharacteristic::setNotifyProperty ( bool  value)

Set the Notify property value.

引数
[in]valueSet to true if we are to allow notification messages.

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

615  {
616  //log_d("setNotifyProperty(%d)", value);
617  if (value) {
618  m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_NOTIFY);
619  } else {
620  m_properties = (esp_gatt_char_prop_t)(m_properties & ~ESP_GATT_CHAR_PROP_BIT_NOTIFY);
621  }
622 } // setNotifyProperty
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
uint8_t esp_gatt_char_prop_t

◆ setReadProperty()

void BLECharacteristic::setReadProperty ( bool  value)

Set the Read property value.

引数
[in]valueSet to true if we are to allow reads.

BLECharacteristic.cpp629 行目に定義があります。

629  {
630  //log_d("setReadProperty(%d)", value);
631  if (value) {
632  m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_READ);
633  } else {
634  m_properties = (esp_gatt_char_prop_t)(m_properties & ~ESP_GATT_CHAR_PROP_BIT_READ);
635  }
636 } // setReadProperty
#define ESP_GATT_CHAR_PROP_BIT_READ
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
uint8_t esp_gatt_char_prop_t

◆ setValue() [1/7]

void BLECharacteristic::setValue ( uint8_t data,
size_t  length 
)

Set the value of the characteristic.

引数
[in]dataThe data to set for the characteristic.
[in]lengthThe length of the data in bytes.

BLECharacteristic.cpp644 行目に定義があります。

644  {
645  char* pHex = BLEUtils::buildHexData(nullptr, data, length);
646  log_v(">> setValue: length=%d, data=%s, characteristic UUID=%s", length, pHex, getUUID().toString().c_str());
647  free(pHex);
649  log_e("Size %d too large, must be no bigger than %d", length, ESP_GATT_MAX_ATTR_LEN);
650  return;
651  }
652  m_semaphoreSetValue.take();
653  m_value.setValue(data, length);
654  m_semaphoreSetValue.give();
655  log_v("<< setValue");
656 } // setValue
BLEUUID getUUID()
Get the UUID of the characteristic.
static char * buildHexData(uint8_t *target, uint8_t *source, uint8_t length)
Create a hex representation of data.
Definition: BLEUtils.cpp:774
std::string toString()
Return a string representation of the characteristic.
void setValue(std::string value)
Set the current value.
Definition: BLEValue.cpp:115
void give()
Give a semaphore. The Semaphore is given.
Definition: FreeRTOS.cpp:142
#define ESP_GATT_MAX_ATTR_LEN
GATT maximum attribute length
#define log_e(format,...)
char const int length
Definition: cJSON.h:161
#define log_v(format,...)
Definition: esp32-hal-log.h:84
bool take(std::string owner="<Unknown>")
Take a semaphore. Take a semaphore and wait indefinitely.
Definition: FreeRTOS.cpp:188

◆ setValue() [2/7]

void BLECharacteristic::setValue ( std::string  value)

Set the value of the characteristic from string data. We set the value of the characteristic from the bytes contained in the string.

引数
[in]Setthe value of the characteristic.
戻り値
N/A.

BLECharacteristic.cpp666 行目に定義があります。

666  {
667  setValue((uint8_t*)(value.data()), value.length());
668 } // setValue
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
__uint8_t uint8_t
Definition: stdint.h:21
void setValue(uint8_t *data, size_t size)
Set the value of the characteristic.

◆ setValue() [3/7]

void BLECharacteristic::setValue ( uint16_t data16)

BLECharacteristic.cpp670 行目に定義があります。

670  {
671  uint8_t temp[2];
672  temp[0] = data16;
673  temp[1] = data16 >> 8;
674  setValue(temp, 2);
675 } // setValue
uint16_t temp
__uint8_t uint8_t
Definition: stdint.h:21
void setValue(uint8_t *data, size_t size)
Set the value of the characteristic.

◆ setValue() [4/7]

void BLECharacteristic::setValue ( uint32_t data32)

BLECharacteristic.cpp677 行目に定義があります。

677  {
678  uint8_t temp[4];
679  temp[0] = data32;
680  temp[1] = data32 >> 8;
681  temp[2] = data32 >> 16;
682  temp[3] = data32 >> 24;
683  setValue(temp, 4);
684 } // setValue
uint16_t temp
__uint8_t uint8_t
Definition: stdint.h:21
void setValue(uint8_t *data, size_t size)
Set the value of the characteristic.

◆ setValue() [5/7]

void BLECharacteristic::setValue ( int &  data32)

BLECharacteristic.cpp686 行目に定義があります。

686  {
687  uint8_t temp[4];
688  temp[0] = data32;
689  temp[1] = data32 >> 8;
690  temp[2] = data32 >> 16;
691  temp[3] = data32 >> 24;
692  setValue(temp, 4);
693 } // setValue
uint16_t temp
__uint8_t uint8_t
Definition: stdint.h:21
void setValue(uint8_t *data, size_t size)
Set the value of the characteristic.

◆ setValue() [6/7]

void BLECharacteristic::setValue ( float &  data32)

BLECharacteristic.cpp695 行目に定義があります。

695  {
696  float temp = data32;
697  setValue((uint8_t*)&temp, 4);
698 } // setValue
uint16_t temp
__uint8_t uint8_t
Definition: stdint.h:21
void setValue(uint8_t *data, size_t size)
Set the value of the characteristic.

◆ setValue() [7/7]

void BLECharacteristic::setValue ( double &  data64)

BLECharacteristic.cpp700 行目に定義があります。

700  {
701  double temp = data64;
702  setValue((uint8_t*)&temp, 8);
703 } // setValue
uint16_t temp
__uint8_t uint8_t
Definition: stdint.h:21
void setValue(uint8_t *data, size_t size)
Set the value of the characteristic.

◆ setWriteNoResponseProperty()

void BLECharacteristic::setWriteNoResponseProperty ( bool  value)

Set the Write No Response property value.

引数
[in]valueSet to true if we are to allow writes with no response.

BLECharacteristic.cpp710 行目に定義があります。

710  {
711  //log_d("setWriteNoResponseProperty(%d)", value);
712  if (value) {
713  m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_WRITE_NR);
714  } else {
715  m_properties = (esp_gatt_char_prop_t)(m_properties & ~ESP_GATT_CHAR_PROP_BIT_WRITE_NR);
716  }
717 } // setWriteNoResponseProperty
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
uint8_t esp_gatt_char_prop_t

◆ setWriteProperty()

void BLECharacteristic::setWriteProperty ( bool  value)

Set the Write property value.

引数
[in]valueSet to true if we are to allow writes.

BLECharacteristic.cpp724 行目に定義があります。

724  {
725  //log_d("setWriteProperty(%d)", value);
726  if (value) {
727  m_properties = (esp_gatt_char_prop_t)(m_properties | ESP_GATT_CHAR_PROP_BIT_WRITE);
728  } else {
729  m_properties = (esp_gatt_char_prop_t)(m_properties & ~ESP_GATT_CHAR_PROP_BIT_WRITE);
730  }
731 } // setWriteProperty
const char *const const char *const const cJSON *const value
Definition: cJSON_Utils.h:42
#define ESP_GATT_CHAR_PROP_BIT_WRITE
uint8_t esp_gatt_char_prop_t

◆ toString()

std::string BLECharacteristic::toString ( void  )

Return a string representation of the characteristic.

戻り値
A string representation of the characteristic.

BLECharacteristic.cpp738 行目に定義があります。

738  {
739  std::string res = "UUID: " + m_bleUUID.toString() + ", handle : 0x";
740  char hex[5];
741  snprintf(hex, sizeof(hex), "%04x", m_handle);
742  res += hex;
743  res += " ";
744  if (m_properties & ESP_GATT_CHAR_PROP_BIT_READ) res += "Read ";
745  if (m_properties & ESP_GATT_CHAR_PROP_BIT_WRITE) res += "Write ";
746  if (m_properties & ESP_GATT_CHAR_PROP_BIT_WRITE_NR) res += "WriteNoResponse ";
747  if (m_properties & ESP_GATT_CHAR_PROP_BIT_BROADCAST) res += "Broadcast ";
748  if (m_properties & ESP_GATT_CHAR_PROP_BIT_NOTIFY) res += "Notify ";
749  if (m_properties & ESP_GATT_CHAR_PROP_BIT_INDICATE) res += "Indicate ";
750  return res;
751 } // toString
const char *const string
Definition: cJSON.h:170
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR
#define ESP_GATT_CHAR_PROP_BIT_READ
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY
#define ESP_GATT_CHAR_PROP_BIT_WRITE
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST
#define ESP_GATT_CHAR_PROP_BIT_INDICATE
std::string toString()
Get a string representation of the UUID.
Definition: BLEUUID.cpp:350

フレンドと関連関数の詳解

◆ BLECharacteristicMap

friend class BLECharacteristicMap
friend

BLECharacteristic.h100 行目に定義があります。

◆ BLEDescriptor

friend class BLEDescriptor
friend

BLECharacteristic.h99 行目に定義があります。

◆ BLEServer

friend class BLEServer
friend

BLECharacteristic.h97 行目に定義があります。

◆ BLEService

friend class BLEService
friend

BLECharacteristic.h98 行目に定義があります。

メンバ詳解

◆ indicationTimeout

const uint32_t BLECharacteristic::indicationTimeout = 1000
static

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

◆ PROPERTY_BROADCAST

const uint32_t BLECharacteristic::PROPERTY_BROADCAST = 1<<3
static

BLECharacteristic.h89 行目に定義があります。

◆ PROPERTY_INDICATE

const uint32_t BLECharacteristic::PROPERTY_INDICATE = 1<<4
static

BLECharacteristic.h90 行目に定義があります。

◆ PROPERTY_NOTIFY

const uint32_t BLECharacteristic::PROPERTY_NOTIFY = 1<<2
static

BLECharacteristic.h88 行目に定義があります。

◆ PROPERTY_READ

const uint32_t BLECharacteristic::PROPERTY_READ = 1<<0
static

BLECharacteristic.h86 行目に定義があります。

◆ PROPERTY_WRITE

const uint32_t BLECharacteristic::PROPERTY_WRITE = 1<<1
static

BLECharacteristic.h87 行目に定義があります。

◆ PROPERTY_WRITE_NR

const uint32_t BLECharacteristic::PROPERTY_WRITE_NR = 1<<5
static

BLECharacteristic.h91 行目に定義があります。


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