enhance homekit advertising

update BLEAdvertisingData::addName()
This commit is contained in:
hathach committed 2018-02-06 17:11:09 +07:00
1 parent 56f63234f0
commit 9eb616e334
3 files changed
+18 -10

No files matched your search

+4 -4
View File
@@ -142,10 +142,10 @@ const char* dbg_err_str(uint32_t err_id); // TODO move to other place
#if CFG_DEBUG
#define PRINT_LOCATION() cprintf("%s: %d:\n", __PRETTY_FUNCTION__, __LINE__)
#define PRINT_MESS(x) cprintf("%s: %d: %s \n" , __PRETTY_FUNCTION__, __LINE__, (char*)(x))
#define PRTNT_HEAP() if (CFG_DEBUG == 3) cprintf("\n%s: %d: Heap free: %d\n", __PRETTY_FUNCTION__, __LINE__, util_heap_get_free_size())
#define PRINT_STR(x) cprintf("%s: %d: " #x " = %s\n" , __PRETTY_FUNCTION__, __LINE__, (char*)(x) )
#define PRINT_INT(x) cprintf("%s: %d: " #x " = %ld\n" , __PRETTY_FUNCTION__, __LINE__, (uint32_t) (x) )
#define PRINT_MESS(x) cprintf("%s: %d: %s \n" , __FUNCTION__, __LINE__, (char*)(x))
#define PRTNT_HEAP() if (CFG_DEBUG == 3) cprintf("\n%s: %d: Heap free: %d\n", __FUNCTION__, __LINE__, util_heap_get_free_size())
#define PRINT_STR(x) cprintf("%s: %d: " #x " = %s\n" , __FUNCTION__, __LINE__, (char*)(x) )
#define PRINT_INT(x) cprintf("%s: %d: " #x " = %ld\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
#define PRINT_HEX(x) \
do {\
+10 -4
View File
@@ -37,8 +37,6 @@
#include <bluefruit.h>
#include "BLEHomekit.h"
#define HOMEKIT_PROTOCOL_VERION 2
uint16_t BLEHomekit::_gInstanceID = 1;
BLEHomekit::BLEHomekit()
@@ -106,7 +104,7 @@ bool BLEHomekit::setAdv(BLEAdvertisingData& adv_ref)
.category = HAP_CAT_LIGHTBULB,
.gsn = 1,
.config_num = 1,
.compatible_verion = HOMEKIT_PROTOCOL_VERION
.compatible_verion = 2 // protocol version
};
Bluefruit.Gap.getAddr(data.dev_id);
@@ -114,6 +112,14 @@ bool BLEHomekit::setAdv(BLEAdvertisingData& adv_ref)
VERIFY_STATIC( sizeof(data) == 17);
adv.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
return adv.addManufacturerData(&data, sizeof(data));
adv.addManufacturerData(&data, sizeof(data));
// Full name is not added, added full name to scan response
if ( !adv.addName() )
{
Bluefruit.ScanResponse.addName();
}
return true;
}
@@ -173,7 +173,7 @@ bool BLEAdvertisingData::addService(BLEClientService& service)
/**
* Add Name to Adv packet, use setName() to set
* @return true if success
* @return true if full name is added, false if shorten name or not enough data to add name
*/
bool BLEAdvertisingData::addName(void)
{
@@ -189,7 +189,9 @@ bool BLEAdvertisingData::addName(void)
len = BLE_GAP_ADV_MAX_SIZE - (_count+2);
}
return addData(type, name, len);
VERIFY( addData(type, name, len) );
return type == BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
}
// tx power is set by setTxPower