This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Particle sensor interface with BLE

HI ,

I need to interface particle measurement sensor with nrf52832. I am using S132 softdevice and SDK 11.0 for my application. I need to send commands to sensor to take action(like auto send,auto stop,read particle, set adjustment,get adjustment...). And I need to send those datas to mobile app via BLE through notification mode.I can able to send commands and get response from sensor. I cannot able to send commands to uart when i am in "void on_write(ble_lbs_t * p_lbs, ble_evt_t * p_ble_evt)" this event. Can anyone guide me to implement.

Parents
  • Ok, then it would be easiest to implement this functionality in the led_write_handler() function. You can find the function in main.c. This is a function for handling write events to the LED characteristic. You can see this function being called in the on_write() function like this:

    if ((p_evt_write->handle == p_lbs->led_char_handles.value_handle) &&
        (p_evt_write->len == 1) &&
        (p_lbs->led_write_handler != NULL))
    {
        p_lbs->led_write_handler(p_ble_evt->evt.gap_evt.conn_handle, p_lbs, p_evt_write->data[0]);
    }
    

    Then in the led_write_handler() you can use the uint8_t led_state indicate what commands you want to send, using a switch-case. A start could be something like this:

    static void led_write_handler(uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t led_state)
    {
        switch (led_state)
        {
            case AUTO_SEND:
                
                break;
            
            case AUTO_STOP:
                
                break;        
    
            default:
                
                break;
        }
    }
    

    For each switch-statement you can send data over the uart using the app_uart_put() function.

Reply
  • Ok, then it would be easiest to implement this functionality in the led_write_handler() function. You can find the function in main.c. This is a function for handling write events to the LED characteristic. You can see this function being called in the on_write() function like this:

    if ((p_evt_write->handle == p_lbs->led_char_handles.value_handle) &&
        (p_evt_write->len == 1) &&
        (p_lbs->led_write_handler != NULL))
    {
        p_lbs->led_write_handler(p_ble_evt->evt.gap_evt.conn_handle, p_lbs, p_evt_write->data[0]);
    }
    

    Then in the led_write_handler() you can use the uint8_t led_state indicate what commands you want to send, using a switch-case. A start could be something like this:

    static void led_write_handler(uint16_t conn_handle, ble_lbs_t * p_lbs, uint8_t led_state)
    {
        switch (led_state)
        {
            case AUTO_SEND:
                
                break;
            
            case AUTO_STOP:
                
                break;        
    
            default:
                
                break;
        }
    }
    

    For each switch-statement you can send data over the uart using the app_uart_put() function.

Children
No Data
Related