Skip to content

Instantly share code, notes, and snippets.

@dejanb
Last active September 30, 2024 16:55
Show Gist options
  • Save dejanb/85282932d08d26dce2c9323b3d0cc1e2 to your computer and use it in GitHub Desktop.
Save dejanb/85282932d08d26dce2c9323b3d0cc1e2 to your computer and use it in GitHub Desktop.
Test Bluetooth mesh

start clean mesh (first terminal):


$ rm -rf ~/.config/meshcfg/config_db.json
$ sudo rm -rf /var/lib/bluetooth/mesh
$ sudo mkdir /var/lib/bluetooth/mesh
$ sudo /usr/libexec/bluetooth/bluetooth-meshd -nd --debug

provisioner (second terminal):


$ mesh-cfgclient

Warning: config file "/home/pi/.config/meshcfg/config_db.json" not found
[mesh-cfgclient]# create
Created new node with token 522b02d50de1c8a2
Proxy added: org.bluez.mesh.Node1 (/org/bluez/mesh/nodea186fe8c7e3b461daa29664eba26ed2d)
Proxy added: org.bluez.mesh.Management1 (/org/bluez/mesh/nodea186fe8c7e3b461daa29664eba26ed2d)
Attached with path /org/bluez/mesh/nodea186fe8c7e3b461daa29664eba26ed2d
[mesh-cfgclient]# appkey-create 0 0

device (third terminal):


$ bluez/test/test-mesh

join
Joining with UUID 3df8492249f1476491a1e4e1d051a5f7
Join procedure started

provisioner:


[mesh-cfgclient]# provision 3df8492249f1476491a1e4e1d051a5f7

device:

PromptStatic ( static-oob )
Enter 16 octet key on remote device:  6f4b1f31cbe0d0f81b0ef64a1c70b86c

provisioner:


[[mesh-agent]# ] Enter key (hex number): 6f4b1f31cbe0d0f81b0ef64a1c70b86c

device:

Joined mesh network with token 62cb5d464413e5c7

provisioner:


Assign addresses for 2 elements
Provisioning done:
Mesh node:
	UUID = 3DF8492249F1476491A1E4E1D051A5F7
	primary = 00aa

	elements (2):

[mesh-cfgclient]# menu config
[mesh-cfgclient]# target 00aa
Configuring node 00aa

[config: Target = 00aa]# appkey-add 0

[config: Target = 00aa]# composition-get
Received DeviceCompositionStatus (len 29)
Received composion:
	Feature support:
		relay: yes
		proxy: no
		friend: yes
		lpn: no
	 Element 0:
		location: 0000
		SIG defined models:
		  Model ID	0000 "Configuration Server"
		  Model ID	1000 "Generic OnOff Server"
		 Vendor defined models:
		  Model ID	05f1 0001
	 Element 1:
		location: 0000
		SIG defined models:
		  Model ID	1001 "Generic OnOff Client"

[config: Target = 00aa]# bind 00aa 0 1000
[config: Target = 00aa]# bind 00ab 0 1001

device:


attach
Attach mesh node to bluetooth-meshd daemon
Mesh app registered: /org/bluez/mesh/node3df8492249f1476491a1e4e1d051a5f7
Update Model Config 1000
Bindings: [0]
Update Model Config 1001
Bindings: [0]

dest
Enter 4-digit hex destination address:
00aa
Destination address: 00aa
client-menu
*** ON/OFF CLIENT MENU ***
on
Set state: 1
OnOffClient send command
Message Received on Element 00, src= 00ab, dst=00aa
State is ON
Message Received on Element 01, src= 00aa, dst=00ab
OnOffClient process message len = 3
Got state ON from 00aa
off
Set state: 0
OnOffClient send command
Message Received on Element 00, src= 00ab, dst=00aa
State is OFF
Message Received on Element 01, src= 00aa, dst=00ab
OnOffClient process message len = 3
Got state OFF from 00aa
get-state
OnOffClient send command
Message Received on Element 00, src= 00ab, dst=00aa
Get state
Message Received on Element 01, src= 00aa, dst=00ab
OnOffClient process message len = 3
Got state OFF from 00aa
@dejanb
Copy link
Author

dejanb commented Sep 4, 2024

Hi Vincent, if I remember correctly (which might not be the case), your expectation to see the unprovisioned device on both PIs is not correct. There can be only one "provisioner" on the mesh. By calling "create" on PI2 you are actually creating a new network.

I hope this helps.

@dreamlayers
Copy link

Yes, provisioning is the action of joining a device to a network. The device can only be a member of one network at a time. Typically devices can only be discovered unprovisioned when they've been reset, like after rapidly turning a light bulb off and on some number of times. You certainly can use one device from two different computers, but both of those computers must be part of the same network. This can be accomplished by copying the relevant keys from one computer to the other. I did this to control a Sylvania light bulb that had been provisioned via Sylvania's app on my phone. After my computer became part of the same network, I was able to control the light bulb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment