feat(ble): add a NimBLE provider and fold its controls into Settings
Bluedroid cannot initialize beside the Lua runtime on this heap, so the provider is NimBLE-Arduino. Scans keep the six strongest devices in a fixed buffer rather than growing one. The standalone BLE app is gone: it was a screen of toggles that belongs next to the other device settings.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
-- Run: lua test/ble.lua
|
||||
package.path = "sdcard/.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()
|
||||
|
||||
dofile("sdcard/.lua/apps/Settings/main.lua")
|
||||
|
||||
init()
|
||||
device.tap("BLE")
|
||||
assert(device.labelled("off"))
|
||||
assert(not device.find("disconnect"))
|
||||
|
||||
device.tap("turn on")
|
||||
assert(device.bleName == "Slate32 BLE")
|
||||
device.tap("scan devices")
|
||||
assert(device.labelled("scanning BLE"))
|
||||
tick()
|
||||
assert(device.labelled("Sensor"))
|
||||
|
||||
device.tap("Sensor")
|
||||
assert(device.labelled("connecting BLE"))
|
||||
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")
|
||||
Reference in New Issue
Block a user