Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of football_project by
Diff: Radio.cpp
- Revision:
- 18:affef3a7db2a
- Child:
- 23:26f27c462976
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Radio.cpp Sun Nov 29 13:52:53 2015 +0000
@@ -0,0 +1,65 @@
+#include <RFM69.h>
+#include <SPI.h>
+
+#define GATEWAY_ID 1 // this is ME, TGateway
+#define NETWORKID 101 //the same on all nodes that talk to each other
+
+#define FREQUENCY RF69_915MHZ
+
+//#define IS_RFM69HW //NOTE: uncomment this ONLY for RFM69HW or RFM69HCW
+#define ENCRYPT_KEY "EncryptKey123456" // use same 16byte encryption key for all devices on net
+#define ACK_TIME 50 // max msec for ACK wait
+#define LED 9 // Anardino miniWireless has LEDs on D9
+#define SERIAL_BAUD 115200
+#define VERSION "1.0"
+
+#define MSGBUFSIZE 64 // message buffersize, but for this demo we only use:
+ // 1-byte NODEID + 4-bytes for time + 1-byte for temp in C + 2-bytes for vcc(mV)
+
+//RFM69::RFM69(PinName PinName mosi, PinName miso, PinName sclk,slaveSelectPin, PinName int)
+//RFM69 radio(P0_24,P0_23,P0_25,P0_28,P0_7);
+
+static bool promiscuousMode = false; // set 'true' to sniff all packets on the same network
+static bool requestACK = false;
+
+static char phone_buffer[150] = {0};
+static char radio_buffer[150] = {0};
+
+extern void writeToPhone(char *data);
+
+void radio_init()
+{
+ //tmr.start();
+
+ //delay_ms(1000);
+
+ //radio.initialize(FREQUENCY, GATEWAY_ID, NETWORKID);
+ //radio.encrypt(0);
+ //radio.promiscuous(promiscuousMode);
+}
+
+#if 0
+void radio_loop()
+{
+ static int counter = 0;
+
+ if (radio.receiveDone())
+ {
+ snprintf(phone_buffer, sizeof(phone_buffer), "Got data from: %d.\r\n[%s]\r\n", radio.SENDERID, radio.DATA);
+ writeToPhone(phone_buffer);
+
+ if (radio.ACKRequested())
+ {
+ radio.sendACK();
+ }
+ }
+
+ if (++counter > 30)
+ {
+ snprintf(radio_buffer, sizeof(radio_buffer), "timer val: %d", 8);
+ radio.sendWithRetry((uint8_t)GATEWAY_ID, radio_buffer,strlen(radio_buffer),true);
+
+ counter = 0;
+ }
+}
+#endif
