单导联心电记录仪
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.4 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #if 1
  2. #include "board.h"
  3. #include "nrf_delay.h"
  4. #include "project_cfg.h"
  5. #include "sys.h"
  6. #include "version.h"
  7. #include "zble_module.h"
  8. #include "zdatachannel_service.h"
  9. #if 0
  10. void qingfengboard_test(void) {
  11. // 测试LED
  12. debug_light_init(15);
  13. // 测试BUTTON
  14. // static uint8_t io_index[] = {ZPIN(0, 5), ZPIN(1, 9)};
  15. // zbsp_gpio_state_monitor(1000, (uint8_t*)io_index, ZARRAY_SIZE(io_index));
  16. // 测试睡眠唤醒
  17. zbsp_enter_sleep(3000, 5, true);
  18. }
  19. #endif
  20. ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
  21. APP_TIMER_DEF(m_test_tx_timer);
  22. static const char* hex2str(const uint8_t* data, int32_t len) {
  23. static char rx[64] = {0};
  24. memset(rx, 0, sizeof(rx));
  25. for (int32_t i = 0; i < len; i++) {
  26. sprintf(rx + i * 2, "%02X", data[i]);
  27. }
  28. return rx;
  29. }
  30. void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
  31. /**
  32. * @brief
  33. */
  34. if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
  35. ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
  36. }
  37. }
  38. static void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context) {
  39. switch (p_ble_evt->header.evt_id) {
  40. case BLE_GAP_EVT_CONNECTED:
  41. ZLOGI("Connected");
  42. break;
  43. case BLE_GAP_EVT_DISCONNECTED:
  44. ZLOGI("Disconnected");
  45. // zble_module_start_adv();
  46. break;
  47. }
  48. }
  49. void on_service_init(void) {
  50. /**
  51. * @brief
  52. */
  53. ZLOGI("init zdatachannel service");
  54. zdatachannel_init_t zdatachannle_init;
  55. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  56. zdatachannle_init.data_handler = zdatachannel_data_handler;
  57. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  58. }
  59. static void test_tx_timer_cb(void* p_context) {
  60. static uint32_t data;
  61. uint16_t txlen = 4;
  62. data++;
  63. zdatachannel_data_send((uint8_t*)&data, &txlen);
  64. }
  65. int main(void) {
  66. zsys_init();
  67. NRF_LOG_INFO("compile time :%s", __TIME__);
  68. NRF_LOG_INFO("Version :%d", VERSION);
  69. NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
  70. static zble_module_cfg_t cfg = //
  71. {
  72. .deviceName = "iflytop2",
  73. .on_service_init = on_service_init,
  74. };
  75. zble_module_init(&cfg);
  76. NRF_SDH_BLE_OBSERVER(m_ble_observer, 3, ble_evt_handler, NULL);
  77. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  78. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(5), NULL));
  79. zble_module_start_adv();
  80. zsys_loop();
  81. }
  82. #endif