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

how to received data from peripheral?

Hi, I'm using nRF52832 Software Development Kit, PCA10040, S132.

I am trying to test ble_app_blinky_c.

I have problem with received data from peripheral which is my own BLE device.

First of all, I tested blinky central and peripheral with two nordic borad.

When I pressed peripheral button 1, breakpoint stop at "case BLE_GATTC_EVT_HVX:"

void ble_lbs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
    if ((p_context == NULL) || (p_ble_evt == NULL))
    {
        return;
    }

    ble_lbs_c_t * p_ble_lbs_c = (ble_lbs_c_t *)p_context;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP:
            on_hvx(p_ble_lbs_c, p_ble_evt);
            break;

        case BLE_GATTC_EVT_HVX:
            on_hvx(p_ble_lbs_c, p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnected(p_ble_lbs_c, p_ble_evt);
            break;

        default:
            break;
    }
}

 

In ble_app_blinky_c, I found that the change in the charteristic status of the peripheral was received from on_hvx() of BLE_GATTC_EVT_HVX.

All I want to do is just read the data from the bl device and record it on the terminal.

To do this, can I use BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP?

Is this the right way to add cases above code like this, 

Switch (p_ble_evt->header.evt_id)
{
Case BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP:
on_hvx (p_ble_lbs_c, p_ble_evt);
break;

...

or... Should I create a new function in main()?

 

* I think it might be difficult to understand the intent of my question because I didn't fully understand the example code.
My key problem is that I don't know where the data from my device is located in the example.
(or I don't know how to add the code.)

Best Regards,

Lyrics

Parents
  • lyrics said:
    Thank you very much for your quick reply.

    No problem at all, I am happy to help!

    lyrics said:
    I understood the basics.
    And I will study again with 'ble_app_uart_c'.

    Great, just let me know if you should have any further questions on this!

    lyrics said:
    Does the example ble_app_blinky_c handler only the events caused by the button?

    The button LED notification service is made to send a notification if a button is pressed in order to set a LED, as such, the connected device will only receive button and LED information through this service - since it is its only contents.
    I am not sure if this is what you were asking about. As you can see from the ble_app_blinky_c lbs event handler, it handles all ( both ) of the available LBS events.

    lyrics said:
    In addition, can't we use 'BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP' to bring the charterical values?

    That depends, which data exactly are you interested in seeing?
    If you would like to see the contents of a received notification, you should use the contents of the BLE_GATTC_EVT_HVX event instead.

    Best regards,
    Karl

Reply
  • lyrics said:
    Thank you very much for your quick reply.

    No problem at all, I am happy to help!

    lyrics said:
    I understood the basics.
    And I will study again with 'ble_app_uart_c'.

    Great, just let me know if you should have any further questions on this!

    lyrics said:
    Does the example ble_app_blinky_c handler only the events caused by the button?

    The button LED notification service is made to send a notification if a button is pressed in order to set a LED, as such, the connected device will only receive button and LED information through this service - since it is its only contents.
    I am not sure if this is what you were asking about. As you can see from the ble_app_blinky_c lbs event handler, it handles all ( both ) of the available LBS events.

    lyrics said:
    In addition, can't we use 'BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP' to bring the charterical values?

    That depends, which data exactly are you interested in seeing?
    If you would like to see the contents of a received notification, you should use the contents of the BLE_GATTC_EVT_HVX event instead.

    Best regards,
    Karl

Children
No Data
Related