update HAP char
This commit is contained in:
1 parent
57c89c85fa
commit
7220d98c94
6 files changed
+75
-12
No files matched your search
@@ -37,6 +37,9 @@
|
||||
#define BLEHOMEKIT_H_
|
||||
|
||||
#include "HAPUuid.h"
|
||||
#include "HAPCharacteristic.h"
|
||||
#include "HAPService.h"
|
||||
|
||||
#include "HapAccessoryInfo.h"
|
||||
|
||||
enum
|
||||
|
||||
@@ -34,5 +34,53 @@
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <bluefruit.h>
|
||||
#include "BLEHomekit.h"
|
||||
|
||||
BLEUuid HAPCharacteristic::_g_uuid_cid(HAP_UUID_CHR_CHARACTERISTIC_ID);
|
||||
|
||||
err_t HAPCharacteristic::begin(void)
|
||||
{
|
||||
VERIFY_STATUS( BLECharacteristic::begin() );
|
||||
return _addChrID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Characteristic Instance ID descriptor
|
||||
* @return status code
|
||||
*/
|
||||
err_t HAPCharacteristic::_addChrID(void)
|
||||
{
|
||||
// Add Descriptor UUID if not yet added
|
||||
if (_g_uuid_cid._uuid.type == BLE_UUID_TYPE_UNKNOWN)
|
||||
{
|
||||
_g_uuid_cid.begin();
|
||||
}
|
||||
|
||||
_cid = BLEHomekit::_gInstanceID++;
|
||||
|
||||
ble_gatts_attr_md_t cid_md =
|
||||
{
|
||||
.read_perm = BLE_SECMODE_OPEN,
|
||||
.write_perm = BLE_SECMODE_NO_ACCESS,
|
||||
.vlen = 0,
|
||||
.vloc = BLE_GATTS_VLOC_STACK
|
||||
};
|
||||
|
||||
ble_gatts_attr_t cid_desc =
|
||||
{
|
||||
.p_uuid = &_g_uuid_cid._uuid,
|
||||
.p_attr_md = &cid_md,
|
||||
.init_len = 2,
|
||||
.init_offs = 0,
|
||||
.max_len = 2,
|
||||
.p_value = (uint8_t*) &_cid
|
||||
};
|
||||
|
||||
uint16_t ref_hdl;
|
||||
VERIFY_STATUS ( sd_ble_gatts_descriptor_add(BLE_GATT_HANDLE_INVALID, &cid_desc, &ref_hdl) );
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,20 @@
|
||||
|
||||
#include <BLECharacteristic.h>
|
||||
|
||||
class HAPCharacteristic
|
||||
class HAPCharacteristic : public BLECharacteristic
|
||||
{
|
||||
public:
|
||||
static BLEUuid _g_uuid_cid;
|
||||
|
||||
HAPCharacteristic(BLEUuid bleuuid) : BLECharacteristic(bleuuid) { _cid = 0; }
|
||||
|
||||
virtual err_t begin(void);
|
||||
|
||||
private:
|
||||
uint16_t _cid;
|
||||
|
||||
err_t _addChrID(void);
|
||||
|
||||
};
|
||||
|
||||
#endif /* HAPCHARACTERISTIC_H_ */
|
||||
@@ -37,7 +37,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <bluefruit.h>
|
||||
#include "BLEHomekit.h"
|
||||
#include "HAPService.h"
|
||||
|
||||
err_t HAPService::begin(void)
|
||||
{
|
||||
@@ -46,6 +45,10 @@ err_t HAPService::begin(void)
|
||||
return _addSvcID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HAP Service Instance Characteristic
|
||||
* @return status code
|
||||
*/
|
||||
err_t HAPService::_addSvcID(void)
|
||||
{
|
||||
BLECharacteristic chr(HAP_UUID_CHR_SERVICE_ID);
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
#ifndef HAPUUID_H_
|
||||
#define HAPUUID_H_
|
||||
|
||||
#define HAP_UUID_CHR_SERVICE_ID ((const uint8_t[]) { 0xD1, 0xA0, 0x83, 0x50, 0x00, 0xAA, 0xD3, 0x87, 0x17, 0x48, 0x59, 0xA7, 0x5D, 0xE9, 0x04, 0xE6 })
|
||||
#define HAP_UUID_CHR_CHARACTERISTIC_ID ((const uint8_t[]) { 0x9A, 0x93, 0x96, 0xD7, 0xBD, 0x6A, 0xD9, 0xB5, 0x16, 0x46, 0xD2, 0x81, 0xFE, 0xF0, 0x46, 0xDC })
|
||||
#define HAP_UUID_CHR_SERVICE_SIGNATURE ((const uint8_t[]) { 0x91, 0x52, 0x76, 0xBB, 0x26, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xA5, 0x00, 0x00, 0x00 })
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* PAIRING
|
||||
*------------------------------------------------------------------*/
|
||||
@@ -195,13 +199,4 @@
|
||||
#define HAP_UUID_CHR_SERVICE_LABLE_NAMESPACE ((const uint8_t[]) { 0x91, 0x52, 0x76, 0xBB, 0x26, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xCD, 0x00, 0x00, 0x00 })
|
||||
#define HAP_UUID_CHR_COLOR_TEMP ((const uint8_t[]) { 0x91, 0x52, 0x76, 0xBB, 0x26, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xCE, 0x00, 0x00, 0x00 })
|
||||
|
||||
|
||||
#define HAP_UUID_CHR_SERVICE_ID ((const uint8_t[]) { 0xD1, 0xA0, 0x83, 0x50, 0x00, 0xAA, 0xD3, 0x87, 0x17, 0x48, 0x59, 0xA7, 0x5D, 0xE9, 0x04, 0xE6 })
|
||||
#define HAP_UUID_CHR_CHARACTERISTIC_ID ((const uint8_t[]) { 0x9A, 0x93, 0x96, 0xD7, 0xBD, 0x6A, 0xD9, 0xB5, 0x16, 0x46, 0xD2, 0x81, 0xFE, 0xF0, 0x46, 0xDC })
|
||||
#define HAP_UUID_CHR_SERVICE_SIGNATURE ((const uint8_t[]) { 0x91, 0x52, 0x76, 0xBB, 0x26, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xA5, 0x00, 0x00, 0x00 })
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Characteristics
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
#endif /* HAPUUID_H_ */
|
||||
@@ -137,7 +137,7 @@ class BLECharacteristic
|
||||
void setReadAuthorizeCallback(read_authorize_cb_t fp);
|
||||
void setWriteAuthorizeCallbak(write_authorize_cb_t fp);
|
||||
|
||||
err_t begin(void);
|
||||
virtual err_t begin(void);
|
||||
|
||||
ble_gatts_char_handles_t handles(void);
|
||||
|
||||
|
||||
Reference in new issue
Block a user