6 posts / 0 new
Last post
Firefox2005
Offline
Last seen:2 weeks 1 day ago
加入:2016-04-13 09:36
Creating a task

Hello,

I implemented a Custom Profile as shown in ble_app_perihperal.
I want to do some things after a write to a Characteristic happened.
因为this I want to create a task and send it a message when the write happens.

void user_custs1_ctrl_wr_ind_handler(ke_msg_id_t const msgid,
struct custs1_val_write_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
//create and send message to own task

}

我如何实现任务吗?

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Firefox,

Hi Firefox,

I dont quite get what you would like to do, you mean create an additional task like APP_TASK or like any other task like the profiles TASK_BASS, TASK_DISS etc ? The whole SDK in based on tasks and delivering messages in different tasks, you can start by taking as an example any of the profiles in order to do that. You can check the _init function that most of the profiles have in order to be created when initialized. Also you will have to declare your TASK in the KE_TASK_TYPE definition.

Thanks MT_dialog

Liang Yun Hao
Offline
Last seen:3 years 2 months ago
加入:2016-03-05 13:38
Hi, Dialog

Hi, Dialog
I would like to implement a task that work periodically(maybe 1 second or longer) to measure ADC value and add it in the advertising data. How could I create a new task and change advertising data? And where the whole system start? Thanks.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Liang Yun Hao,

Hi Liang Yun Hao,

You can use a kernel timer that will trigger some adc measurements, the flow should go like described below:

  • The device has just booted so you can start by taking measurements using the ADC (you can do that either after you ve finished creating your database or if there is no database you can start taking measurements right away, the corresponding callbacks are .app_on_db_init_complete and .app_on_set_dev_config_complete).
  • after the measurements are obtained you can place the measurements in your advertising string, start a kernel timer and start the advertising procedure.
  • The Kernel timer will count down the intervals of your adc measurements, as soon as the kernel timer elapses you will issue a stop advertising command (in the callback function of the timer) in order to stop the advertising (app_easy_gap_advertise_stop() function).
  • That will stop the advertising and will trigger the .app_on_adv_undirect_complete callback or the .app_on_adv_nonconn_complete depending on the kind of the advertising that you have been using. In that callback you can take the next measurements from the ADC, update your advertising string and start advertising again.
  • A few example on this updating the advertising string are, the ble_app_barebone and also you can have a look at the Tutorial 1 - Modifying Advertising Parameters.

Thanks MT_dialog

Liang Yun Hao
Offline
Last seen:3 years 2 months ago
加入:2016-03-05 13:38
Hi, Dialog

Hi, Dialog

What is the database? Does it mean "task"? And where is the advertising start after boot up?(I use the prox_reporter project) Thanks.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Liang Yun Hao,

Hi Liang Yun Hao,

No, the database is how the BLE data are organized in a peripheral device, and has nothing to do with a task. The advertising starts as soon as the database of the device has been created (if there is a database), for example in the proximity reporter the advertise operation starts as soon as the database has been created, which is at the .app_on_db_init_complete callback function hence at the default_app_on_db_init_complete() function.

Thanks MT_dialog