76 lines
2.1 KiB
Lua
76 lines
2.1 KiB
Lua
---@meta
|
|
|
|
-- Generated from native/src/bindings/core/ble.cpp. Do not edit.
|
|
|
|
---@alias BleObservationIterator fun(state: nil, after: string|nil): address: string|nil, name: string|nil, rssi: integer|nil, payload: string|nil, lastSeenMs: integer|nil
|
|
|
|
---@class BleFilter
|
|
---@field services? string[] Service-data UUIDs to keep.
|
|
---@field manufacturers? integer[] Manufacturer ids to keep.
|
|
|
|
---@class BleLib
|
|
ble = {}
|
|
|
|
---Starts the BLE stack.
|
|
---@param name? string Local device name.
|
|
---@return true? ok
|
|
---@return string? error
|
|
function ble.init(name) end
|
|
|
|
---Stops the BLE stack and releases its memory.
|
|
function ble.deinit() end
|
|
|
|
---Whether the BLE stack is running.
|
|
---@return boolean
|
|
function ble.isInitialized() end
|
|
|
|
---Starts passively observing advertisements, coalesced per device. The returned iterator is reusable; observation stops with its Lua state.
|
|
---@param filter? BleFilter Keep only matching adverts; nil keeps all.
|
|
---@return BleObservationIterator? observations
|
|
---@return string? error
|
|
function ble.observe(filter) end
|
|
|
|
---Stops observing and clears the buffered devices.
|
|
function ble.unobserve() end
|
|
|
|
---Whether advertisement observation is running.
|
|
---@return boolean
|
|
function ble.isObserving() end
|
|
|
|
---Connects to a peripheral.
|
|
---@param address string
|
|
---@return true? ok
|
|
---@return string? error
|
|
function ble.connect(address) end
|
|
|
|
---Disconnects from the connected peripheral.
|
|
function ble.disconnect() end
|
|
|
|
---Whether a peripheral is connected.
|
|
---@return boolean
|
|
function ble.isConnected() end
|
|
|
|
---Reads a characteristic value.
|
|
---@param serviceUuid string
|
|
---@param characteristicUuid string
|
|
---@return string? value
|
|
---@return string? error
|
|
function ble.read(serviceUuid, characteristicUuid) end
|
|
|
|
---Writes a characteristic value.
|
|
---@param serviceUuid string
|
|
---@param characteristicUuid string
|
|
---@param value string
|
|
---@return true? ok
|
|
---@return string? error
|
|
function ble.write(serviceUuid, characteristicUuid, value) end
|
|
|
|
---Starts advertising.
|
|
---@param name? string Advertised device name.
|
|
---@return true? ok
|
|
---@return string? error
|
|
function ble.startAdvertising(name) end
|
|
|
|
---Stops advertising.
|
|
function ble.stopAdvertising() end
|