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

sd_ble_gatts_hvx returns NRF_ERROR_INVALID_STATE (0x00000008), what could be the problem?

Hello, when invoking sd_ble_gatts_hvx, it returned NRF_ERROR_INVALID_STATE (0x00000008), I wanna know what are the list of possible errors, here are a list I made:

  1. CCCD handle not properly set. I'm working on it, and it is getting increasingly unlikely that this is the probelm (I'm using android device, and my code doesn't appear to be missing steps when comparing to nrf tool box)
  2. Wrong gatt connection handle, this is unlikely, I looked up the corresponding handle, it is 0, instead of the initial value (0xFFFFFFFF if I recall it correctly)
  3. CCCD handle set, but the wrong one. Again, highly unlikely since my code worked before, and it properly identified the right chara. using the UUID, one thing I found to be kind of funny is that all characteristics' CCCD handle appear to have the same UUID, "00002902-0000-1000-8000-00805f9b34fb", which I personally believe to be less than prudent.
  4. CCCD handle not REALLY set, due to reasons in this question, again I'm working on it, and again, my code is almost the same as nrf tool box, yet allegedly tool box works, mine doesn't, I actually couldn't tried tool box on my custom board, because the tool box is too specialized.

Then there's also the possibility of a flimsy porting. You see, I migrated my code from nrf51422 S110 to nrf52840 S140, and to be honest I'm not sure the whole effort was fool-proof. So is it possible that a mistake somewhere else far, far away caused the whole "NRF_ERROR_INVALID_STATE" error?

So, my questions:

Did I miss anything?

What about the possibility of a faulty migration, that I failed to go through the proper initialization steps, which caused this problem? I think it's unlikely, because if that were the case, I shouldn't be able to call hvx at all?

Cheers?

Related