This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Howto Processes Written Characteristics in BDS project

Anyone have experience with the proper way to process written/updated custom characteristics in the APP(main) in a Bluetooth Developer Studio BDS generated code project?

I am working on a nRF52840 dev kit with SDK v14.0 and my BDS has plugin v1.3.0 sdk14 using a custom service with a custom characteristic with generated output to my experimental/bluetoothds_template project.

When on the Phone(central) and i write to a characteristic, on the ble device(peripheral) I get the following logging from the generated code <info> Bluetooth_IF: YY_XX evt WRITE. Following the ble event in the code, the final call is in the file service_if.c in on_YY_evt() in which the case statement has that logging line.

I don't want to put my processing new user data function call right there because I believe this is an interrupt call from the SoftDevice to update the characteristic. My function is intensive and should be run from the APP(main).

The examples I find about BDS all show how to Send Char to the Phone, not process Char Writes from the Phone.

Anyone have any advice? Thanks

Parents
  • Hi,

    All the on_ble_evt() functions runs in interrupt priority APP_IRQ_PRIORITY_LOW. So you can call sd_() functions from this priority level. But you should not call things in a way so that it's prevents it from doing its other tasks, but short calls to other sd_ functions is fine.

    If you are in fact doing very intensive processing you should do this from main context. In order to transfer execution from the interrupt context to the main context you can then use the scheduler. We have an old tutorial here and this post that might be useful.

    Also note that the aim of BDS is fast prototyping. BDS plugin was updated for SDK 14, but it's machine generated code. You might want to learn how to write your custom services. See this Custom Service Tutorial on GitHub that is using the ble_app_template for more on that.

Reply
  • Hi,

    All the on_ble_evt() functions runs in interrupt priority APP_IRQ_PRIORITY_LOW. So you can call sd_() functions from this priority level. But you should not call things in a way so that it's prevents it from doing its other tasks, but short calls to other sd_ functions is fine.

    If you are in fact doing very intensive processing you should do this from main context. In order to transfer execution from the interrupt context to the main context you can then use the scheduler. We have an old tutorial here and this post that might be useful.

    Also note that the aim of BDS is fast prototyping. BDS plugin was updated for SDK 14, but it's machine generated code. You might want to learn how to write your custom services. See this Custom Service Tutorial on GitHub that is using the ble_app_template for more on that.

Children
Related