Advertisement
Guest User

Untitled

a guest
Apr 6th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import time
  2.  
  3. from .AES_CMAC import AES_CMAC
  4. from .ulora2 import LoRa, ModemConfig
  5.  
  6.  
  7. class CustomLora(LoRa):
  8.     def on_recv(self, message):
  9.         print('Received a message!!!')
  10.  
  11.  
  12. lora = CustomLora(spi_channel=(4, 22, 21), interrupt=32, interrupt2=25,
  13.                   this_address=10, cs_pin=12, reset_pin=13, tx_power=20,
  14.                   modem_config=ModemConfig.Bw125Cr48Sf4096, receive_all=True)
  15.  
  16. joinEUI = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
  17. devEUI = [<redacted>]
  18. NwkKey = [<redacted>]
  19.  
  20. # MCHR + data + DevNonce
  21. data = bytes([0x00] + joinEUI + devEUI + [0x00, 0x00])
  22.  
  23. mic = AES_CMAC()
  24. MIC = mic.encode(NwkKey, data)[:4]
  25.  
  26. lora.send(data + bytes(MIC), header_id=255, header_to=255)
  27. time.sleep(5)
  28. lora.set_mode_rx()
  29.  
  30. while True:
  31.     # print(lora._spi_read(0x1B))
  32.     pass
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement