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

  • 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;
        }
    }
    
  • actually i tried this example but adding into the sdk9 and in the MCP terminal i can bale to see initially button state invalid(0xff) and once i press the button it is showing button is pressed and reamins like in the same state but it is not like what you saw o and1 whreas i tried in the sdk 8it is asking me something core.m0.h file

  • 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.

  • Could you please show me your MCP terminla are you tested in the android MCP or PC MCP because PC mcp always showing me no response from emulator and i would like to know know whether you see 0 and 1 for button push or instead 0 and 1 you saw button pressed and released in the MCP please give me those information because its very difficult to find the issue int he sdk i followaed exactly same in te gtihub procedure but nto succed so then i did copy and replace approch in template it gets ccompiled but button state alwyas showing button released

  • It looks like this in MCP for Android. Not the Button pressed and released. The state toggles on both button push and release.

    MCP for Android

    It looks like this in MCP for PC. Not that the value field is '0' and '1'. The state toggles on both button push and release. MCP

    Are you using the newest MCP versions?

Related