InterSerialBridge.cpp 895 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "Arduino.h"
  2. #include "EspNowSerial/EspNowSerial.h"
  3. #include "InterSerialBridge/InterSerialBridge.h"
  4. EspMacAddress peer_addr = {0x9c, 0x9e, 0x6e, 0xe0, 0x87, 0xf4};
  5. CcmpMasterKey pmk = {0x2a, 0xc9, 0xe6, 0x4e, 0x36, 0x4c, 0xa7, 0xf4, 0xca, 0xd0, 0x4a, 0xdd, 0x34, 0xc2, 0x28, 0x25};
  6. CcmpMasterKey lmk = {0x8c, 0xd3, 0xa5, 0x7a, 0x25, 0xdf, 0x92, 0x45, 0x2a, 0xf3, 0xd5, 0x0d, 0x56, 0xc8, 0x3c, 0x34};
  7. EspNowSerial EnSerial(WIFI_MODE_STA);
  8. InterSerialBridge<1024> SerialBridge(Serial, EnSerial);
  9. void setup()
  10. {
  11. // Initialize HW Serial
  12. Serial.begin(921600);
  13. // Initialize ESP-NOW as serial
  14. uint8_t status = EnSerial.begin(11, false, pmk);
  15. status += EnSerial.add_peer_encrypted(peer_addr, lmk);
  16. // Init ESP-NOW
  17. if (status != ESP_OK)
  18. {
  19. while (1)
  20. {
  21. delay(1000);
  22. }
  23. }
  24. }
  25. void loop()
  26. {
  27. // process bridge stack
  28. SerialBridge.loop_callback();
  29. }