Skip to content

Commit 6664ebf

Browse files
committed
add set/get Apperance
1 parent 92dc3ed commit 6664ebf

File tree

2 files changed

+55
-33
lines changed

2 files changed

+55
-33
lines changed

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -386,30 +386,9 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable)
386386
return ERROR_NONE;
387387
}
388388

389-
bool AdafruitBluefruit::setConnInterval(uint16_t min, uint16_t max)
390-
{
391-
_ppcp_min_conn = min;
392-
_ppcp_max_conn = max;
393-
394-
ble_gap_conn_params_t gap_conn_params =
395-
{
396-
.min_conn_interval = _ppcp_min_conn, // in 1.25ms unit
397-
.max_conn_interval = _ppcp_max_conn, // in 1.25ms unit
398-
.slave_latency = BLE_GAP_CONN_SLAVE_LATENCY,
399-
.conn_sup_timeout = BLE_GAP_CONN_SUPERVISION_TIMEOUT_MS / 10 // in 10ms unit
400-
};
401-
402-
VERIFY_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params), false);
403-
404-
return true;
405-
}
406-
407-
bool AdafruitBluefruit::setConnIntervalMS(uint16_t min_ms, uint16_t max_ms)
408-
{
409-
return setConnInterval( MS100TO125(min_ms), MS100TO125(max_ms) );
410-
}
411-
412-
389+
/*------------------------------------------------------------------*/
390+
/* General Functions
391+
*------------------------------------------------------------------*/
413392
void AdafruitBluefruit::setName(const char* str)
414393
{
415394
ble_gap_conn_sec_mode_t sec_mode = BLE_SECMODE_OPEN;
@@ -460,6 +439,22 @@ void AdafruitBluefruit::setConnLedInterval(uint32_t ms)
460439
if ( !active ) xTimerStop(_led_blink_th, 0);
461440
}
462441

442+
bool AdafruitBluefruit::setApperance(uint16_t appear)
443+
{
444+
return ERROR_NONE == sd_ble_gap_appearance_set(appear);
445+
}
446+
447+
uint16_t AdafruitBluefruit::getApperance(void)
448+
{
449+
uint16_t appear = 0;
450+
(void) sd_ble_gap_appearance_get(&appear);
451+
return appear;
452+
}
453+
454+
/*------------------------------------------------------------------*/
455+
/* GAP, Connections and Bonding
456+
*------------------------------------------------------------------*/
457+
463458
bool AdafruitBluefruit::connected(void)
464459
{
465460
return ( _conn_hdl != BLE_CONN_HANDLE_INVALID );
@@ -476,6 +471,30 @@ bool AdafruitBluefruit::disconnect(void)
476471
return true; // not connected still return true
477472
}
478473

474+
bool AdafruitBluefruit::setConnInterval(uint16_t min, uint16_t max)
475+
{
476+
_ppcp_min_conn = min;
477+
_ppcp_max_conn = max;
478+
479+
ble_gap_conn_params_t gap_conn_params =
480+
{
481+
.min_conn_interval = _ppcp_min_conn, // in 1.25ms unit
482+
.max_conn_interval = _ppcp_max_conn, // in 1.25ms unit
483+
.slave_latency = BLE_GAP_CONN_SLAVE_LATENCY,
484+
.conn_sup_timeout = BLE_GAP_CONN_SUPERVISION_TIMEOUT_MS / 10 // in 10ms unit
485+
};
486+
487+
VERIFY_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params), false);
488+
489+
return true;
490+
}
491+
492+
bool AdafruitBluefruit::setConnIntervalMS(uint16_t min_ms, uint16_t max_ms)
493+
{
494+
return setConnInterval( MS100TO125(min_ms), MS100TO125(max_ms) );
495+
}
496+
497+
479498
void AdafruitBluefruit::setConnectCallback( BLEGap::connect_callback_t fp )
480499
{
481500
_connect_cb = fp;

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,19 @@ class AdafruitBluefruit
143143

144144

145145
/*------------------------------------------------------------------*/
146-
/* General Purpose Functions
146+
/* General Functions
147147
*------------------------------------------------------------------*/
148-
void autoConnLed (bool enabled);
149-
void setConnLedInterval (uint32_t ms);
148+
void setName (const char* str);
149+
uint8_t getName (char* name, uint16_t bufsize);
150150

151-
void setName (const char* str);
152-
uint8_t getName (char* name, uint16_t bufsize);
151+
bool setTxPower (int8_t power);
152+
int8_t getTxPower (void);
153153

154-
bool setTxPower (int8_t power);
155-
int8_t getTxPower (void);
154+
bool setApperance (uint16_t appear);
155+
uint16_t getApperance (void);
156+
157+
void autoConnLed (bool enabled);
158+
void setConnLedInterval (uint32_t ms);
156159

157160
/*------------------------------------------------------------------*/
158161
/* GAP, Connections and Bonding
@@ -170,8 +173,8 @@ class AdafruitBluefruit
170173
bool requestPairing (void);
171174
void clearBonds (void);
172175

173-
ble_gap_addr_t getPeerAddr(void);
174-
uint8_t getPeerAddr(uint8_t addr[6]);
176+
ble_gap_addr_t getPeerAddr (void);
177+
uint8_t getPeerAddr (uint8_t addr[6]);
175178

176179
void printInfo(void);
177180

0 commit comments

Comments
 (0)