5 posts / 0 new
Last post
zhongfushun
Offline
Last seen:1 year 7 months ago
加入:2019-04-24 02:30
关于 DA14583 HRPS

学习HRPS中出现的问题:

使用定时器周期性调用以下函数,试图周期性发送心率值到手机APP,传递给该函数的值是从1逐步递加到120的整数值,但当该值递加到70左右(从手机APP观察到),板子死机,之后与手机APP断开链接,就再也连接不上了。这大概是什么原因造成的?因为是初学者,麻烦提供思路。

void app_hrps_meas_send(uint16_t hrp_val)
{
// Add BASS in the database
struct hrps_meas_send_req * req = KE_MSG_ALLOC(HRPS_MEAS_SEND_REQ, TASK_HRPS,
TASK_APP, hrps_meas_send_req);

req->conhdl = active_conhdl;
struct hrs_hr_meas *phrs_hr_meas = &req->meas_val;
phrs_hr_meas->flags = HRS_FLAG_HR_8BITS_VALUE;
phrs_hr_meas->nb_rr_interval = 4;
phrs_hr_meas->rr_intervals[0] = 10;
phrs_hr_meas->heart_rate = hrp_val;
phrs_hr_meas->energy_expended = HRS_HR_CNTL_POINT_CODE;

// Send the message
ke_msg_send(req);
}

以下是激活PROFILE函数:

void app_hrps_enable(uint16_t conhdl)
{
// Allocate the message
struct hrps_enable_req * req = KE_MSG_ALLOC(HRPS_ENABLE_REQ, TASK_HRPS, TASK_APP,
hrps_enable_req);
// Fill in the parameter structure
active_conhdl= conhdl;
req->conhdl = conhdl;
req->sec_lvl = get_user_prf_srv_perm(TASK_HRPS);
req->con_type = PRF_CON_NORMAL; // PRF_CON_DISCOVERY;
req->hr_meas_ntf_en = 0;// Notification OFF by default.
//req->batt_level_ntf_cfg[0] = 0; // Notification OFF by default.
req->body_sensor_loc = 0;

// Send the message
ke_msg_send(req);

app_hrps_config( (uint16_t)0, USE_HRPS_LEVEL_ALERT, GPIO_HRPS_LED_PORT, GPIO_HRPS_LED_PIN);
app_hrp_poll_start(APP_HRPS_POLL_INTERVAL);

}

Device:
CYibin
Offline
Last seen:4 months 1 week ago
工作人员
加入:2017-12-14 02:48
你好,

你好,

有几个问题需要确认:

1. 定时器用的哪个接口?定时周期是多少?将该部分的相关代码完整贴出来。

2. 用 keil debug 模式的时候,观察到死机的位置是?

zhongfushun
Offline
Last seen:1 year 7 months ago
加入:2019-04-24 02:30
1、定时器定义代码如下:

1、定时器定义代码如下:

app.h 添加,见加粗字体

/// APP Task messages
enum APP_MSG
{
APP_MODULE_INIT_CMP_EVT = KE_FIRST_MSG(TASK_APP),

#if BLE_PROX_REPORTER
APP_PXP_TIMER,
#endif //BLE_PROX_REPORTER

#if BLE_BAS_SERVER
APP_BATT_TIMER,
APP_BATT_ALERT_TIMER,
#endif //BLE_BAS_SERVER

#if BLE_HR_SENSOR
APP_HRPS_TIMER,
APP_HRPS_ALERT_TIMER,

#endif

启动定时器代码:

void app_hrp_poll_start(uint16_t poll_timeout)
{
hrp_poll_timeout = poll_timeout;

app_timer_set(APP_HRPS_TIMER, TASK_APP, 10); //first poll in 100 ms
}
定时器事件处理代码:

const struct ke_msg_handler app_hrps_process_handlers[]=
{
{HRPS_CREATE_DB_CFM, (ke_msg_func_t)hrps_create_db_cfm_handler},
{HRPS_MEAS_SEND_CFM , (ke_msg_func_t)hrps_meas_send_cfm_handler},

{HRPS_CFG_INDNTF_IND, (ke_msg_func_t)app_hrps_cfg_indntf_ind},
{APP_HRPS_TIMER, (ke_msg_func_t)app_hrp_timer_handler},
{APP_HRPS_ALERT_TIMER, (ke_msg_func_t)app_hrp_alert_timer_handler},

{HRPS_DISABLE_IND, (ke_msg_func_t)hrps_disable_handler},

};

int app_hrp_timer_handler(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
app_hrp_lvl();//在这里发送心率值

app_timer_set(APP_HRPS_TIMER, dest_id, hrp_poll_timeout);

return (KE_MSG_CONSUMED);
}
2、死机位置是:

void wrap_platform_reset(uint32_t error)
{
ASSERT_WARNING(error==RESET_AFTER_SPOTA_UPDATE); //do not break in case of a SPOTA reset
platform_reset_func(error);
}

以上,谢谢!

zhongfushun
Offline
Last seen:1 year 7 months ago
加入:2019-04-24 02:30
CYibin,你好,问题已解决,系处理HRPS_MEAS

CYibin,你好,问题已解决,系处理HRPS_MEAS_SEND_CFM事件时发了不适合的命令。

CYibin
Offline
Last seen:4 months 1 week ago
工作人员
加入:2017-12-14 02:48
Hi zhongfushun, 好的,感谢分享。

Hi zhongfushun, 好的,感谢分享。

Topic locked