反应很慢 RSSI_CHANGED_ACTION

Very slow reaction RSSI_CHANGED_ACTION

我已经解决了一些关于这个主题的问题 例如这个: Application never receives RSSI_CHANGED_ACTION

但他们使用 SCAN_RESULTS_AVAILABLE_ACTION 解决了问题。 我也这样做了,但现在由于客户要求,我必须使用 RSSI_CHANGED_ACTION。

它似乎对 rssi 变化的反应很慢。例如,它仅在我进行更大的位置更改时才会更改。 当我使用 SCAN_RESULTS_AVAILABLE_ACTION 时,它经常变化。即使我只是在一个房间里。

那么为什么 RSSI_CHANGED_ACTION 反应慢?

我找到了为什么是 "slow reacting" 的答案。 在 WifiStateMachine.java 中,我在这里找到了这个片段:

        /*
         * Rather then sending the raw RSSI out every time it
         * changes, we precalculate the signal level that would
         * be displayed in the status bar, and only send the
         * broadcast if that much more coarse-grained number
         * changes. This cuts down greatly on the number of
         * broadcasts, at the cost of not informing others
         * interested in RSSI of all the changes in signal
         * level.
         */

在 WifiWatchdogStateMachine.java 我在这里找到了这个:

  /* RSSI Levels as used by notification icon
   Level 4  -55 <= RSSI
   Level 3  -66 <= RSSI < -55
   Level 2  -77 <= RSSI < -67
   Level 1  -88 <= RSSI < -78
   Level 0         RSSI < -88 */

我认为这是自我解释。 我对此进行了测试,如果你通过了一个级别,你只会收到广播。 例如,您有更好或等于 -55 dbm,并且在下一次轮询之后您有介于 -66 和 -55 之间的 Broadcastrecieve。但是,如果您的 dBm 值只是在 -55 和 -66 之间变化,您将永远不会收到广播。