Files
esphome-dev/esphome/components
Joe 7963abb27a Fix BedJet setup priority [fixes esphome/issues#3807] (#4677)
There is a race condition where a BedJet unit previously had its BLE
"notify" flag enabled, and it continues to broadcast these notify
packets even after the ESP32 (and BLEClient) goes away, such as during
a crash or unplugging power.

BLEClient::setup_priority=AFTER_BLUETOOTH, while
BedJetHub::setup_priority=AFTER_WIFI. When the ESP32 starts back up
again, BLEClient::setup() happens first and will start receiving the
BLE notify packets almost immediately. Since we register the BLEClient
child from codegen, BedJetHub is registered as a child already by this
point, so BLEClient dispatches the notify status packet (and other gatt
events) to the BedJetHub handler, even though BedJetHub::setup() has
not been called yet.

We initialize BedJetHub::codec_ in setup(), so if BLEClient starts
dispatching gatt events before setup() is called, then codec_ will not
be initialized yet. This causes BedJetHub's gatt notify handler to call
`this->codec_->decode_notify()` on an uninitialized null pointer. Since
invoking a method does not have to dereference the pointer, that method
invocation is allowed; but later trying to access memory on that
instance results in a StoreProhibited panic.

Changing the BedJetHub's setup_priority to BLUETOOTH causes it to be
setup before BLEClient, so that by the time BLEClient starts to receive
BLE packets, BedJetHub is ready to receive them.
2023-04-12 08:33:15 +00:00
..
2022-11-24 13:12:55 +13:00
2023-01-26 17:20:45 +13:00
2023-03-20 03:38:41 +00:00
2023-03-22 08:05:09 +00:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2023-01-17 10:36:44 +13:00
2022-08-11 13:57:42 +12:00
2023-01-18 10:42:43 +13:00
2022-11-24 13:12:55 +13:00
2023-03-27 22:08:26 +00:00
2023-03-07 04:25:14 +00:00
2022-12-06 23:25:19 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2023-02-23 02:05:33 +00:00
2022-11-24 13:12:55 +13:00
2023-01-18 10:42:47 +13:00
2023-03-20 03:38:41 +00:00
2023-02-23 01:31:35 +00:00
2022-11-24 13:12:55 +13:00
2023-02-13 15:53:40 +13:00
2022-11-24 13:12:55 +13:00
2023-03-15 22:23:01 +00:00
2022-01-08 21:35:55 +13:00
2023-02-09 10:25:44 +13:00
2023-04-04 02:34:14 +00:00
2022-11-24 13:12:55 +13:00
2022-02-21 12:23:26 +13:00
2023-03-21 20:24:14 +00:00
2023-03-21 20:24:14 +00:00
2023-04-12 02:29:06 +00:00
2023-04-03 19:31:11 +00:00
2023-03-21 20:24:14 +00:00
2022-12-22 18:39:25 +13:00
2023-04-12 02:29:06 +00:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2022-01-04 10:35:15 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2021-09-26 21:34:06 +13:00
2021-09-26 21:34:06 +13:00
2021-09-26 21:34:06 +13:00
2023-03-20 03:38:41 +00:00
2023-03-20 03:38:41 +00:00
2022-11-24 13:12:55 +13:00
2022-06-07 22:43:46 +12:00
2022-11-24 13:12:55 +13:00
2023-03-31 04:29:17 +00:00
2023-03-20 03:38:41 +00:00
2022-04-13 10:19:48 +12:00
2022-05-19 12:47:33 +12:00
2023-03-20 03:38:41 +00:00
2023-02-03 07:53:46 +13:00
2023-03-08 01:11:12 +00:00
2022-04-26 09:50:36 +12:00
2022-04-13 10:19:48 +12:00
2023-03-20 03:38:41 +00:00
2023-01-18 10:43:16 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2023-01-18 10:17:31 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2022-11-24 13:12:55 +13:00
2022-09-14 16:51:20 +12:00
2023-03-20 03:38:41 +00:00
2023-02-22 23:40:20 +00:00
2022-10-19 13:44:26 +13:00