add enableLedConn() to Bluefruit to enable/disable seting LED_CONN when connected
This commit is contained in:
1 parent
eddddb7472
commit
2022a14e34
2 files changed
+15
-4
No files matched your search
@@ -64,7 +64,7 @@
|
||||
// To change this value, an adjustment for SRAM is required in linker script
|
||||
#define BLE_GATTS_ATTR_TABLE_SIZE 0x1000
|
||||
|
||||
#define BLUEFRUIT_TASK_STACKSIZE (1024*4)
|
||||
#define BLUEFRUIT_TASK_STACKSIZE (1024*5)
|
||||
|
||||
extern "C" void SD_EVT_IRQHandler(void);
|
||||
void adafruit_bluefruit_task(void* arg);
|
||||
@@ -75,6 +75,8 @@ AdafruitBluefruit::AdafruitBluefruit(void)
|
||||
{
|
||||
_ble_event_sem = NULL;
|
||||
|
||||
_led_conn = true;
|
||||
|
||||
varclr(&_adv);
|
||||
varclr(&_scan_resp);
|
||||
|
||||
@@ -164,6 +166,11 @@ void AdafruitBluefruit::setName(const char* str)
|
||||
strncpy(_name, str, 32);
|
||||
}
|
||||
|
||||
void AdafruitBluefruit::enableLedConn(bool enabled)
|
||||
{
|
||||
_led_conn = enabled;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::connected(void)
|
||||
{
|
||||
return ( _conn_hdl != BLE_CONN_HANDLE_INVALID );
|
||||
@@ -451,7 +458,7 @@ void AdafruitBluefruit::_poll(void)
|
||||
switch ( evt->header.evt_id )
|
||||
{
|
||||
case BLE_GAP_EVT_CONNECTED:
|
||||
digitalWrite(LED_CONN, HIGH);
|
||||
if (_led_conn) digitalWrite(LED_CONN, HIGH);
|
||||
|
||||
_conn_hdl = evt->evt.gap_evt.conn_handle;
|
||||
_peer_addr = evt->evt.gap_evt.params.connected.peer_addr;
|
||||
@@ -462,8 +469,9 @@ void AdafruitBluefruit::_poll(void)
|
||||
break;
|
||||
|
||||
case BLE_GAP_EVT_DISCONNECTED:
|
||||
if (_led_conn) digitalWrite(LED_CONN, LOW);
|
||||
|
||||
_conn_hdl = BLE_GATT_HANDLE_INVALID;
|
||||
digitalWrite(LED_CONN, LOW);
|
||||
|
||||
vSemaphoreDelete(_txbuf_sem);
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ class AdafruitBluefruit
|
||||
|
||||
err_t begin(void);
|
||||
|
||||
void enableLedConn(bool enabled);
|
||||
|
||||
void setName(const char* str);
|
||||
// bool setTxPower(int8_t power);
|
||||
|
||||
@@ -112,9 +114,10 @@ class AdafruitBluefruit
|
||||
|
||||
private:
|
||||
SemaphoreHandle_t _ble_event_sem;
|
||||
|
||||
BLEDfu _dfu_svc;
|
||||
|
||||
bool _led_conn;
|
||||
|
||||
// ADV Data
|
||||
struct {
|
||||
uint8_t data[BLE_GAP_ADV_MAX_SIZE];
|
||||
|
||||
Reference in new issue
Block a user