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.

86 lines
2.9 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. #include "znordic.h"
  2. //
  3. #include <stdarg.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. //
  8. #include "aproject_config/config.h"
  9. #include "app_basic_service/device_version_info_mgr.h"
  10. #include "app_basic_service/zapp.h"
  11. #include "zble_module.h"
  12. #include "zdatachannel_service.h"
  13. #include "one_conduction_main.h"
  14. //
  15. ZDATACHANNEL_DEF(m_zhrs, 2 /*���ȼ�*/, 1 /*client num*/); // ��������
  16. /**
  17. * @brief Ϣ
  18. */
  19. void zdatachannel_data_handler(zdatachannel_evt_t *p_evt) {
  20. if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
  21. one_conduction_process_rx_packet((uint8_t *)p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
  22. }
  23. }
  24. void on_service_init(void) {
  25. ZLOGI("init zdatachannel service");
  26. zdatachannel_init_t zdatachannle_init;
  27. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  28. zdatachannle_init.data_handler = zdatachannel_data_handler;
  29. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  30. }
  31. /*lint -save -e14 */
  32. /**
  33. * Function is implemented as weak so that it can be overwritten by custom application error handler
  34. * when needed.
  35. */
  36. void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) {
  37. __disable_irq();
  38. NRF_LOG_FINAL_FLUSH();
  39. switch (id) {
  40. case NRF_FAULT_ID_SDK_ASSERT: {
  41. assert_info_t *p_info = (assert_info_t *)info;
  42. NRF_LOG_ERROR("ASSERTION FAILED at %s:%u", p_info->p_file_name, p_info->line_num);
  43. break;
  44. }
  45. case NRF_FAULT_ID_SDK_ERROR: {
  46. error_info_t *p_info = (error_info_t *)info;
  47. NRF_LOG_ERROR("ERROR %u [%s] at %s:%u\r\nPC at: 0x%08x", p_info->err_code, nrf_strerror_get(p_info->err_code), p_info->p_file_name, p_info->line_num, pc);
  48. NRF_LOG_ERROR("End of error report");
  49. break;
  50. }
  51. default:
  52. NRF_LOG_ERROR("UNKNOWN FAULT at 0x%08X", pc);
  53. break;
  54. }
  55. NRF_BREAKPOINT_COND;
  56. // On assert, the system can only recover with a reset.
  57. NRF_LOG_WARNING("System reset");
  58. NVIC_SystemReset();
  59. }
  60. int main() {
  61. zapp_early_init();
  62. znordic_init_without_wd();
  63. zapp_init();
  64. /*******************************************************************************
  65. * ʼ *
  66. *******************************************************************************/
  67. static zble_module_cfg_t cfg;
  68. cfg.deviceName = device_info_read_sn_str();
  69. cfg.on_service_init = on_service_init;
  70. zble_module_init(&cfg);
  71. /*******************************************************************************
  72. * Ʒʼ *
  73. *******************************************************************************/
  74. one_conduction_main();
  75. /*******************************************************************************
  76. * LOOP *
  77. *******************************************************************************/
  78. zapp_start_schedule();
  79. znordic_loop();
  80. }