add set/get Apperance
This commit is contained in:
1 parent
92dc3ed5eb
commit
6664ebfef7
2 files changed
+55
-33
No files matched your search
@@ -386,30 +386,9 @@ err_t AdafruitBluefruit::begin(bool prph_enable, bool central_enable)
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::setConnInterval(uint16_t min, uint16_t max)
|
||||
{
|
||||
_ppcp_min_conn = min;
|
||||
_ppcp_max_conn = max;
|
||||
|
||||
ble_gap_conn_params_t gap_conn_params =
|
||||
{
|
||||
.min_conn_interval = _ppcp_min_conn, // in 1.25ms unit
|
||||
.max_conn_interval = _ppcp_max_conn, // in 1.25ms unit
|
||||
.slave_latency = BLE_GAP_CONN_SLAVE_LATENCY,
|
||||
.conn_sup_timeout = BLE_GAP_CONN_SUPERVISION_TIMEOUT_MS / 10 // in 10ms unit
|
||||
};
|
||||
|
||||
VERIFY_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params), false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::setConnIntervalMS(uint16_t min_ms, uint16_t max_ms)
|
||||
{
|
||||
return setConnInterval( MS100TO125(min_ms), MS100TO125(max_ms) );
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* General Functions
|
||||
*------------------------------------------------------------------*/
|
||||
void AdafruitBluefruit::setName(const char* str)
|
||||
{
|
||||
ble_gap_conn_sec_mode_t sec_mode = BLE_SECMODE_OPEN;
|
||||
@@ -460,6 +439,22 @@ void AdafruitBluefruit::setConnLedInterval(uint32_t ms)
|
||||
if ( !active ) xTimerStop(_led_blink_th, 0);
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::setApperance(uint16_t appear)
|
||||
{
|
||||
return ERROR_NONE == sd_ble_gap_appearance_set(appear);
|
||||
}
|
||||
|
||||
uint16_t AdafruitBluefruit::getApperance(void)
|
||||
{
|
||||
uint16_t appear = 0;
|
||||
(void) sd_ble_gap_appearance_get(&appear);
|
||||
return appear;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* GAP, Connections and Bonding
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
bool AdafruitBluefruit::connected(void)
|
||||
{
|
||||
return ( _conn_hdl != BLE_CONN_HANDLE_INVALID );
|
||||
@@ -476,6 +471,30 @@ bool AdafruitBluefruit::disconnect(void)
|
||||
return true; // not connected still return true
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::setConnInterval(uint16_t min, uint16_t max)
|
||||
{
|
||||
_ppcp_min_conn = min;
|
||||
_ppcp_max_conn = max;
|
||||
|
||||
ble_gap_conn_params_t gap_conn_params =
|
||||
{
|
||||
.min_conn_interval = _ppcp_min_conn, // in 1.25ms unit
|
||||
.max_conn_interval = _ppcp_max_conn, // in 1.25ms unit
|
||||
.slave_latency = BLE_GAP_CONN_SLAVE_LATENCY,
|
||||
.conn_sup_timeout = BLE_GAP_CONN_SUPERVISION_TIMEOUT_MS / 10 // in 10ms unit
|
||||
};
|
||||
|
||||
VERIFY_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params), false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::setConnIntervalMS(uint16_t min_ms, uint16_t max_ms)
|
||||
{
|
||||
return setConnInterval( MS100TO125(min_ms), MS100TO125(max_ms) );
|
||||
}
|
||||
|
||||
|
||||
void AdafruitBluefruit::setConnectCallback( BLEGap::connect_callback_t fp )
|
||||
{
|
||||
_connect_cb = fp;
|
||||
|
||||
@@ -143,16 +143,19 @@ class AdafruitBluefruit
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* General Purpose Functions
|
||||
/* General Functions
|
||||
*------------------------------------------------------------------*/
|
||||
void autoConnLed (bool enabled);
|
||||
void setConnLedInterval (uint32_t ms);
|
||||
void setName (const char* str);
|
||||
uint8_t getName (char* name, uint16_t bufsize);
|
||||
|
||||
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);
|
||||
bool setApperance (uint16_t appear);
|
||||
uint16_t getApperance (void);
|
||||
|
||||
void autoConnLed (bool enabled);
|
||||
void setConnLedInterval (uint32_t ms);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* GAP, Connections and Bonding
|
||||
@@ -170,8 +173,8 @@ class AdafruitBluefruit
|
||||
bool requestPairing (void);
|
||||
void clearBonds (void);
|
||||
|
||||
ble_gap_addr_t getPeerAddr(void);
|
||||
uint8_t getPeerAddr(uint8_t addr[6]);
|
||||
ble_gap_addr_t getPeerAddr (void);
|
||||
uint8_t getPeerAddr (uint8_t addr[6]);
|
||||
|
||||
void printInfo(void);
|
||||
|
||||
|
||||
Reference in new issue
Block a user