utzig commented on a change in pull request #2144: OTP Tool: Support BLE Addr
and HWID
URL: https://github.com/apache/mynewt-core/pull/2144#discussion_r363934701
##########
File path: hw/bsp/dialog_da1469x-dk-pro/otp_tool.py
##########
@@ -605,6 +615,141 @@ def test_alive_target(uart):
SystemExit("Successfully communicated with target")
[email protected]('-u', '--uart', required=True, help='uart port')
[email protected](help='Read the BLE Address of the device')
+def otp_read_ble_addr(uart):
+ try:
+ ser = serial.Serial(port=uart, baudrate=1000000, timeout=1,
+ bytesize=8, stopbits=serial.STOPBITS_ONE)
+ except serial.SerialException:
+ raise SystemExit("Failed to open serial port")
+
+ cmd = cmd_no_payload(0xaa55aa55, Cmd.READ_BLEADDR)
+ msg = struct.pack('II', *cmd)
+
+ try:
+ ser.write(msg)
+ except serial.SerialException:
+ raise SystemExit("Failed to write to %s" % uart)
+
+ data = read_exact(ser, 16)
+ response = cmd_response._make(struct.unpack_from('IIII', data))
+ if response.status == 0:
+ # BLE Addr is 48 bits long, read as 2 uint32_t values
+ ble_words = struct.unpack_from('II', ser.read(8))
+ print("BLE Addr - Low Word:" + hex(ble_words[0])
+ + " High Word:" + hex(ble_words[1]))
+ else:
+ raise SystemExit("Error reading BLE Addr with status %s" %
+ hex(response.status))
+
+
[email protected]('-u', '--uart', required=True, help='uart port')
[email protected](help='Generate and program the BLE Address of the device')
+def otp_write_ble_addr(uart):
+ try:
+ ser = serial.Serial(port=uart, baudrate=1000000, timeout=1,
+ bytesize=8, stopbits=serial.STOPBITS_ONE)
+ except serial.SerialException:
+ raise SystemExit("Failed to open serial port")
+
+ cmd = cmd_no_payload(0xaa55aa55, Cmd.GEN_BLEADDR)
+ msg = struct.pack('II', *cmd)
+
+ try:
+ ser.write(msg)
+ except serial.SerialException:
+ raise SystemExit("Failed to write %s" % uart)
+
+ data = read_exact(ser, 16)
+ response = cmd_response._make(struct.unpack_from('IIII', data))
+ if (response.status == 0 or response.status == 1):
Review comment:
Not "pythonic' to use parenthesis here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services