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

How to turn on LED base on message sent by ble_app_uart?

For example I want to turn on LED whenever I send 'a' text from my phone. How could I do cause I do not know where a message is stored. I am using ble_app_uart example 

Parents Reply Children
  • Hello again,

    Xiam said:
    Can I ask you another question?

    Of course! it is no problem at all.
    For future reference, I would however recommend that you open a new ticket for a new question, but seeing how this is closely related to your original ticket, this is fine for now.

    Xiam said:
    How can I collecting data from board over UART? Cause I connected LED to a button, then whenever I press a button I want a message "LED ON" is sent to my phone, still using ble app uart example

    The sending of the UART data is done in the uart_event_handler function of the example.
    If the APP_UART_DATA_READY event is generated, that means that data has been received over UART, and that this data is located in the UART RX buffer. This data is then retrieved from the UART RX buffer, and queued for sending over BLE using ble_nus_data_send.

    To achieve the functionality you describe, you may copy the contents of the APP_UART_DATA_READY case into your button-press handler, remove the call to app_uart_get (since you do not need to retrieve anything from the UART RX buffer), and substitute it and it processing with a c string containing "LED ON".
    Then, this will be passed to ble_nus_data_send and queued for sending.

    Try this, and let me know if you are able to send the "LED ON" string to your mobile phone using this method.

    Best regards,
    Karl

Related