Browse Source

update

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
be73a4a9a5
  1. 3
      .vscode/settings.json
  2. 1
      README.md
  3. 5
      app/src/basic/heart_rate_sensor_protocol.h
  4. 41
      app/src/one_conduction/ble_cmd_process_service.c
  5. 3
      app/src/one_conduction/config.h
  6. 9
      app/src/one_conduction/display_manager.c
  7. 2
      app/src/one_conduction/one_conduction_main.c

3
.vscode/settings.json

@ -89,7 +89,8 @@
"stdarg.h": "c",
"nrf_uarte.h": "c",
"heart_rate_sensor_protocol.h": "c",
"ble_cmd_process_service.h": "c"
"ble_cmd_process_service.h": "c",
"heart_wave_sample_service.h": "c"
},
"files.encoding": "gbk"
}

1
README.md

@ -259,6 +259,7 @@ TODO:
6. 支持电池电量采集
8. 采集完30秒,蜂鸣器滴一声,采集完成,蜂鸣器滴一声
16. 调整UI位置
11. 死机后一直重启的BUG
--------------------------------------------------------------
2. UI添加蓝牙状态
3. UI添加上传状态

5
app/src/basic/heart_rate_sensor_protocol.h

@ -158,11 +158,6 @@ typedef struct {
} start_upload_record_cmd_t;
typedef struct {
uin
} start_upload_record_receipt_t;
typedef struct {
uint8_t sn[14];
} read_sn_receipt_t;

41
app/src/one_conduction/ble_cmd_process_service.c

@ -8,7 +8,8 @@
#include "one_conduction_board.h"
#include "sample_data_manager.h"
APP_TIMER_DEF(m_record_upload_tmr); //
APP_TIMER_DEF(m_record_upload_tmr); //
APP_TIMER_DEF(m_record_upload_finish_packet_report_tmr); //
static uint8_t txbuf[128];
static uint8_t reportbuf[128];
static bool m_realtime_report_state = false;
@ -17,6 +18,7 @@ static bool m_ble_cmder_is_inited = false;
static uint32_t m_report_data_sumcheckcode = 0;
static void record_upload_tmr_cb(void* p_context);
static void record_upload_finish_packet_report_tmr_cb(void* p_context);
int ble_stop_upload_record();
/*******************************************************************************
* 广 *
@ -36,6 +38,7 @@ void ble_cmder_stop_adv() {
void ble_cmder_init() {
if (!m_ble_cmder_is_inited) {
ZERROR_CHECK(app_timer_create(&m_record_upload_tmr, APP_TIMER_MODE_REPEATED, record_upload_tmr_cb));
ZERROR_CHECK(app_timer_create(&m_record_upload_finish_packet_report_tmr, APP_TIMER_MODE_SINGLE_SHOT, record_upload_finish_packet_report_tmr_cb));
}
m_ble_cmder_is_inited = true;
}
@ -91,7 +94,7 @@ void ble_cmder_report_upload_finish_event(uint32_t sumcheckcode) {
ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)txbuf;
uint16_t sendlen = sizeof(ify_hrs_packet_t) + 4;
txheader->cmd = ify_hrs_report_record_upload_end;
txheader->cmd = ify_hrs_report_record_upload_end; // 6A
txheader->frame_index = 0;
txheader->frame_type = kifyhrs_pt_report;
@ -119,8 +122,19 @@ void ble_cmder_report_sample_finish_event() {
*******************************************************************************/
static int m_upload_fd;
static uint8_t datacache[256];
static uint8_t m_remaindatalen = 0;
static void record_upload_tmr_cb(void* p_context) { //
static int m_remaindatalen = 0;
/**
* @brief
*
* @param p_context
*/
static void record_upload_finish_packet_report_tmr_cb(void* p_context) { //
ble_cmder_report_upload_finish_event(m_report_data_sumcheckcode);
}
static void record_upload_tmr_cb(void* p_context) { //
if (!m_isupload_data_state) return;
// sample_data_mgr_read
if (m_remaindatalen == 0) {
@ -128,18 +142,23 @@ static void record_upload_tmr_cb(void* p_context) { //
int32_t rdsize = sample_data_mgr_read(m_upload_fd, datacache, sizeof(datacache));
if (rdsize <= 0) {
ZLOGI("read file end,stop upload");
ble_cmder_report_upload_finish_event(m_report_data_sumcheckcode);
ZERROR_CHECK(app_timer_start(m_record_upload_finish_packet_report_tmr, APP_TIMER_TICKS(30), (void*)m_report_data_sumcheckcode));
ble_stop_upload_record();
return;
}
m_remaindatalen = rdsize;
}
if (m_remaindatalen == 0) {
return;
}
int32_t mtusize = zble_module_get_mtu_size();
mtusize = mtusize < 128 ? mtusize : 128;
uint8_t* data = datacache + (sizeof(datacache) - m_remaindatalen);
uint8_t len = m_remaindatalen > mtusize ? mtusize : m_remaindatalen;
int len = m_remaindatalen > mtusize ? mtusize : m_remaindatalen;
ZLOGI("upload %d %d %d", len, m_remaindatalen, mtusize);
if (!zdatachannel_is_connected()) {
ZLOGI("ble is disconnected,stop upload");
ble_stop_upload_record();
@ -153,7 +172,7 @@ static void record_upload_tmr_cb(void* p_context) { //
ZLOGI("ble unenable notify,stop upload");
ble_stop_upload_record();
return;
} else if (suc == NRF_ERROR_BUSY) {
} else if (suc == NRF_ERROR_BUSY || suc == NRF_ERROR_RESOURCES) {
//
return;
} else {
@ -402,7 +421,13 @@ void ble_cmder_process_rx(uint8_t* rx, int len) {
int ecode = ble_start_upload_record(&filename);
if (ecode == 0) {
send_success_receipt(rxheader);
ify_hrs_packet_t* txheader = (ify_hrs_packet_t*)txbuf;
uint16_t sendlen = sizeof(ify_hrs_packet_t) + 1; // 4BYTE便
txheader->cmd = rxheader->cmd;
txheader->frame_index = rxheader->frame_index;
txheader->frame_type = kifyhrs_pt_cmd_receipt;
zdatachannel_data_send2(txbuf, sendlen);
} else {
send_error_receipt(rxheader, ecode);
}

3
app/src/one_conduction/config.h

@ -18,4 +18,5 @@
#define SAMPLE_RATE 200
#define SAMPLE_PRECISION 12
#define AUTOMATIC_SLEEP_TIME 15000
#define AUTOMATIC_SLEEP_TIME 15000
#define SAMPLE_MIN_TIME_S (5.0)

9
app/src/one_conduction/display_manager.c

@ -10,6 +10,7 @@
#include "font.h"
#include "heart_wave_sample_service.h"
#include "one_conduction_board.h"
#include "config.h"
PageState_t g_pageState;
void dsp_mgr_change_to_page(page_t page) { //
@ -231,7 +232,7 @@ void dsp_mgr_change_to_sampling(int progress_s, int heartrate) { //
sps->heartrate_x = sps->progress_x + sps->progress_width + 2;
sps->heartrate_y = sps->progress_y - 4;
int progress = progress_s / 30.0 * 25;
int progress = progress_s / SAMPLE_MIN_TIME_S * 25;
ssd1306_basic_clear_gram();
@ -253,7 +254,7 @@ void samplePage_update_state(int progress_s, int wave_y, int heartrate, bool upd
sample_page_state_t* sps = &m_sample_page_state;
uint8_t xchange, ychange;
int progress = progress_s / 30.0 * 25;
int progress = progress_s / SAMPLE_MIN_TIME_S * 25;
if (progress_s / 10 == 0) {
ssd1306_basic_draw_str(sps->progress_x, sps->progress_y - 8, &xchange, &ychange, "xxx", &font8x8_xo_lib);
@ -291,7 +292,7 @@ void dsp_mgr_change_to_sampling(int progress_s, int heartrate) { //
sps->heartrate_x = sps->wave_drawser_x + sps->wave_drawser_width + 5;
sps->heartrate_y = sps->wave_drawser_y;
int progress = progress_s / 30.0 * 25;
int progress = progress_s / SAMPLE_MIN_TIME_S * 25;
uint8_t xchange, ychange;
ssd1306_basic_clear_gram();
@ -323,7 +324,7 @@ void samplePage_update_state(int progress_s, int wave_y, int heartrate, bool upd
sample_page_state_t* sps = &m_sample_page_state;
uint8_t xchange, ychange;
int progress = progress_s / 30.0 * 25;
int progress = progress_s / SAMPLE_MIN_TIME_S * 25;
ssd1306_basic_draw_progress(sps->progress_x, sps->progress_y, sps->progress_width, sps->progress_hight, 25, progress);
if (progress_s / 10 >= 3) {

2
app/src/one_conduction/one_conduction_main.c

@ -323,7 +323,7 @@ void app_event_process_cb(void* p_event_data, uint16_t event_size) {
//
ble_cmder_try_report_one_sample_data(p_event->val.frame_data.frameIndex, p_event->val.frame_data.data);
} else if (p_event->eventType == kplod_disconnected_event || !m_plod_state_connected_state) {
if (hwss_has_captured_time_ms() < 30000) {
if (hwss_has_captured_time_ms() < (SAMPLE_MIN_TIME_S * 1000)) {
// 30
ble_cmder_try_report_sensor_drop_event(0x01, 0);
/*******************************************************************************

Loading…
Cancel
Save