Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from .AES_CMAC import AES_CMAC
- from .ulora2 import LoRa, ModemConfig
- class CustomLora(LoRa):
- def on_recv(self, message):
- print('Received a message!!!')
- lora = CustomLora(spi_channel=(4, 22, 21), interrupt=32, interrupt2=25,
- this_address=10, cs_pin=12, reset_pin=13, tx_power=20,
- modem_config=ModemConfig.Bw125Cr48Sf4096, receive_all=True)
- joinEUI = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
- devEUI = [<redacted>]
- NwkKey = [<redacted>]
- # MCHR + data + DevNonce
- data = bytes([0x00] + joinEUI + devEUI + [0x00, 0x00])
- mic = AES_CMAC()
- MIC = mic.encode(NwkKey, data)[:4]
- lora.send(data + bytes(MIC), header_id=255, header_to=255)
- time.sleep(5)
- lora.set_mode_rx()
- while True:
- # print(lora._spi_read(0x1B))
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement