96c1a68ee0
Wire the host side of the new advertisement observer (continuous scan, bounded staleness map, ingestion filter) and add a BLETemp app that decodes ATC_MiThermometer adverts (service data 0x181A, ATC1441 and pvvx formats) from ble.observed(). Migrate the Settings/Ble picker off the removed blocking scan onto observe()/observed(). Remove the Hello and Scroll demo apps; BLETemp now serves as the tree-owned-scrolling example in the docs. AGENTS.md gains a Design Stance: this is pre-release firmware, so a wrong abstraction gets redesigned, not extended with a compat shim. BLE cannot run in the emulator, so the app logic is covered by host tests (test/bletemp.lua) against fake_device.
36 lines
978 B
Lua
36 lines
978 B
Lua
-- Run: lua test/ble.lua
|
|
package.path = "sdcard/.lua/lib/?.lua;lib/esp32-lua-api/lua/lib/?.lua;test/?.lua;" .. package.path
|
|
|
|
local device = require "fake_device"
|
|
device.bleDevices = { { name = "Sensor", address = "aa:bb:cc:dd:ee:ff", rssi = -42 } }
|
|
device.install()
|
|
|
|
local app = device.start "sdcard/.lua/apps/Settings/Ble/main.lua"
|
|
|
|
assert(device.labelled "off")
|
|
assert(not device.find "disconnect")
|
|
|
|
device.tap "turn on"
|
|
assert(device.bleName == "Slate32 BLE")
|
|
device.tap "scan devices"
|
|
assert(device.bleObserving)
|
|
assert(device.labelled "Sensor")
|
|
|
|
device.tap "Sensor"
|
|
assert(device.labelled "connecting BLE")
|
|
assert(not device.bleObserving)
|
|
app.tick()
|
|
assert(device.bleConnected == "aa:bb:cc:dd:ee:ff")
|
|
assert(device.find "disconnect")
|
|
|
|
device.tap "disconnect"
|
|
device.tap "start advertising"
|
|
assert(device.bleAdvertising == "Slate32 BLE")
|
|
device.tap "stop advertising"
|
|
assert(device.bleAdvertising == nil)
|
|
|
|
device.tap "turn off"
|
|
assert(not device.bleInitialized)
|
|
|
|
print "ok"
|