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

ble_lbs buton service not getting ececuted in SDK 9

image description(/attachment/464b945b7dfd5bcb858b14aa400f0933)

Hello everyone,

I am using the ble_lbs example when i checked in the Master control panel initially it is showing button released state and after i press the button it is changed to button pressed state after that i remain int he button pressed state it is not going back to button release state but i would like to make to create this fucntion whenever i press the button it goes to button pressed mode and back to button release mode and also whenever i press the button it has to send notification to the central about the button pressed state please give me some ideas how to implement or modify those fucntions in the ble_lbs any help would be greatly appreciated

Thank you

Parents
  • It is not clear to me exactly what you mean. I have tried this example with SDK 8 and SD 8 as per the readme file. When I push Button 2 the value in MCP is changed to '1' and when I release the button the value reverts back to '0'. In my mind this reflects the state of the button very well. Furthermore, the example is using notifications to notify MCP (or a central) of the button push. Am I correct in assuming that you would like to make the value toggle on each button press? I.e. that each time you push the button the value toggles, but every release of the button does nothing?

    If so you can change the 'button_event_handler()' in main.c to something like this:

    static void button_event_handler(uint8_t pin_no, uint8_t button_action)
    {
        uint32_t err_code;
        static bool button_toggle = true; // Variable used to hold state of value.
        
        switch (pin_no)
        {
            case LEDBUTTON_BUTTON_PIN_NO:
                if(button_action == APP_BUTTON_PUSH) // Check for button push. Disregard button releases.
                {
                    err_code = ble_lbs_on_button_change(&m_lbs, button_toggle); // Notify central of button state change.
                    if (err_code != NRF_SUCCESS &&
                        err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
                        err_code != NRF_ERROR_INVALID_STATE)
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                    button_toggle =! button_toggle; // Toggle state
                }
                break;
    
            default:
                APP_ERROR_HANDLER(pin_no);
                break;
        }
    }
    
  • You should always use the SDK and Softdevice that is specified in the readme files. Otherwise you cannot expect it to work out of the box. Regarding the core.m0.h file I suspect you mean core_cm0.h and there have been asked several questions about this file already.

Reply Children
No Data
Related