Moved all serial strings to flash to save RAM
This commit is contained in:
parent
b5e1ff2ef1
commit
2d9f4a3f46
3 changed files with 53 additions and 53 deletions
|
@ -21,14 +21,14 @@ void setup() {
|
|||
ledsHigh();
|
||||
|
||||
bluetooth.begin(9600);
|
||||
Serial.println("[HC05] Port open!");
|
||||
Serial.println(F("[HC05] Port open!"));
|
||||
|
||||
Serial.print("[RF69] Initializing ... ");
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
byte state = rf.begin();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
|
@ -38,7 +38,7 @@ void setup() {
|
|||
ledsLow();
|
||||
digitalWrite(LED_START_OK, HIGH);
|
||||
|
||||
Serial.println("[HC05] Waiting for incoming data ... ");
|
||||
Serial.println(F("[HC05] Waiting for incoming data ... "));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -48,15 +48,15 @@ void loop() {
|
|||
while(bluetooth.available() > 0) {
|
||||
digitalWrite(LED_RECEIVING, HIGH);
|
||||
char receivedCharacter = bluetooth.read();
|
||||
Serial.print("[HC05] ");
|
||||
Serial.print(F("[HC05] "));
|
||||
Serial.print(receivedCharacter);
|
||||
Serial.print("\t 0x");
|
||||
Serial.print(F("\t 0x"));
|
||||
Serial.println(receivedCharacter, HEX);
|
||||
digitalWrite(LED_RECEIVING, LOW);
|
||||
if(receivedCharacter != '\n') {
|
||||
receivedString += receivedCharacter;
|
||||
} else {
|
||||
Serial.print("[HC05] Received string: ");
|
||||
Serial.print(F("[HC05] Received string: "));
|
||||
Serial.println(receivedString);
|
||||
receivedFlag = true;
|
||||
break;
|
||||
|
@ -67,16 +67,16 @@ void loop() {
|
|||
digitalWrite(LED_TRANSMITING, HIGH);
|
||||
receivedFlag = false;
|
||||
Packet pack("01:23:45:67:89:AB:CD:EF", receivedString.c_str());
|
||||
Serial.print("[RF69] Transmitting packet ... ");
|
||||
Serial.print(F("[RF69] Transmitting packet ... "));
|
||||
byte state = rf.transmit(pack);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
}
|
||||
digitalWrite(LED_TRANSMITING, LOW);
|
||||
Serial.println("[HC05] Waiting for incoming data ... ");
|
||||
Serial.println(F("[HC05] Waiting for incoming data ... "));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,57 +22,57 @@ void setup() {
|
|||
|
||||
ledsHigh();
|
||||
|
||||
Serial.print("[XBee] Initializing ... ");
|
||||
Serial.print(F("[XBee] Initializing ... "));
|
||||
byte state = bee.begin(9600);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
ledsLow();
|
||||
delay(BLINK_DELAY);
|
||||
ledsHigh();
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
while(true);
|
||||
}
|
||||
|
||||
Serial.print("[XBee] Setting PAN ID ... ");
|
||||
Serial.print(F("[XBee] Setting PAN ID ... "));
|
||||
state = bee.setPanId("0123456789ABCDEF");
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
ledsLow();
|
||||
delay(BLINK_DELAY);
|
||||
ledsHigh();
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
while(true);
|
||||
}
|
||||
|
||||
Serial.print("[XBee] Setting destination address ... ");
|
||||
Serial.print(F("[XBee] Setting destination address ... "));
|
||||
state = bee.setDestinationAddress("0013A200", "40A58A5D");
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
ledsLow();
|
||||
delay(BLINK_DELAY);
|
||||
ledsHigh();
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
while(true);
|
||||
}
|
||||
|
||||
Serial.print("[RF69] Initializing ... ");
|
||||
Serial.print(F("[RF69] Initializing ... "));
|
||||
state = rf.begin();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
|
@ -84,42 +84,42 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("[RF69] Waiting for incoming transmission ... ");
|
||||
Serial.print(F("[RF69] Waiting for incoming transmission ... "));
|
||||
byte state = rf.receive(pack);
|
||||
|
||||
if(state == ERR_NONE) {
|
||||
digitalWrite(LED_RECEIVING, HIGH);
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
|
||||
char str[24];
|
||||
|
||||
pack.getSourceStr(str);
|
||||
Serial.print("[RF69] Source:\t\t");
|
||||
Serial.print(F("[RF69] Source:\t\t"));
|
||||
Serial.println(str);
|
||||
|
||||
pack.getDestinationStr(str);
|
||||
Serial.print("[RF69] Destination:\t");
|
||||
Serial.print(F("[RF69] Destination:\t"));
|
||||
Serial.println(str);
|
||||
|
||||
Serial.print("[RF69] Length:\t\t");
|
||||
Serial.print(F("[RF69] Length:\t\t"));
|
||||
Serial.println(pack.length);
|
||||
|
||||
Serial.print("[RF69] Data:\t\t");
|
||||
Serial.print(F("[RF69] Data:\t\t"));
|
||||
Serial.println(pack.data);
|
||||
|
||||
digitalWrite(LED_RECEIVING, LOW);
|
||||
|
||||
Serial.print("[XBee] Sending packet ... ");
|
||||
Serial.print(F("[XBee] Sending packet ... "));
|
||||
digitalWrite(LED_TRANSMITING, HIGH);
|
||||
bee.println(pack.data);
|
||||
digitalWrite(LED_TRANSMITING, LOW);
|
||||
Serial.println("done!");
|
||||
Serial.println(F("done!"));
|
||||
|
||||
} else if(state == ERR_RX_TIMEOUT) {
|
||||
Serial.println("timeout!");
|
||||
Serial.println(F("timeout!"));
|
||||
|
||||
} else if(state == ERR_CRC_MISMATCH) {
|
||||
Serial.println("CRC error!");
|
||||
Serial.println(F("CRC error!"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,57 +20,57 @@ void setup() {
|
|||
|
||||
ledsHigh();
|
||||
|
||||
Serial.print("[XBee] Initializing ... ");
|
||||
Serial.print(F("[XBee] Initializing ... "));
|
||||
byte state = bee.begin(9600);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
ledsLow();
|
||||
delay(BLINK_DELAY);
|
||||
ledsHigh();
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
while(true);
|
||||
}
|
||||
|
||||
Serial.print("[XBee] Setting PAN ID ... ");
|
||||
Serial.print(F("[XBee] Setting PAN ID ... "));
|
||||
state = bee.setPanId("0123456789ABCDEF");
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
ledsLow();
|
||||
delay(BLINK_DELAY);
|
||||
ledsHigh();
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
while(true);
|
||||
}
|
||||
|
||||
Serial.print("[XBee] Setting destination address ... ");
|
||||
Serial.print(F("[XBee] Setting destination address ... "));
|
||||
state = bee.setDestinationAddress("0013A200", "40A58A5D");
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
ledsLow();
|
||||
delay(BLINK_DELAY);
|
||||
ledsHigh();
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
while(true);
|
||||
}
|
||||
|
||||
Serial.print("[SX1278] Initializing ... ");
|
||||
Serial.print(F("[SX1278] Initializing ... "));
|
||||
state = lora.begin();
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
ledsLow();
|
||||
digitalWrite(LED_START_ERROR, HIGH);
|
||||
|
@ -80,7 +80,7 @@ void setup() {
|
|||
ledsLow();
|
||||
digitalWrite(LED_START_OK, HIGH);
|
||||
|
||||
Serial.println("[XBee] Waiting for incoming data ... ");
|
||||
Serial.println(F("[XBee] Waiting for incoming data ... "));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -90,15 +90,15 @@ void loop() {
|
|||
while(bee.available() > 0) {
|
||||
digitalWrite(LED_RECEIVING, HIGH);
|
||||
char receivedCharacter = bee.read();
|
||||
Serial.print("[XBee] ");
|
||||
Serial.print(F("[XBee] "));
|
||||
Serial.print(receivedCharacter);
|
||||
Serial.print("\t 0x");
|
||||
Serial.print(F("\t 0x"));
|
||||
Serial.println(receivedCharacter, HEX);
|
||||
digitalWrite(LED_RECEIVING, LOW);
|
||||
if((receivedCharacter != '\n') && (receivedCharacter != '\r')) {
|
||||
receivedString += receivedCharacter;
|
||||
} else if(receivedCharacter != '\n') {
|
||||
Serial.print("[XBee] Received string: ");
|
||||
Serial.print(F("[XBee] Received string: "));
|
||||
Serial.println(receivedString);
|
||||
receivedFlag = true;
|
||||
break;
|
||||
|
@ -109,12 +109,12 @@ void loop() {
|
|||
digitalWrite(LED_TRANSMITING, HIGH);
|
||||
receivedFlag = false;
|
||||
Packet pack("01:23:45:67:89:AB:CD:EF", receivedString.c_str());
|
||||
Serial.print("[SX1278] Transmitting packet ... ");
|
||||
Serial.print(F("[SX1278] Transmitting packet ... "));
|
||||
byte state = lora.transmit(pack);
|
||||
if(state == ERR_NONE) {
|
||||
Serial.println("success!");
|
||||
Serial.println(F("success!"));
|
||||
} else {
|
||||
Serial.print("failed, code 0x");
|
||||
Serial.print(F("failed, code 0x"));
|
||||
Serial.println(state, HEX);
|
||||
}
|
||||
digitalWrite(LED_TRANSMITING, LOW);
|
||||
|
|
Loading…
Add table
Reference in a new issue