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

about service change can't receive BLE_GATTS_EVT_WRITE

nrf52832     SDK14.2       s132_nrf52_5.0.0_softdevice     PCA10040       ble_app_hids_keyboard  

I modify the project : 

two  service :  one  is   hid   another  is  different  hid_1 

press button 2  init  hid

presss button 3  init  hid_1

connect  the  android  phone , press button2   reset ,and ,init  hid;  press button3   reset  ,and, init  hid_1, reconnect  the phone,

turn  off and on the bluetooth(android  phone),but I can‘t receive   BLE_GATTS_EVT_WRITE(gcm_ble_evt_handler),  I  enable  the  NRF_SDH_BLE_SERVICE_CHANGED

I  can’t  know the reason,  but  SDK15.2   it  succeed,  why?   How  can  i do?

  • Hi,Simonr,the last replay can't see reply ,so i reply you here. 

    1 sorry,I'm wrong, forgive me, the  gscm_service_changed_ind_send  function don't  return  NRF_ERROR_NOT_SUPPORTED ,just always

    return NRF_ERROR_INVALID_STATE ,I copy the wrong information and i don't realize it.sorry!

    2  the  BLE_HIDS_ENABLED  macro is set to 1 alreadly.

    3  the  NRF_SDH_BLE_SERVICE_CHANGED  is  set to 1 alreadly.

    4  the ios phone works well by  SDK14.2,just  android phone don't work.

    5  the  question is  reappear  easily, just  do  as  i operated:  SDK14.2

    Two  mode:  'FI' and 'DI',

    FI' mode  can  be  entered  by  pressing button2.  'FI' mode  init  hid which has  keyboard and mouse descriptor.   

    'DI’ mode can  be  entered  by pressing button3. 'DI' mode init hid_1 which just has  keyboard.

    Switching different mode  between 'FI' and 'DI' by pressing button2 and button3.

    for  example ,the  first mode is 'FI', it can works well(namely,can typing.

    Then  pressing  button3,  it will reset ,  and  enter in  'DI'  mode. At the same time  it will  reconnect  the  android phone . 

    Then  turn  off  and  on  the  android phone's bluetooth, it  will  reconnet  again,but the 'DI'  mode can't  work(that  can't  typing).

    It  is  easy  to reappear.  I beg your pardon  for  my fault that  copy  the wrong information . I hope  you continuly

    reply me.  Thank you.

  • Ok, so the issue is just in Android, and you're experiencing an NRF_ERROR_INVALID_STATE return value, am I right? When INVALID_STATE returns from gscm_service_changed_ind_send it means "Service changed cannot be indicated to this peer because the peer has not subscribed to it." This could be an issue with your service initialization. Could you show me a snippet of code of how you've done the service init? 

    It's also odd that it happens just on Android. What app are you using on your Android to communicate with the nRF52832? Have you tested this on multiple Android phones, and multiple versions of Android? Please state what phone and Android versions you have tested, and maybe we'll find some bugs on the Android side. 

    Best regards,

    Simon

  • 1  You are right ,i'am experiencing an NRF_ERROR_INVALID_STATE ,but  SDK15.2  sometimes return  NRF_ERROR_INVALID_STATE as  well,but  then  SDK15.2 can receive BLE_GATTS_EVT_WRITE(gcm_ble_evt_handler) ,and the mode works well.   
    2  I  just  use  the  android   system  bluetooth . I  test  multiple  androdi phone,like  Huawei ,Xiaomi ,and so on. I  often  use   Xiaomi 8 and the  android  version is 9.

     

  • In any case, the best course of action would be to resolve this error. Could you please share a snippet of code to show how you do the service initialization. Are all the Android phones you've tested been Android version 9? There have been a few issues lately with people struggling with that exact version. Also, do you get the NRF_ERROR_INVALID_STATE on iOS devices, or does this just occur when using Android devices?

    Best regards,

    Simon

  • can  i  give  you  the  project . How  can  i  give you?

Related