-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split network and node configuration (#11)
- Loading branch information
1 parent
6328fa1
commit 96722db
Showing
6 changed files
with
289 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
wirepas-mqtt-library==1.2.5 | ||
cbor2==5.6.4 | ||
PyYAML==6.0.1 | ||
pycryptodome==3.20.0 | ||
pycryptodome==3.20.0 | ||
pydantic==2.8.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
Provisioning helpers | ||
=================== | ||
.. Copyright: | ||
Copyright 2024 Wirepas Ltd under Apache License, Version 2.0. | ||
See file LICENSE for full license details. | ||
""" | ||
|
||
|
||
class ProvisioningDataException(Exception): | ||
""" | ||
Wirepas Provisioning data generic Exception | ||
""" | ||
|
||
|
||
def convert_to_bytes(param_raw: bytes | int | str) -> bytes: | ||
if isinstance(param_raw, str): | ||
if param_raw.upper().startswith("0X"): | ||
param_raw = param_raw.upper().replace("0X", "") | ||
param = bytes.fromhex(param_raw) | ||
else: | ||
param = bytes(param_raw, "utf-8") | ||
elif isinstance(param_raw, int): | ||
param = param_raw.to_bytes(max(1, (param_raw.bit_length() + 7)) // 8, byteorder="big") | ||
else: | ||
param = param_raw | ||
|
||
return param | ||
|
||
|
||
def convert_to_int(param: int | str) -> int: | ||
if isinstance(param, str): | ||
param = int(param, 0) | ||
|
||
return param |
Oops, something went wrong.