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

why the INVALID_STATE error code appear???And how to solve??

Hi all,

In my keyboard application, I found sometimes it return the INVALID_STATE error code , when called keys_send() , once this error code appeared, no others return by keys_send() again.
But the connection state is always CONNECTED, both in device side and the host side (it displays CONNECTED in the host side).
I want to know:

1.why will it happen while CONNECTED? 2.what could I do to excute the keys_send() correctly?

Thanks a lot.

Jim

  • The stable way to reappearance is : 1.Set the KB into advertising by pressing the bond button to delete the bond info; 2.Pair the iPad successfully and any key could be received correctly; 3.Re-power on the KB and the function is OK; 4.When KB standby, ignore the KB from iPad side but keep the KB side no change, and the KB will go into advertising again, then re-pair with the iPad, the function is OK, too; 5.Re-power on the KB and found it was CONNECTED in iPad side but no key function, and check the err-code was INVALID_STATE, so the function keys_send() not excute correctly;

    Maybe something loaded not correctly when power on??Could you guide how to disappear the INVALID_STATE?

    BTW, the SDK version is 4.4.1 and SD is 5.2.1 while silicon is C0.

    Thanks.

  • After use ble_debug_assert_handler() to locate the error source and the result is : file_name is app_timer.c , line_num is 0x154 , error_code is 0x00000004

  • That would seem to indicate that you are running out of memory. Since it is occurring on a operation on a timer rather than creation of a timer, you need to increase your timer queue size by changing the define APP_TIMER_OP_QUEUE_SIZE to be larger.

  • what's the range of APP_TIMER_OP_QUEUE_SIZE ? And what's the relation between APP_TIMER_OP_QUEUE_SIZE and APP_TIMER_MAX_TIMERS ?

    Thanks.

  • I believe APP_TIMER_OP_QUEUE_SIZE is only limited by the amount of free RAM you have to store the queue. I don't know if there really is a direct relationship between the number of timers vs the size of the queue. It really is going to depend on how your application is designed. If you only have a couple of timer operations going at the same time you may get away with a smaller queue size than if you are performing operations on all of your timers nearly simultaneously.

    Take a look at APP_TIMER_INIT in app_timer.h, and spend some time looking at app_timer.c if you want to get more familiar with how the timers work.

Related