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.

70 lines
1.7 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. #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. ZDATACANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
  21. static const char* hex2str(const uint8_t* data, int32_t len) {
  22. static char rx[64] = {0};
  23. memset(rx, 0, sizeof(rx));
  24. for (int32_t i = 0; i < len; i++) {
  25. sprintf(rx + i * 2, "%02X", data[i]);
  26. }
  27. return rx;
  28. }
  29. void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
  30. /**
  31. * @brief
  32. */
  33. if (p_evt->type == ZDATACANNEL_EVT_RX_DATA) {
  34. ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
  35. }
  36. }
  37. void on_service_init(void) {
  38. /**
  39. * @brief
  40. */
  41. ZLOGI("init zdatachannel service");
  42. zdatachannel_init_t zdatachannle_init;
  43. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  44. zdatachannle_init.data_handler = zdatachannel_data_handler;
  45. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  46. }
  47. int main(void) {
  48. zsys_init();
  49. NRF_LOG_INFO("compile time :%s", __TIME__);
  50. NRF_LOG_INFO("Version :%d", VERSION);
  51. NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
  52. static zble_module_cfg_t cfg = //
  53. {
  54. .deviceName = "iflytop",
  55. .on_service_init = on_service_init,
  56. };
  57. zble_module_init(&cfg);
  58. zble_module_start_adv();
  59. zsys_loop();
  60. }
  61. #endif