I'm using the Custom service example as by base. Now this was really itching me to not know the reason which causes it. I'm giving an "if-else" condition inside a "switch-case" condition as shown below inside the custom ble service handler as follows. In the BLE_CUS_EVT_NOTIFICATION_ENABLED case to be specific and inside it the if condition checking for the received_data variable :
received_data is the variable which stores the data written to the service. It is a global variable so I think scope isn't the issue here. When I see my "received_data" in the debug terminal it shows that the value is 1 but it never enters the "if(received_data==1)" condition.
But if the same thing is done in ble event handler callback function then it's working fine . In the BLE_GATTS_EVT_WRITE event to specific and if condition works here fine :
what's the reason that if works in on ble event handler and not in the custom service event handler. Aren't if-else cases applicable anywhere in the code?