Commit ec7d483e authored by Hermann Mayer's avatar Hermann Mayer

Improved chat demo.

parent beae7261
...@@ -11,37 +11,22 @@ unsigned long RFMSendTime = 0; //next send time ...@@ -11,37 +11,22 @@ unsigned long RFMSendTime = 0; //next send time
int RFMSendSpeed=1000; //send packet every 1000 msec int RFMSendSpeed=1000; //send packet every 1000 msec
char buffer[50]; char buffer[50];
void log(const char* message) void log(const char* info, const char* message = "")
{ {
snprintf(buffer, 50, "[%11ld] %s", millis(), message); snprintf(buffer, 50, "[%10ld %-20s] %s", millis(), info, message);
Serial.println((const char*) buffer); Serial.println((const char*) buffer);
} }
void log(String message) void logBuffer(const char* info, const char* message, uint8_t length)
{ {
Serial.println(message); snprintf(buffer, 50, "[%10ld %-20s] %s", millis(), info, message);
} Serial.print((const char*) buffer);
void logBuffer(uint8_t length)
{
// Serial.print("[Raw Message] ");
// for(byte i=1; i<length; i++) {
// Serial.print("0x");
// Serial.print(RFM70_buf[i], HEX);
// Serial.print(", ");
// }
// Serial.println("");
Serial.print("[ Message] ");
for(byte i=1; i<length; i++) { for(byte i=1; i<length; i++) {
Serial.write(RFM70_buf[i]); Serial.write(RFM70_buf[i]);
} }
Serial.println(""); Serial.println();
} }
//RFM70 event handler //RFM70 event handler
...@@ -65,7 +50,7 @@ void rfmTask() ...@@ -65,7 +50,7 @@ void rfmTask()
byte rx_len = RFM70.Receive_Packet(RFM70_buf); byte rx_len = RFM70.Receive_Packet(RFM70_buf);
if (rx_len) { if (rx_len) {
logBuffer(rx_len); logBuffer("Msg Rec", "<< ", rx_len);
} }
} }
} }
...@@ -110,6 +95,7 @@ int main(void) ...@@ -110,6 +95,7 @@ int main(void)
RFM70.Send_Packet(WR_TX_PLOAD, RFM70_buf, recLen+1); RFM70.Send_Packet(WR_TX_PLOAD, RFM70_buf, recLen+1);
log("Sending data"); log("Sending data");
logBuffer("Msg Send", ">> ", recLen);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment