PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.2KB

  1. // cc110_client.pde
  2. // -*- mode: C++ -*-
  3. // Example sketch showing how to create a simple messageing client
  4. // with the RH_CC110 class. RH_CC110 class does not provide for addressing or
  5. // reliability, so you should only use RH_CC110 if you do not need the higher
  6. // level messaging abilities.
  7. // It is designed to work with the other example cc110_server
  8. // Tested with Teensy 3.1 and Anaren 430BOOST-CC110L
  9. #include <SPI.h>
  10. #include <RH_CC110.h>
  11. // Singleton instance of the radio driver
  12. RH_CC110 cc110;
  13. void setup()
  14. {
  15. Serial.begin(9600);
  16. while (!Serial)
  17. ; // wait for serial port to connect. Needed for native USB
  18. // CC110L may be equipped with either 26 or 27MHz crystals. You MUST
  19. // tell the driver if a 27MHz crystal is installed for the correct configuration to
  20. // occur. Failure to correctly set this flag will cause incorrect frequency and modulation
  21. // characteristics to be used. You can call this function, or pass it to the constructor
  22. cc110.setIs27MHz(true); // Anaren 430BOOST-CC110L Air BoosterPack test boards have 27MHz
  23. if (!cc110.init())
  24. Serial.println("init failed");
  25. // After init(), the following default values apply:
  26. // TxPower: TransmitPower5dBm
  27. // Frequency: 915.0
  28. // Modulation: GFSK_Rb1_2Fd5_2 (GFSK, Data Rate: 1.2kBaud, Dev: 5.2kHz, RX BW 58kHz, optimised for sensitivity)
  29. // Sync Words: 0xd3, 0x91
  30. // But you can change them:
  31. // cc110.setTxPower(RH_CC110::TransmitPowerM30dBm);
  32. // cc110.setModemConfig(RH_CC110::GFSK_Rb250Fd127);
  33. //cc110.setFrequency(928.0);
  34. }
  35. void loop()
  36. {
  37. Serial.println("Sending to cc110_server");
  38. // Send a message to cc110_server
  39. uint8_t data[] = "Hello World!";
  40. cc110.send(data, sizeof(data));
  41. cc110.waitPacketSent();
  42. // Now wait for a reply
  43. uint8_t buf[RH_CC110_MAX_MESSAGE_LEN];
  44. uint8_t len = sizeof(buf);
  45. if (cc110.waitAvailableTimeout(3000))
  46. {
  47. // Should be a reply message for us now
  48. if (cc110.recv(buf, &len))
  49. {
  50. Serial.print("got reply: ");
  51. Serial.println((char*)buf);
  52. // Serial.print("RSSI: ");
  53. // Serial.println(cc110.lastRssi(), DEC);
  54. }
  55. else
  56. {
  57. Serial.println("recv failed");
  58. }
  59. }
  60. else
  61. {
  62. Serial.println("No reply, is cc110_server running?");
  63. }
  64. delay(400);
  65. }