change Bluefruit.getName() signature
This commit is contained in:
1 parent
76e168d2de
commit
27ef26024b
3 files changed
+13
-17
No files matched your search
@@ -107,10 +107,10 @@ bool BLEAdvertisingData::addService(BLEClientService& service)
|
||||
// Add Name to Adv packet, use setName() to set
|
||||
bool BLEAdvertisingData::addName(void)
|
||||
{
|
||||
const char* name = Bluefruit.getName();
|
||||
char name[BLE_GAP_ADV_MAX_SIZE+1];
|
||||
|
||||
uint8_t type = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
|
||||
uint8_t len = strlen(name);
|
||||
uint8_t len = Bluefruit.getName(name, sizeof(name));
|
||||
|
||||
// not enough for full name, chop it
|
||||
if (_count + len + 2 > BLE_GAP_ADV_MAX_SIZE)
|
||||
|
||||
@@ -90,8 +90,6 @@ AdafruitBluefruit::AdafruitBluefruit(void)
|
||||
|
||||
_tx_power = 0;
|
||||
|
||||
strcpy(_name, CFG_DEFAULT_NAME);
|
||||
|
||||
_conn_hdl = BLE_CONN_HANDLE_INVALID;
|
||||
_bonded = false;
|
||||
|
||||
@@ -185,7 +183,7 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable)
|
||||
|
||||
// Default device name
|
||||
ble_gap_conn_sec_mode_t sec_mode = BLE_SECMODE_OPEN;
|
||||
VERIFY_STATUS ( sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) _name, strlen(_name)) );
|
||||
VERIFY_STATUS ( sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) CFG_DEFAULT_NAME, strlen(CFG_DEFAULT_NAME)) );
|
||||
|
||||
VERIFY_STATUS( sd_ble_gap_appearance_set(BLE_APPEARANCE_UNKNOWN) );
|
||||
VERIFY_STATUS( sd_ble_gap_tx_power_set( CFG_BLE_TX_POWER_LEVEL ) );
|
||||
@@ -251,15 +249,14 @@ bool AdafruitBluefruit::setConnIntervalMS(uint16_t min_ms, uint16_t max_ms)
|
||||
|
||||
void AdafruitBluefruit::setName(const char* str)
|
||||
{
|
||||
strncpy(_name, str, 32);
|
||||
|
||||
ble_gap_conn_sec_mode_t sec_mode = BLE_SECMODE_OPEN;
|
||||
sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) _name, strlen(_name));
|
||||
sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) str, strlen(str));
|
||||
}
|
||||
|
||||
char* AdafruitBluefruit::getName(void)
|
||||
uint8_t AdafruitBluefruit::getName(char* name, uint16_t bufsize)
|
||||
{
|
||||
return _name;
|
||||
VERIFY_STATUS( sd_ble_gap_device_name_get((uint8_t*) name, &bufsize), 0);
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::setTxPower(int8_t power)
|
||||
|
||||
@@ -106,14 +106,14 @@ class AdafruitBluefruit
|
||||
/*------------------------------------------------------------------*/
|
||||
/* General Purpose Functions
|
||||
*------------------------------------------------------------------*/
|
||||
void autoConnLed (bool enabled);
|
||||
void setConnLedInterval (uint32_t ms);
|
||||
void autoConnLed (bool enabled);
|
||||
void setConnLedInterval (uint32_t ms);
|
||||
|
||||
void setName (const char* str);
|
||||
char* getName (void);
|
||||
void setName (const char* str);
|
||||
uint8_t getName (char* name, uint16_t bufsize);
|
||||
|
||||
bool setTxPower (int8_t power);
|
||||
int8_t getTxPower (void);
|
||||
bool setTxPower (int8_t power);
|
||||
int8_t getTxPower (void);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* GAP, Connections and Bonding
|
||||
@@ -165,7 +165,6 @@ class AdafruitBluefruit
|
||||
uint16_t _conn_interval;
|
||||
|
||||
int8_t _tx_power;
|
||||
char _name[32+1];
|
||||
|
||||
SemaphoreHandle_t _ble_event_sem;
|
||||
SemaphoreHandle_t _soc_event_sem;
|
||||
|
||||
Reference in new issue
Block a user