clean up blue led blink

This commit is contained in:
hathach 2018-08-07 22:09:51 +07:00
parent 8786955225
commit 0e9d4f4341
2 changed files with 27 additions and 24 deletions

View File

@ -115,10 +115,7 @@ static ble_gap_id_key_t const * m_gap_ids[1];
// Adafruit
static uint8_t _adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
extern void blinky_fast_set(bool isFast);
extern void blinky_ota_connected(void);
extern void blinky_ota_disconneted(void);
/**@brief Function updating Service Changed CCCD and indicate a service change to peer.
*
@ -739,9 +736,6 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
blinky_ota_connected();
led_on(LED_BLUE);
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
m_is_advertising = false;
break;
@ -752,10 +746,8 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
uint16_t sys_attr_len = 128;
m_direct_adv_cnt = APP_DIRECTED_ADV_TIMEOUT;
blinky_ota_disconneted();
blinky_fast_set(false);
led_off(LED_BLUE);
blinky_fast_set(false);
err_code = sd_ble_gatts_sys_attr_get(m_conn_handle,
sys_attr,

View File

@ -128,7 +128,7 @@ volatile bool _freset_erased_complete = false;
// Adafruit for Blink pattern
bool isBlinkFast = false;
bool isOTAConnected = false;
bool _ota_connected = false;
APP_TIMER_DEF( blinky_timer_id );
@ -171,7 +171,7 @@ static void blinky_handler(void * p_context)
led_control(LED_RED, state);
// Blink LED BLUE if OTA mode and not connected
if (is_ota() && !isOTAConnected)
if (is_ota() && !_ota_connected)
{
led_control(LED_BLUE, state);
}
@ -188,17 +188,6 @@ void blinky_fast_set(bool isFast)
isBlinkFast = isFast;
}
void blinky_ota_connected(void)
{
isOTAConnected = true;
}
void blinky_ota_disconneted(void)
{
isOTAConnected = false;
}
void board_init(void)
{
button_pin_init(BOOTLOADER_BUTTON);
@ -484,6 +473,10 @@ uint32_t tusb_hal_millis(void)
/*------------------------------------------------------------------*/
/* SoftDevice Event handler
*------------------------------------------------------------------*/
/*
* Process BLE event from SD
*/
uint32_t proc_ble(void)
{
__ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ];
@ -495,16 +488,34 @@ uint32_t proc_ble(void)
// Handle valid event, ignore error
if( NRF_SUCCESS == err)
{
ble_evt_t* evt = (ble_evt_t*) ev_buf;
switch (evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
_ota_connected = true;
led_on(LED_BLUE);
break;
case BLE_GAP_EVT_DISCONNECTED:
_ota_connected = false;
led_off(LED_BLUE);
break;
default: break;
}
// from dfu_transport_ble
extern void ble_evt_dispatch(ble_evt_t * p_ble_evt);
ble_evt_t* evt = (ble_evt_t*) ev_buf;
ble_evt_dispatch(evt);
}
return err;
}
/*
* process SOC event from SD
*/
uint32_t proc_soc(void)
{
uint32_t soc_evt;