Skip to contentSkip to conversation

test/test-mesh: Add support for static OOB in the agent

PATCH Applied Inga Stotland 2 participants 2 messages Mar 11, 2020 – Mar 12, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/test-mesh: Add support for static OOB in the agent

This allows to display a 16-octet key to be entered on the remote device during provisioning.

---
 test/agent.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
test/agent.py +19 -0
index 778dbe092..af9edd35c 100755
@@ -3,6 +3,7 @@
 import sys
 import dbus
 import dbus.service
+import numpy
 
 try:
   from termcolor import colored, cprint
@@ -17,6 +18,12 @@ AGENT_PATH = "/mesh/test/agent"
 
 bus = None
 
+def array_to_string(b_array):
+	str_value = ""
+	for b in b_array:
+		str_value += "%02x" % b
+	return str_value
+
 class Agent(dbus.service.Object):
 	def __init__(self, bus):
 		self.path = AGENT_PATH
@@ -27,6 +34,7 @@ class Agent(dbus.service.Object):
 		caps = []
 		oob = []
 		caps.append('out-numeric')
+		#caps.append('static-oob')
 		oob.append('other')
 		return {
 			AGENT_IFACE: {
@@ -46,3 +54,14 @@ class Agent(dbus.service.Object):
 	def DisplayNumeric(self, type, value):
 		print(set_cyan('DisplayNumeric ('), type,
 				set_cyan(') number ='), set_green(value))
+
+	@dbus.service.method(AGENT_IFACE, in_signature="s", out_signature="ay")
+	def PromptStatic(self, type):
+		static_key = numpy.random.randint(0, 255, 16)
+		key_str = array_to_string(static_key)
+
+		print(set_cyan('PromptStatic ('), type, set_cyan(')'))
+		print(set_cyan('Enter 16 octet key on remote device: '),
+							set_green(key_str));
+
+		return dbus.Array(static_key, signature='y')
Signature · 1 line
2.21.1
Applied
#1 lore raw

Applied, with Static OOB enabled by default

Quoted 54 lines · Inga Stotland

This allows to display a 16-octet key to be entered on the remote device during provisioning.

---
 test/agent.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
test/agent.py +19 -0
index 778dbe092..af9edd35c 100755
@@ -3,6 +3,7 @@
 import sys
 import dbus
 import dbus.service
+import numpy
 
 try:
   from termcolor import colored, cprint
@@ -17,6 +18,12 @@ AGENT_PATH = "/mesh/test/agent"
 
 bus = None
 
+def array_to_string(b_array):
+	str_value = ""
+	for b in b_array:
+		str_value += "%02x" % b
+	return str_value
+
 class Agent(dbus.service.Object):
 	def __init__(self, bus):
 		self.path = AGENT_PATH
@@ -27,6 +34,7 @@ class Agent(dbus.service.Object):
 		caps = []
 		oob = []
 		caps.append('out-numeric')
+		#caps.append('static-oob')
 		oob.append('other')
 		return {
 			AGENT_IFACE: {
@@ -46,3 +54,14 @@ class Agent(dbus.service.Object):
 	def DisplayNumeric(self, type, value):
 		print(set_cyan('DisplayNumeric ('), type,
 				set_cyan(') number ='), set_green(value))
+
+	@dbus.service.method(AGENT_IFACE, in_signature="s", out_signature="ay")
+	def PromptStatic(self, type):
+		static_key = numpy.random.randint(0, 255, 16)
+		key_str = array_to_string(static_key)
+
+		print(set_cyan('PromptStatic ('), type, set_cyan(')'))
+		print(set_cyan('Enter 16 octet key on remote device: '),
+							set_green(key_str));
+
+		return dbus.Array(static_key, signature='y')