|
|
@ -36,18 +36,24 @@ NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ |
|
|
|
* CODE * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< µ±Ç°Á¬½Ó¾ä±ú */ |
|
|
|
static uint16_t m_mtu_size = BLE_GATT_ATT_MTU_DEFAULT - 3; |
|
|
|
static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< µ±Ç°Á¬½Ó¾ä±ú */ |
|
|
|
static uint16_t m_mtu_size = BLE_GATT_ATT_MTU_DEFAULT - 3; |
|
|
|
static zble_event_listener_t m_event_listener; |
|
|
|
|
|
|
|
static void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context) { |
|
|
|
uint32_t err_code; |
|
|
|
uint32_t err_code; |
|
|
|
static zble_event_t zevent; |
|
|
|
switch (p_ble_evt->header.evt_id) { |
|
|
|
case BLE_GAP_EVT_CONNECTED: |
|
|
|
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; |
|
|
|
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle; |
|
|
|
zevent.eventType = kzble_event_connected; |
|
|
|
if (m_event_listener) m_event_listener(&zevent); |
|
|
|
break; |
|
|
|
|
|
|
|
case BLE_GAP_EVT_DISCONNECTED: |
|
|
|
m_conn_handle = BLE_CONN_HANDLE_INVALID; |
|
|
|
m_conn_handle = BLE_CONN_HANDLE_INVALID; |
|
|
|
zevent.eventType = kzble_event_disconnected; |
|
|
|
if (m_event_listener) m_event_listener(&zevent); |
|
|
|
break; |
|
|
|
|
|
|
|
case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { |
|
|
@ -128,10 +134,13 @@ void zble_module_stop_adv() { |
|
|
|
uint32_t err_code = sd_ble_gap_adv_stop(m_advertising.adv_handle); |
|
|
|
ZERROR_CHECK(err_code); |
|
|
|
} |
|
|
|
bool zble_module_is_connected() { return m_conn_handle != BLE_CONN_HANDLE_INVALID; } |
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
|
* INIT * |
|
|
|
*******************************************************************************/ |
|
|
|
void zble_module_reglistener(zble_event_listener_t event_listener) { m_event_listener = event_listener; } |
|
|
|
|
|
|
|
void zble_module_init(zble_module_cfg_t* cfg) { |
|
|
|
/** |
|
|
|
* @brief |
|
|
|