i2c+timer+work keeps getting -22 or -128 and keep crashing

Hi,

I am using i2c to get sensor data. At first the client write a value to the service. In the service on write callback it trigger's a timer, in the timer, it submit a work. In the work handler, it reads data and then notify the client.

but the notify keeps returning -22 or -128, the bluetooth is connected, and the notify data is correct.

When the client disconnect, the chip crashed and auto restarted.

How should I fix this?

Thanks,

Parents
  • Hi 

    Why do you use a timer to trigger the work item, do you need to add a delay to the sensor readout? 

    Is the notification ever successful, or will it always return an error? 

    Have you tried to debug the call to gatt_notify(..) so you can see exactly where in the code the error is returned? 
    That can usually provide more details than the error code alone. 

    Would you be able to share the code showing how the sensor is read and the notification sent? 

    Best regards
    Torbjørn

  • To be more specific, the current issue is: after the 1st connect, the sensor data notify got -22. then the client disconnect, disconnect working fine. the client connect again, the sensor data notify successfully. but when client disconnect again, the chip crashed and auto restart. 

    In a summary, 1st connect, can't notify, but can disconnect. 2nd and later, can notify, but disconnect crash the chip.

    I set the CONFIG_BT_LOG_LEVEL_DBG = y, but no any errors info.

    Thanks,

  • hey I figured the reason of the 1st connect can't notify issue. Sorry somehow the client didn't enable notification for the 1st time connect. so its not the chip issue. so the only issue now is why crash after disconnect. if you may know please advise some possibilities for me to dig in. Thanks

Reply Children
No Data
Related