跳到主要内容

关于堆栈通过自己的数据和数据重置

5年前

关于堆栈通过自己的数据和数据重置

张贴了Liuluan002.0分 2回复
0旋转

嗨对话框,

我现在使用堆栈来做广告,the period of time I have set is 2.5s by using the timer . I am using the "current_role" in my program for controlling the role switching in the program"app_task.c" and "app.c". However when it is running for 25 times for the role switching, it will reset the whole program, and lost all the things put into the ram before, could you please help with this issue?

以下是app_task.c:的某些部分:
extern volatile uint8_t current_role;

int app_switch_role(ke_msg_id_t msgid,void * param,ke_task_id_t dest_id,ke_task_id_t src_id)
{
app_gapm_reset_op();

return(ke_msg_consumed);
}

static const struct ke_msg_handler app_gap_process_handlers [] =
{
{gapm_device_ready_ind,(ke_msg_func_t)gapm_device_ready_ind_handler},
{gapm_cmp_evt,(ke_msg_func_t)gapm_cmp_evt_handler},
{gapc_cmp_evt,(ke_msg_func_t)gapc_cmp_evt_handler},
{gapc_connection_req_ind,(ke_msg_func_t)gapc_connection_req_ind_handler},
{gapc_disconnect_ind,(ke_msg_func_t)gapc_disconnect_ind_handler},
{app_module_init_cmp_evt,(ke_msg_func_t)app_module_init_cmp_evt_handler},
{gapm_adv_report_ind,(ke_msg_func_t)gapm_adv_report_ind_handler},

{app_dynamic_addata,(ke_msg_func_t)app_update_add_data},
{app_switch_role_timer,(ke_msg_func_t)app_switch_role},
};

int gapm_cmp_evt_handler(ke_msg_id_t const msgid,
struct gapm_cmp_evt const * param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
开关(Param->操作)
{
//reset completed
案例GAPM_RESET:
{
if(param-> status!= gap_err_no_error)
{
assert_err(0);// 意外的错误
}
别的
{
//设置设备配置
app_easy_gap_dev_configure();

#if debug_log33.
printf_string(“\ r \ n gapm_reset \ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一
}
}
休息;

//设备配置更新
CASE GAPM_SET_DEV_CONFIG:
{
if(param-> status!= gap_err_no_error)
{
assert_err(0);// 意外的错误

// niklas.
#if debug_log33.
printf_string(“\ r \ nerror253 \ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一
}

别的
{

if(1 == current_role)
{
#if debug_log2.
printf_string(“\ r \ nadv1”);
printf_byte(position1);
printf_string(“\ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一
Record3();
Execute_callback_void(app_on_set_dev_config_complete);
position1 ++;
}

别的
{

#if debug_log2.
printf_string(“\ r \ nadv2”);
printf_byte(position1);
printf_string(“\ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一
Record3();
Execute_callback_void(app_on_set_dev_config_complete);
position1 ++;
}
ke_timer_set(app_switch_role_timer,task_app,250);// 100 * 10ms

}
}
休息;

//广告完成
case GAPM_ADV_NON_CONN:
案例GAPM_ADV_UNDIRECT:
{
#if debug_log33.
printf_string(“\ r \ n gapm_adv_undirect \ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一

Execute_callback_param(app_on_adv_undirect_complete,param->状态);

}
休息;

//定向广告完成
案例Gapm_adv_direct:
{
#if debug_log33.
printf_string(“\ r \ n gapm_adv_direct \ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一

Execute_callback_param(app_on_adv_direct_complete,param->状态);
}
休息;

案例Gapm_scan_active:
案例GAPM_SCAN_PASSIVE:
{
#if debug_log33.
printf_string(“\ r \ n gapm_scan_passive:\ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一

Execute_callback_void(app_on_scanning_completed);
}
休息;

案例GAPM_CONNECTION_DIRECT:
if(param-> status == gap_err_canceled)
{

#if debug_log33.
printf_string(“\ r \ n gapm_connection_direct:\ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一

Execute_callback_void(app_on_connect_failed);
}
休息;

案例GAPM_CANCEL:
{
#if debug_log33.
printf_string(“\ r \ n gapm_cancel:\ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一

if(param-> status!= gap_err_no_error)
{
assert_err(0);// 意外的错误
}
if (app_process_catch_rest_cb!=NULL)
{
app_process_catch_rest_cb(msgid,param,dest_id,src_id);
}
}
休息;

默认:
if (app_process_catch_rest_cb!=NULL)
{
#if debug_log33.
printf_string(“\ r \ ndefault:\ r \ n”);
UART2_INIT(UART_BAUDRATE_115K2,3);
#万一

app_process_catch_rest_cb(msgid,param,dest_id,src_id);

}
休息;
}

return(ke_msg_consumed);
}

以下是App.C程序的某部分:

volatile uint8_t current_role = 1;//

static struct stable gapm_set_dev_config_cmd * app_easy_gap_dev_config_create_msg(void)
{
//分配用于GAP的消息
if(set_dev_config_cmd == null)
{
struct gapm_set_dev_config_cmd * cmd;
cmd = app_gapm_configure_msg_create();
set_dev_config_cmd = cmd;

if(user_config)
{
cmd->操作= gapm_set_dev_config;

if(1 == current_role)
{
cmd->角色= user_gapm_conf.role;
current_role = 0;
}

别的
{
cmd->角色= user_gapm_conf.role;
current_role = 1;
}

cmd-> seepent = user_gapm_conf.appearance;
cmd-> sepent_write_perm = user_gapm_conf.appearance_write_perm;
cmd-> name_write_perm = user_gapm_conf.name_write_perm;
cmd-> max_mtu = user_gapm_conf.max_mtu;
cmd-> con_intv_min = user_gapm_conf.con_intv_min;
cmd-> con_intv_max = user_gapm_conf.con_intv_max;
cmd-> con_latency = user_gapm_conf.con_latency;
cmd-> supmen_to = user_gapm_conf.superv_to;
cmd->标志= user_gapm_conf.flags;
memcpy(cmd-> irk.key,user_gapm_conf.irk,key_len);
}
别的

memcpy((void *)cmd,(void *)和default_set_dev_config,sizeof(struct gapm_set_dev_config_cmd));

}
返回(set_dev_config_cmd);
}

5年前

Liuluan002. 0分

能否请你帮忙?在我完成了27次的角色切换后,系统会再次初始一切,能帮到这个问题吗?

5年前

mt_dialog. -30点

嗨Liuluan002,

I suppose that when the code executes the program forces a reset through the platform_reset function. I would say that perhaps there is a memory leak somewhere and that forces the program to go to a platform_reset. You can check this by overriding the platform reset function in the jump_table with a custom function and try to catch it with a break point with the sleep disabled. Just place a while(1) loop into your custom function.

谢谢mt_dialog.