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

how can i receive data from smart phone??

hi, with good advisers in here, i can build the ble_uart_example and download it.

and using the function 'ble_nus_send_string' in 'ble_nus.c', i can send some messages from nrf51822 to smart phone application 'nrf toolbox'.

but this example just sends messages to smart phone. i want to receive some messages from smart phone also. like communication....

i cannot find receive function in nus...

i am using SDK 6.0.0 and s110 softdevice

Parents
  • Hi, as said Anders, with "nus_data_handle", you can see the data that your smartphone has sent.

    In SDK 9, example "ble_app_uart" you can see how redirect this data to your nrf51822.

    static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
    {
         for (uint32_t i = 0; i < length; i++)
         {
            while(app_uart_put(p_data[i]) != NRF_SUCCESS);
         }
        while(app_uart_put('\n') != NRF_SUCCESS);
    }
    

    But if you use sdk v6, softdevice s110, here (section Handling of data received over BLE) you can find how you can do it.

    void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
    {
        for (int i = 0; i < length; i++)
        {
            simple_uart_put(p_data[i]);
        }
        simple_uart_put('\n');
    }
    
Reply
  • Hi, as said Anders, with "nus_data_handle", you can see the data that your smartphone has sent.

    In SDK 9, example "ble_app_uart" you can see how redirect this data to your nrf51822.

    static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
    {
         for (uint32_t i = 0; i < length; i++)
         {
            while(app_uart_put(p_data[i]) != NRF_SUCCESS);
         }
        while(app_uart_put('\n') != NRF_SUCCESS);
    }
    

    But if you use sdk v6, softdevice s110, here (section Handling of data received over BLE) you can find how you can do it.

    void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
    {
        for (int i = 0; i < length; i++)
        {
            simple_uart_put(p_data[i]);
        }
        simple_uart_put('\n');
    }
    
Children
No Data
Related