|
|
@ -10,6 +10,7 @@ |
|
|
|
// |
|
|
|
#include "app_uart.h" |
|
|
|
#include "basic/ssd1306/driver_ssd1306_basic.h" |
|
|
|
#include "basic\zdatachannel_service.h" |
|
|
|
#include "one_conduction/one_conduction_board.h" |
|
|
|
#include "three_lead\three_lead_board.h" |
|
|
|
#if defined(UART_PRESENT) |
|
|
@ -213,7 +214,7 @@ void main() { |
|
|
|
/******************************************************************************* |
|
|
|
* 蓝牙测试 * |
|
|
|
*******************************************************************************/ |
|
|
|
#if 1 |
|
|
|
#if 0 |
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
@ -313,11 +314,11 @@ void main() { |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
#if 0 |
|
|
|
#if 1 |
|
|
|
/******************************************************************************* |
|
|
|
* 3导联-ADS1293-测试 * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
#if 0 |
|
|
|
static void test_tx_timer_cb(void* p_context) { |
|
|
|
static uint32_t data; |
|
|
|
data++; |
|
|
@ -343,6 +344,84 @@ void main() { |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
|
static void zdatachanel_send_log(const char* fmt, ...) { |
|
|
|
static char tx[256] = {0}; |
|
|
|
static uint16_t len = 0; |
|
|
|
va_list args; |
|
|
|
va_start(args, fmt); |
|
|
|
|
|
|
|
len = vsprintf(tx, fmt, args); |
|
|
|
zdatachannel_data_send((uint8_t*)tx, &len); |
|
|
|
va_end(args); |
|
|
|
} |
|
|
|
|
|
|
|
static void test_tx_timer_cb(void* p_context) { |
|
|
|
static uint32_t data; |
|
|
|
data++; |
|
|
|
zdatachanel_send_log("%d,%d,%d\n", data, data, data); |
|
|
|
// static uint8_t tx[9] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}; |
|
|
|
// uint16_t p_length = 9; |
|
|
|
// zdatachannel_data_send(tx, &p_length); |
|
|
|
} |
|
|
|
|
|
|
|
ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/); |
|
|
|
static const char* hex2str(const uint8_t* data, int32_t len) { |
|
|
|
static char rx[64] = {0}; |
|
|
|
memset(rx, 0, sizeof(rx)); |
|
|
|
for (int32_t i = 0; i < len; i++) { |
|
|
|
sprintf(rx + i * 2, "%02X", data[i]); |
|
|
|
} |
|
|
|
return rx; |
|
|
|
} |
|
|
|
|
|
|
|
static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) { |
|
|
|
/** |
|
|
|
* @brief 接收到指令数据 |
|
|
|
*/ |
|
|
|
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) { |
|
|
|
ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length)); |
|
|
|
} |
|
|
|
} |
|
|
|
static void on_service_init(void) { |
|
|
|
/** |
|
|
|
* @brief 数据通道初始化 |
|
|
|
*/ |
|
|
|
ZLOGI("init zdatachannel service"); |
|
|
|
zdatachannel_init_t zdatachannle_init; |
|
|
|
memset(&zdatachannle_init, 0, sizeof(zdatachannle_init)); |
|
|
|
zdatachannle_init.data_handler = zdatachannel_data_handler; |
|
|
|
ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init)); |
|
|
|
} |
|
|
|
|
|
|
|
void main() { |
|
|
|
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); |
|
|
|
|
|
|
|
ThreeLeadECG_sdcard_base_init(); |
|
|
|
|
|
|
|
znordic_init(0, 20); |
|
|
|
NRF_LOG_INFO("compile time :%s", __TIME__); |
|
|
|
NRF_LOG_INFO("Version :%d", VERSION); |
|
|
|
NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME); |
|
|
|
|
|
|
|
static zble_module_cfg_t cfg = // |
|
|
|
{ |
|
|
|
.deviceName = BLE_NAME, |
|
|
|
.on_service_init = on_service_init, |
|
|
|
}; |
|
|
|
zble_module_init(&cfg); |
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb)); |
|
|
|
ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(5), NULL)); |
|
|
|
|
|
|
|
zble_module_start_adv(); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
#if 0 |
|
|
|
/******************************************************************************* |
|
|
|
* 3导联-led测试 * |
|
|
|