4 posts / 0 new
Last post
prasanth.velliy...
Offline
Last seen:1 year 11 months ago
Joined:2016-02-18 12:18
app_timer_set

In DSPS device project

step 1:
extern const struct ke_msg_handler user_spss_process_handlers[]=
{
{SPS_SERVER_CREATE_DB_CFM, (ke_msg_func_t)user_sps_create_db_cfm_handler},
{SPS_SERVER_ENABLE_CFM, (ke_msg_func_t)user_sps_server_enable_cfm_handler},
{SPS_SERVER_DATA_TX_CFM, (ke_msg_func_t)user_sps_server_data_tx_cfm_handler},
{SPS_SERVER_DATA_RX_IND, (ke_msg_func_t)user_sps_server_data_rx_ind_handler},
{SPS_SERVER_TX_FLOW_CTRL_IND, (ke_msg_func_t)user_sps_server_tx_flow_ctrl_ind_handler},
{SPS_SERVER_ERROR_IND, (ke_msg_func_t)user_sps_server_error_ind_handler},
{APP_SAMPLE128_TIMER, (ke_msg_func_t)sample128_timer_handler},
};

step 2:
int sample128_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); // Declaration

step 3:
int sample128_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) // Definition
{

app_timer_set(APP_SAMPLE128_TIMER,TASK_APP,600);

return (KE_MSG_CONSUMED);
}

step 4 : timer call

void user_ble_pull (bool init, bool success)
{
if(init)
{
app_timer_set(APP_SAMPLE128_TIMER,TASK_APP,600);
user_send_ble_data(p_data, length);
}
else {
user_send_ble_data(p_data, length);
}
}

PROBLEM :
代码总是站在这里…/ * * hardfault_handeler**/....
if ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
__asm("BKPT #0\n");
else
while(1);

what could be the problem...am i doing it right way ??

Device:
MT_dialog
Offline
Last seen:3 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi prasanth,

Hi prasanth,

I suppose that you ve declared theAPP_SAMPLE128_TIMER as a message in the message API for the SPS_SERVER, although i cant understand your code. From where you are triggering the timer ? When the timer elapses it will execute the sample128_timer_handler() not the user_ble_pull in order to pull data in a specific interval. It seems that the error that you get is because you keep allocating the same timer over and over if you invoke the user_ble_pull form somewhere in your code.

Just place theapp_timer_set(APP_SAMPLE128_TIMER,TASK_APP,600); at the on_connection callback, remove the custom user_ble_pull and place the code you want in the timer handler function.

Thanks MT_dialog

prasanth.velliy...
Offline
Last seen:1 year 11 months ago
Joined:2016-02-18 12:18
void user_on_connection(uint8

void user_on_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param)
{
default_app_on_connection(connection_idx, param);
user_gattc_exc_mtu_cmd(connection_idx);
app_easy_gap_param_update_start(connection_idx);

app_timer_set(APP_SAMPLE128_TIMER,TASK_APP,100); // Timer_handler call function

arch_printf("Device connected\r\n");
}

int sample128_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) // Definition
{
uint16_t length;
uint8_t vp[8] = "WELCOME";
struct sps_server_data_tx_req * req = KE_MSG_ALLOC_DYN(SPS_SERVER_DATA_TX_REQ,
TASK_SPS_SERVER, TASK_APP, sps_server_data_tx_req, length);

req->length = length;
memcpy(&req->data[0], vp, sizeof(vp));

ke_msg_send(req);
app_easy_timer_cancel_all();

return (KE_MSG_CONSUMED);
}

am i using the - app_timer_set(APP_SAMPLE128_TIMER,TASK_APP,100); in correct place ?? still i am facing issues,i used breakpoints inside int sample128_timer_handler - didn't seem handler is executing...could you please give me example working app_timer_set - code in DSPS

MT_dialog
Offline
Last seen:3 months 1 week ago
Staff
Joined:2015-06-08 11:34
Hi prasanth,

Hi prasanth,

1. Add the APP_SAMPLE128_TIMER as a message in the enum messages of the SPS_SERVER task.

2. Add the {APP_SAMPLE128_TIMER, (ke_msg_func_t)sample128_timer_handler}, in the user_spss_process_handlers[]

3. Add the below snippet as a handler for your timer.

int sample128_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) // Definition
{

arch_set_pxact_gpio();
app_timer_set(APP_SAMPLE128_TIMER,TASK_APP,100);
user_send_ble_data("FELLOW", 6);

return (KE_MSG_CONSUMED);
}

4. Add the app_timer_set(APP_SAMPLE128_TIMER,TASK_APP,600); to start counting upon connection (triiggers the timer to start counting upon connection).

When you establish a connection with a device, the timer will trigger and you will start sending notifications.

Thanks MT_dialog