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

Smart Remote 3, keyboard keys are not received on Android TV when disabling power management

Hi all, 

I get a really weird issue developing on the smart remote 3 project.

I work with my own hardware design, and as I want a specific behaviour I disabled power_management go to sys off when remote is disconnecting or when the advertising stops.

Once I have done this, when testing on Android TV (Nvidia Shied alike), I can connect correctly to it, I get voice and consumer keys but Keyboard keys are not always received (sometimes I get all of them (20% of times), or none (80%)). It seems that sometimes I connect alright and sometimes I don't. It works perfectly on Windows and on smartphones.

Can you reproduce this issue? Do you have any idea how to solve this issue?

Thanks in advance

Parents
  • Hello,

    (sometimes I get all of them (20% of times), or none (80%)

     

     Ok, so that would suggest that there is not something wrong in the way that you set up the characteristic for the HID keyboard. 

    I didn't quite understand the shutdown things you explained. You disable all shutdown, so that nrf_pwr_mgmt_shutdown() is never called? Is that correct?

    Can you check one thing? When you press a button (keyboard key), and it doesn't go through, can you find the sd_ble_gatts_hvx() that is called when you press the key? What does it return?

    Best regards,

    Edvin

  • Hello Edvin,

    Yes I mentionned that I disabled all  nrf_pwr_mgmt_shutdown() and it seems that it's at that point the issue appeared.

    When I have the issue and pressing a button (keyboard), sd_ble_gatts_hvx() still returns NRF_SUCCESS.

    Best regards,

    Sylvain

  • Can you try to disable them one at the time to see if it is one of them that causes the keyboard buttons to fail? If so, which one that causes the issue to appear?

  • Hi Sylvain,

    after removing the nrf_pwr_mgmt_shutdown() calls, have you added additional logic to for example start automatically advertising when a button is pressed and there is no connection?

    When the problem occurs, have there been any cycles of disconnect+connect before the connection is established again? I wonder if it's possible that the host has some lingering state information causing trouble.

    You can look at the M_COMS_BLE_EVT_CONN_UPDATE and M_COMS_BLE_EVT_CONN_SECURED log printouts and the timestamp of these logs (relative to M_COMS_BLE_EVT_CONNECTED event printout) to see if the host behavior is consistent between the working and non-working cases. For example, normally the Host will enable encryption immediately after connecting to a paired remote, but the remote will request encryption if the Host hasn't enabled it within CONFIG_ENC_REQ_DELAY ms after reconnection (ref. m_coms_ble.c::s_encryption_timer)

    Also, have you looked at the log output from the Android side? (https://developer.android.com/studio/command-line/logcat) Perhaps comparing the logcat output from a working and failing case could yield some clues.

    Best regards,

    Audun

  • Hi Edvin, Audun,

    I did a lot more experimentation I know have a better diagnostic of the issue.

    It's the nrf_pwr_mgmt_shutdown() from disconnected event that when he is withdrawn causes the issue.

    I did add  some code to start advertising if not connected when pressing a key?

    I do have multiple M_COMS_BLE_EVT_CONN_UPDATE on android TV which I do not have on other devices.

    Here's what I can see :

    - On first pairing with the box, everything works fine, I have all the keys and everything. If I disconnect by going out of range for example or by rebooting the remote, I still have everything OK.

    - The issue appears when I reboot the box. Then I reconnect alright but I do not get the keyboard keys

    - If I have everything ok, and I reboot the box AND the remote at the same time. When I reconnect everything is alright. This is why when I keep the nrf_pwr_mgmt_shutdown() it works.

    - Once I have the issue rebooting the remote does not solve it. I must reboot, unpair and re-pair to the box

    - Something odd is that if I have the issue and I unpair the remote, connect to another device (windows or android phone) I still have the issue on these devices. I must reboot then unpair to make it work.

    I hope these information will be helpfull.

    Best regards,

    Sylvain

  • Thanks for the additional information, Sylvain. What version Android TV are you testing with? We can  try to reproduce the issue here by removing nrf_pwr_mgmt_shutdown() from default code.

Reply Children
  • I'm on Android TV 7.1.2 with security patch from 1 december 2017 but I also get issues on android 8.0.0 with security patch from 5 december 2018 

  • Can you share some more details regarding the function you call to advertise when disconnected and a button is pressed?
    I've done some testing on a Nexus Player running Android 8.0, but haven't seen the issue yet.

    I made the following modifications to default SR3 v1.2.1 (PCA63519 hardware) to recreate your setup:

    - In application sdk_config.h, set NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0

    - Remove all calls to nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF)

    - Added the following behavior when a button is pressed and remote is not currently connected:

    if (!m_coms_ble_adv_running())
    {
        (void) m_coms_ble_advertise(false);
    }

    I also tried with m_coms_ble_advertise(true), but this will cause the remote to erase the existing bond if CONFIG_MAX_BONDS ==1 (default value), in order to free up enough space in bond database to create new bond. In this case I ended up in an connect/disconnect cycle with the Nexus Player due to encryption failing (encryption keys erased by remote).

    Please let me know if I'm missing some important difference between our setups

Related