|
@ -14,6 +14,7 @@ |
|
|
ZDATACHANNEL_DEF(m_zhrs, 2 /*优先级*/, 1 /*client num*/); // 蓝牙服务 |
|
|
ZDATACHANNEL_DEF(m_zhrs, 2 /*优先级*/, 1 /*client num*/); // 蓝牙服务 |
|
|
APP_TIMER_DEF(m_state_machine_driver_tmr); // 状态机驱动定时器 |
|
|
APP_TIMER_DEF(m_state_machine_driver_tmr); // 状态机驱动定时器 |
|
|
APP_TIMER_DEF(m_plod_state_event_detect_tmr); // 导联连接状态检测定时器 |
|
|
APP_TIMER_DEF(m_plod_state_event_detect_tmr); // 导联连接状态检测定时器 |
|
|
|
|
|
APP_TIMER_DEF(m_charge_event_detect_tmr); // 充电事件检测 |
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
#define SCHED_MAX_EVENT_DATA_SIZE APP_TIMER_SCHED_EVENT_DATA_SIZE /**< Maximum size of scheduler events. */ |
|
|
#define SCHED_MAX_EVENT_DATA_SIZE APP_TIMER_SCHED_EVENT_DATA_SIZE /**< Maximum size of scheduler events. */ |
|
|
|
|
|
|
|
@ -21,6 +22,10 @@ typedef enum { |
|
|
kplod_connected_event = 0, // 导联连接事件 |
|
|
kplod_connected_event = 0, // 导联连接事件 |
|
|
kplod_disconnected_event, // 导联断开事件 |
|
|
kplod_disconnected_event, // 导联断开事件 |
|
|
kplod_connecting_event, // 导联连接中事件 |
|
|
kplod_connecting_event, // 导联连接中事件 |
|
|
|
|
|
|
|
|
|
|
|
kplod_start_charge_event, // 充电事件 |
|
|
|
|
|
kplod_end_charge_event, // 充电结束事件 |
|
|
|
|
|
|
|
|
} app_event_type_t; |
|
|
} app_event_type_t; |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
typedef struct { |
|
@ -71,6 +76,25 @@ static void m_plod_state_event_detect_tmr_cb(void* p_context) { // |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void m_charge_event_detect_tmr_cb(void* p_context) { // |
|
|
|
|
|
static app_event_t appevent; |
|
|
|
|
|
memset(&appevent, 0, sizeof(appevent)); |
|
|
|
|
|
static bool ischarging = false; |
|
|
|
|
|
if (!SingleLeadECG_battery_charge_get_state()) { |
|
|
|
|
|
if (!ischarging) { |
|
|
|
|
|
appevent.eventType = kplod_start_charge_event; |
|
|
|
|
|
ischarging = true; |
|
|
|
|
|
app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (ischarging) { |
|
|
|
|
|
ischarging = false; |
|
|
|
|
|
appevent.eventType = kplod_end_charge_event; |
|
|
|
|
|
app_sched_event_put(&appevent, sizeof(appevent), app_event_process_cb); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
/******************************************************************************* |
|
|
* 事件处理 * |
|
|
* 事件处理 * |
|
|
*******************************************************************************/ |
|
|
*******************************************************************************/ |
|
@ -86,6 +110,12 @@ static void app_event_process_cb(void* p_event_data, uint16_t event_size) { |
|
|
} else if (p_event->eventType == kplod_connecting_event) { |
|
|
} else if (p_event->eventType == kplod_connecting_event) { |
|
|
ZLOGI("plod connecting %d", p_event->val.plod_connected_accumulation_time); |
|
|
ZLOGI("plod connecting %d", p_event->val.plod_connected_accumulation_time); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (p_event->eventType == kplod_start_charge_event) { |
|
|
|
|
|
ZLOGI("start charge"); |
|
|
|
|
|
} else if (p_event->eventType == kplod_end_charge_event) { |
|
|
|
|
|
ZLOGI("end charge"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -134,10 +164,13 @@ void one_conduction_main() { |
|
|
zble_module_init(&cfg); |
|
|
zble_module_init(&cfg); |
|
|
|
|
|
|
|
|
SingleLeadECG_ecg_io_init(); |
|
|
SingleLeadECG_ecg_io_init(); |
|
|
|
|
|
SingleLeadECG_battery_charge_detect_io_init(); |
|
|
ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb)); |
|
|
ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb)); |
|
|
ZERROR_CHECK(app_timer_create(&m_plod_state_event_detect_tmr, APP_TIMER_MODE_REPEATED, m_plod_state_event_detect_tmr_cb)); |
|
|
ZERROR_CHECK(app_timer_create(&m_plod_state_event_detect_tmr, APP_TIMER_MODE_REPEATED, m_plod_state_event_detect_tmr_cb)); |
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_charge_event_detect_tmr, APP_TIMER_MODE_REPEATED, m_charge_event_detect_tmr_cb)); |
|
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_start(m_plod_state_event_detect_tmr, APP_TIMER_TICKS(100), NULL)); |
|
|
ZERROR_CHECK(app_timer_start(m_plod_state_event_detect_tmr, APP_TIMER_TICKS(100), NULL)); |
|
|
|
|
|
ZERROR_CHECK(app_timer_start(m_charge_event_detect_tmr, APP_TIMER_TICKS(100), NULL)); |
|
|
znordic_loop(); |
|
|
znordic_loop(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|