Skip to content

move bytearray.fromhex to ubinascii.unhexlify #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions adafruit_atecc/adafruit_atecc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from struct import pack
from micropython import const
from adafruit_bus_device.i2c_device import I2CDevice
from adafruit_binascii import hexlify
from adafruit_binascii import hexlify, unhexlify

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ATECC.git"
Expand Down Expand Up @@ -120,27 +120,31 @@ def _convert_i2c_addr_to_atecc_addr(i2c_addr=0x60):
Byte 16: 20 32 0010 0000 Default 7 bit I2C Address: 0x20>>1: 0x10 ATECC608A-UNKNOWN
"""
CFG_TLS = bytes(
bytearray.fromhex(
"01 23 00 00 00 00 50 00 00 00 00 00 00 c0 71 00"
"20 20 20 20 20 20 20 20 20 20 20 20 20 c0 00 55"
"00 83 20 87 20 87 20 87 2f 87 2f 8f 8f 9f 8f af"
"20 20 20 20 20 20 20 20 20 20 20 20 20 8f 00 00"
"00 00 00 00 00 00 00 00 00 00 00 00 20 20 20 20"
"20 20 20 20 20 20 20 20 20 af 8f ff ff ff ff 00"
"00 00 00 ff ff ff ff 00 20 20 20 20 20 20 20 20"
"20 20 20 20 20 00 00 00 ff ff ff ff ff ff ff ff"
"ff ff ff ff 20 20 20 20 20 20 20 20 20 20 20 20"
"20 ff ff ff ff 00 00 55 55 ff ff 00 00 00 00 00"
"00 33 20 20 20 20 20 20 20 20 20 20 20 20 20 00"
"33 00 33 00 33 00 33 00 1c 00 1c 00 1c 00 3c 00"
"3c 00 3c 00 3c 20 20 20 20 20 20 20 20 20 20 20"
"20 20 00 3c 00 3c 00 3c 00 1c 00"
bytearray(
unhexlify(
(
"01 23 00 00 00 00 50 00 00 00 00 00 00 c0 71 00"
"20 20 20 20 20 20 20 20 20 20 20 20 20 c0 00 55"
"00 83 20 87 20 87 20 87 2f 87 2f 8f 8f 9f 8f af"
"20 20 20 20 20 20 20 20 20 20 20 20 20 8f 00 00"
"00 00 00 00 00 00 00 00 00 00 00 00 20 20 20 20"
"20 20 20 20 20 20 20 20 20 af 8f ff ff ff ff 00"
"00 00 00 ff ff ff ff 00 20 20 20 20 20 20 20 20"
"20 20 20 20 20 00 00 00 ff ff ff ff ff ff ff ff"
"ff ff ff ff 20 20 20 20 20 20 20 20 20 20 20 20"
"20 ff ff ff ff 00 00 55 55 ff ff 00 00 00 00 00"
"00 33 20 20 20 20 20 20 20 20 20 20 20 20 20 00"
"33 00 33 00 33 00 33 00 1c 00 1c 00 1c 00 3c 00"
"3c 00 3c 00 3c 20 20 20 20 20 20 20 20 20 20 20"
"20 20 00 3c 00 3c 00 3c 00 1c 00"
).replace(" ", "")
)
)
)

# Convert I2C address to config byte 16 and update CFG_TLS
_CFG_BYTES_LIST = list(bytearray(CFG_TLS))
_CFG_BYTE_16 = bytes(bytearray.fromhex(hex(_I2C_ADDR << 1).replace("0x", "")))
_CFG_BYTE_16 = bytes(bytearray(unhexlify(hex(_I2C_ADDR << 1).replace("0x", ""))))
_CFG_BYTES_LIST_MOD = _CFG_BYTES_LIST[0:16] + list(_CFG_BYTE_16) + _CFG_BYTES_LIST[17:]
CFG_TLS = bytes(_CFG_BYTES_LIST_MOD)

Expand Down