MrGlasspoole
Well-known member
Today i got a LC and 3.5 and my 3.2 code does not run on the LC:
I see this when i upload:
Code:
/**************************************************************
* Connection *
***************************************************************
0 <> DIO0
10 <> NSS
11 <> MOSI
12 <> MISO
14 <> SCK
**************************************************************/
#include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h>//get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h> //comes with Arduino IDE (www.arduino.cc)
/**************************************************************
* RADIO SETUP *
**************************************************************/
#define NODEID 01 //unique for each node on same network
#define NETWORKID 204 //the same on all nodes that talk to each other
#define FREQUENCY RF69_868MHZ
#define ENCRYPTKEY "7*V9uQ)M<5epl7f#" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL
#define ACK_TIME 20 // Number of milliseconds to wait for an ack
#define RETRY_PERIOD 5 // How soon to retry (in seconds) if ACK didn't come in
#define RETRY_LIMIT 5 // Maximum number of times to retry
/**************************************************************
* 32 bit Teensy *
**************************************************************/
#define LED 13 // teensy
#define CLOCKPIN 14 // teensy alternative SCK since first SCK is the LED
#define T3_IRQ_PIN 0 // pin for irq on teensy
#define T3_IRQ_NUM 0 // number for IRQ on teensy
#define T3_SPI_CS 10 // pin for SPI CS on teensy
#define POINTS 6 // number of values to send at each transmission
/**************************************************************
* MISC SETUP *
**************************************************************/
#define SERIAL_BAUD 115200
#define DEBUG 1 // Set to 1 for serial port output
/**************************************************************
* DATA STRUCTURE *
**************************************************************/
typedef struct __attribute__((__packed__)) {
uint16_t nodeId; // Store this nodeId
float temp; // Temperature reading
uint16_t vcc; // Battery voltage
byte tx; // Transmit level
float lx; // Light level
uint16_t values[POINTS];
} Payload;
Payload theData;
#ifdef IS_RFM69HW
bool isRFM69HW = true;
#else
bool isRFM69HW = false;
#endif
uint8_t irqPin = T3_IRQ_PIN;
uint8_t irqNum = T3_IRQ_NUM;
uint8_t csPin = T3_SPI_CS;
#ifdef ENABLE_ATC
RFM69_ATC radio(csPin, irqPin, isRFM69HW, irqNum);
#else
RFM69 radio(csPin, irqPin, isRFM69HW, irqNum);
#endif
bool promiscuousMode = false;
void setup() {
Serial.begin(SERIAL_BAUD);
while (!Serial) {;} // Wait for serial port to connect
SPI.setSCK(CLOCKPIN); // alternative SCK pin
pinMode(LED, OUTPUT);
pinMode(irqPin, INPUT); // enable INPUT mode on IRQ pin
radio.initialize(FREQUENCY, NODEID, NETWORKID);
#ifdef IS_RFM69HW
radio.setHighPower(); //only for RFM69HW!
#endif
radio.encrypt(ENCRYPTKEY);
radio.promiscuous(promiscuousMode);
char buff[50];
sprintf(buff, "\nThe frequency is %d Mhz, Kenneth!", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
#ifdef ENABLE_ATC
Serial.println("RFM69_ATC Enabled (Auto Transmission Control)");
#endif
}
void loop() {
if (radio.receiveDone()) {
if (radio.DATALEN != sizeof(Payload)) {
Serial.print("Invalid Payload received!");
} else {
theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else
if (DEBUG) {
Serial.print("Node:");
Serial.print(theData.nodeId);
Serial.print(", Temp:");
Serial.print(theData.temp);
Serial.print(", Lux:");
Serial.print(theData.lx);
Serial.print(", Vcc:");
Serial.print(theData.vcc);
Serial.print(", TX Level:");
Serial.print(theData.tx);
Serial.print(", RSSI:");
Serial.print(radio.RSSI);
}
}
if (radio.ACKRequested()) { // When a node requests an ACK, respond to the ACK
radio.sendACK();
Serial.print(" - ACK sent.");
}
Serial.println();
}
}
Code:
RFM69_Arduino_to_Teensy3.2_Receiver.ino: In function 'void loop()':
RFM69_Arduino_to_Teensy3.2_Receiver\RFM69_Arduino_to_Teensy3.2_Receiver.ino:105:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else
^
RFM69_Arduino_to_Teensy3.2_Receiver\RFM69_Arduino_to_Teensy3.2_Receiver.ino:105:15: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
theData = *(Payload*)radio.DATA; //assume radio.DATA actually contains our struct and not something else
^
Last edited: