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

BLE service with multiple characteristics(client/switch and bulb/server)

I am new to C programming and BLE in general.I am trying to create a service with two characteristics,(the application simply is a modification of BLE bulb and switch). How the original application work is, on the client/switch if you push button 1, it turns on the LED 3 on the server/bulb, and when you push button 2 it turns it off.So it is only one service and one characteristic. The client acts as central and server acts as a peripheral.

What I want is to add another characteristic so that If I push button 3 on the client to turn on  LED 4 on the server .(So in short button 1 will turn LED 3 on and button 3 will turn LED4 on).So I added additional characteristic on both server and client, but the problem is I don't know how to check/distinguish whether the incoming request  on the server is which characteristic.

Question

1. How do I inspect the incoming request whether is coming from characteristic 1 or 2 in the server's main.c  led_write_handler function?

Here is the code

static void led_write_handler(uint16_t conn_handle, ble_led_service_t * p_led_service, uint8_t led_state)
{
   //HERE I WANT TO DO IF THE REQUEST IS CHARACTERSIC 1 TURN LED3 AND IF 2 TURN LED 4
     //NRF_LOG_INFO("led handled %d", p_led_service->led_3_char_handles);
    if (led_state)
    {
        bsp_board_led_on(LIGHTBULB_LED3);
        NRF_LOG_INFO("Received LED ON!");
    }
    else
    {
        bsp_board_led_off(LIGHTBULB_LED3);
        NRF_LOG_INFO("Received LED OFF!");
    }
}

Related