ble_proximity_signal_platform_interface 0.1.0+1
ble_proximity_signal_platform_interface: ^0.1.0+1 copied to clipboard
A common platform interface for the ble_proximity_signal plugin.
ble_proximity_signal_platform_interface #
A common platform interface for the ble_proximity_signal federated plugin.
This package defines:
- Platform contract (
BleProximitySignalPlatform) - Shared configuration models (
ScanConfig,BroadcastConfig) - Shared raw model (
RawScanResult)
If you are a plugin user, you typically do not depend on this package directly. If you are implementing a new platform (or maintaining Android/iOS implementations), this is the source of truth.
Overview #
Contract shape #
Platform implementations must provide:
startBroadcast(token:, config:)/stopBroadcast()startScan(targetTokens:, config:)/stopScan()debugDiscoverServices(deviceId:, timeoutMs:)(debug helper)Stream<RawScanResult> get scanResults(event stream)
The ble_proximity_signal Dart wrapper consumes this stream and applies smoothing/hysteresis
to produce Stream<ProximityEvent>.
RawScanResult payload contract #
Platforms must emit RawScanResult.fromMap(...) compatible maps over the event channel.
Minimum required fields:
targetToken(String)rssi(int)timestampMs(int, epoch millis)
Optional fields (best-effort, may be null):
deviceId,deviceName,localName,localNameHexmanufacturerDataLen,manufacturerDataHexserviceDataLen,serviceDataUuids,serviceDataHexserviceUuids
Notes #
timestampMsuses Unix epoch ms for cross-platform consistency.targetTokenis the identifier extracted from the advertising payload. In debug modes, implementations may fall back todeviceId.localNameHex,serviceDataHex, andmanufacturerDataHexshould contain hex-encoded payloads for debugging; keep them compact and best-effort.
Config models #
BroadcastConfig #
serviceUuid(String, 128-bit UUID)txPower(int? hint; platform may ignore)
ScanConfig #
serviceUuid(String)debugAllowAll(bool)
The Dart wrapper enforces targetTokens.length <= 5 when debugAllowAll == false.
Platforms may enforce as well.
Implementing a new platform #
Create a package and extend BleProximitySignalPlatform.
Key rules:
- Register your implementation by setting
BleProximitySignalPlatform.instance = ... - Stream raw scan events via
scanResults - Match map keys exactly for
RawScanResult.fromMap
Recommended checklist:
- ❌ Event channel emits required keys (
targetToken,rssi,timestampMs) - ❌
timestampMsuses epoch milliseconds - ❌
startScancan accept up to 5 target tokens - ❌ Best-effort populate optional debug fields
- ❌
stopScanandstopBroadcastare idempotent - ❌ Debug discovery returns a human-readable dump string
Example debug discovery output:
deviceId: <id>
name: <device name>
service <uuid>
char <uuid> props=read|notify