SIG mesh demo app based on Bluetooth Mesh Spec.
- Telink SIG Mesh Device
- Android phone (4.3+)
-
Open project int Android Studio : file -> open -> select TelinkBleMesh; Or import library in project in android studio: file -> new -> import module -> select TelinkBleMeshLib.
-
Create custom Application extends
MeshApplication
; Or create a custom class to deal withEventHandler
(generally post event, More details bout EventHandler see details) -
Invoke
MeshService#init
for library initializing; And invokeMeshService#setupMeshNetwork(MeshConfiguration)
for networking setup(more details about MeshConfiguration see details)
- Listening to these events :
ScanEvent.EVENT_TYPE_DEVICE_FOUND
(when unprovisioned device found)ScanEvent.EVENT_TYPE_SCAN_TIMEOUT
(when no device found)ProvisioningEvent.EVENT_TYPE_PROVISION_SUCCESS
(when device provision succeed)ProvisioningEvent.EVENT_TYPE_PROVISION_FAIL
(when device provision fail)
- Invoke
MeshService#startScan
to scan for unprovisioned devices; - When device found, invoke
MeshService#startProvisioning
with allocated unicast address and static-OOB data (Optional) . Provisioning event will be posted when complete;
Binding means add application key to the provisioned node and bind this application key with target models.
- Listening to these events :
BindingEvent.EVENT_TYPE_BIND_SUCCESS
(when bind succeed)BindingEvent.EVENT_TYPE_BIND_FAIL
(when bind fail)
- Invoke
MeshService#startBinding
- Send mesh message:
- invoke
MeshService#sendMeshMessage
to send common model message ,config model message, vendor model message. For example, sendOnOffSetMessage
to set node on/off state (more details about mesh message see details)
- invoke
- Receive status message:
- when ack message sent , device status changed, device status publish ,, status message will be received. Meanwhile
StatusNotificationEvent
will be assembled and post. TheeventType
in StatusNotificationEvent is determined by MeshStatus#Container , generally it is the status message class name; For example, on off status event type isOnOffStatusMessage.class.getName()
- when ack message sent , device status changed, device status publish ,, status message will be received. Meanwhile
- Listening to these events :
GattOtaEvent.EVENT_TYPE_OTA_SUCCESS
(when OTA succeed)GattOtaEvent.EVENT_TYPE_OTA_PROGRESS
(when OTA progress update)GattOtaEvent.EVENT_TYPE_OTA_FAIL
(when OTA fail)
- Invoke
MeshService#startGattOta
This is Telink private action for faster application key binding, only appllication key adding action will be executed.
- Set
BindingDevice#defaultBound
by true to enable default bound when start binding.
This is Telink private provisioning flow for faster and wider networking.
- Device is fast-provision supported
- Device's composition-data is known
- Listening to these events :
FastProvisioningEvent.EVENT_TYPE_FAST_PROVISIONING_ADDRESS_SET
(when set device address complete)FastProvisioningEvent.EVENT_TYPE_FAST_PROVISIONING_FAIL
(when fast provision fail)FastProvisioningEvent.EVENT_TYPE_FAST_PROVISIONING_SUCCESS
(when fast provision succeed)
- Invoke
MeshService.#startFastProvision
and waiting forFastProvisioningEvent
- Device is remote-provision supported;
- If no proxy device in mesh is connected, normal provisioning and binding is needed before remote-provisioning
-
Listening to these events :
ScanReportStatusMessage
(when device found by remote scan)RemoteProvisioningEvent.EVENT_TYPE_REMOTE_PROVISIONING_SUCCESS
(when remote provision succeed)RemoteProvisioningEvent.EVENT_TYPE_REMOTE_PROVISIONING_FAIL
(when remote provision fail)
-
Send mesh message
ScanStartMessage
, and collect scan report when handlingScanReportStatusMessage
-
Invoke
MeshService#startRemoteProvisioning
, and waiting forRemoteProvisioningEvent
- Device is mesh-OTA supported;
- Firmware bin;
- Listening to these events :
FirmwareInfoStatusMessage
(when device firmware version info received)MeshUpdatingEvent.EVENT_TYPE_UPDATING_PREPARED
(when mesh ota prepared -- before sending block)MeshUpdatingEvent.EVENT_TYPE_UPDATING_SUCCESS
(when mesh ota succeed)MeshUpdatingEvent.EVENT_TYPE_UPDATING_FAIL
(when mesh ota fail)MeshUpdatingEvent.EVENT_TYPE_UPDATING_PROGRESS
(when mesh ota progress update)MeshUpdatingEvent.EVENT_TYPE_DEVICE_SUCCESS
(when device update succeed)MeshUpdatingEvent.EVENT_TYPE_DEVICE_FAIL
(when device update fail)
- Invoke
MeshService#startMeshOta
, and waiting forMeshUpdatingEvent
- networkKey : network key
- netKeyIndex : network key index
- appKeyMap : application key and index map, at least one element
- ivIndex : iv-index
- sequenceNumber : sequence-number
- localAddress : provisioner address, should be valid unicast address (0x0001 - 0x7FFF)
- deviceKeyMap : provisioned device address and deviceKey map, updated when device provisioned or device removed
-
opcode : opcode of access layer
-
params : params of access layer
-
destinationAddress : destination address of network layer
-
sourceAddress : source address of network layer, managed by lib, valued by
MeshConfiguration#localAddress
-
accessType : define if message is DEVICE or APPLICATION
-
accessKey : encryption key used when upper transport encryption, managed by lib, if accessType is DEVICE , accessKey will be valued by device key , otherwise be valued by application key
-
appKeyIndex: only used when accessType==APPLICATION
-
ctl : 0 for access message, 1 for control message
-
ttl : message ttl, default 10
-
responseOpcode : used in reliable message,defines expected response opcode , such as on/off-get-message expect on/off-status-message
-
responseMax : used in reliable message,defines expected response max count, if no response received or response count is less than max, retry is needed
-
retryCnt : used in reliable message,defines max retry count if retry needed
-
tidPosition : used in tid message,defines tid position in params, if it is valid position, target byte will be replaced by an auto-increment value in lib
- NetworkInfoUpdateEvent : posted when iv-index or sequence-number updated, new value should be saved in ORM
- OnlineStatusEvent : posted when online-status(telink private status) received
- StatusNotificationEvent : posted when mesh status notification received; Its inner eventType is determined by the StatusMessage (registered in MeshStatus)
- MeshEvent : posted when mesh networking status changed
- Action events are posted when action status changed:
- ScanEvent
- ProvisioningEvent
- BindingEvent
- AutoConnectEvent
- GattOtaEvent
- FastProvisioningEvent
- RemoteProvisioningEvent
- MeshUpdatingEvent