TEST

Dependencies:   TMRh20_v2 mbed-dev ssRadio WakeUp

Revision:
0:827df48824f9
Child:
1:499ddde5f76c
diff -r 000000000000 -r 827df48824f9 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 06 20:22:14 2017 +0000
@@ -0,0 +1,60 @@
+#include "ssRadio.h"
+
+SPI spi(SPI_MOSI, SPI_MISO, SPI_SCK);
+SSRadio *radio;
+//Serial pc(SERIAL_TX, SERIAL_RX);
+
+void onData(uint8_t *data, uint16_t type, uint8_t size) {
+  //pc.printf("Data received.\n");
+  //pc.printf("Type: %d\n", type);
+  //pc.printf("Size: %d", size);
+}
+
+void loop();
+
+int main() {
+  //pc.baud(115200);
+  //Serial.println(F("Hello World!"));
+
+  spi.frequency(8000000);
+  spi.format(8, 0);
+
+  NodeConfig nc(PA_1, PA_2);
+  //nc.setSyncAddress(0x3333333333L);
+  //nc.setNodeAddress(0x424D451110L); // This is stored in EEPROM or uinqID
+  nc.setSyncAddress(0x424D452AD2L);
+  nc.setGwId(0x2AE1);
+  nc.setChannel(112);
+
+  //Serial.println("I'm " + String(nc.getNodeId()));
+  //Serial.flush();
+
+  radio = new SSRadio(&spi, &nc);
+  radio->init();
+
+  radio->setOnReceiveData(&onData);
+  
+  if (!radio->isRunning()) {
+    //pc.printf("Error Radio is not working!");
+  } else {
+    //pc.printf("Working.");
+  }
+  
+  while (1) { loop(); }
+}
+
+long last = 0;
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  
+  long now = us_ticker_read() / 1000;
+  if (now - last > 1000) {
+    //pc.printf("Hello");
+    radio->sendData((uint8_t*)"Hello", 6, 6);
+    last = now;
+  }
+  
+  radio->loop();
+}
+ 
\ No newline at end of file