Commit beae7261 authored by Hermann Mayer's avatar Hermann Mayer

Implemented simple chat.

parent 7c6e1b56
......@@ -81,22 +81,37 @@ int main(void)
RFM70.Initialize();
RFMSendTime = millis();
char message[] = "Slave #1: Hello.";
char messageBuffer[MAX_PACKET_LEN];
uint16_t recLen = 0;
for (;;)
{
rfmTask(); //check for RFM70 event in polling mode
if (millis() > RFMSendTime) //send packet
{
RFMSendTime = millis() + RFMSendSpeed;
// Check for RFM70 event in polling mode
rfmTask();
if (Serial.available() > 0) {
// Clear buffer
for (uint16_t i = 0; i < MAX_PACKET_LEN; i++) {
RFM70_buf[i] = 0x0;
}
// Read serial inputs
recLen = Serial.readBytesUntil('\n', messageBuffer, MAX_PACKET_LEN);
// Copy over message to buffer
for(unsigned int i = 0; i < sizeof(message); i++)
RFM70_buf[i+1] = (byte)message[i];
for(unsigned int i = 0; i < recLen; i++)
RFM70_buf[i+1] = (byte)messageBuffer[i];
RFM70.Send_Packet(WR_TX_PLOAD, RFM70_buf, sizeof(message));
log("Sending data");
}
// Send packet
if (millis() > RFMSendTime)
{
RFMSendTime = millis() + RFMSendSpeed;
RFM70.Send_Packet(WR_TX_PLOAD, RFM70_buf, recLen+1);
log("Sending data");
}
}
}
return 0;
......
......@@ -7,6 +7,7 @@ add_library (Arduino
WInterrupts.c
WMath.cpp
WString.cpp
Stream.cpp
pins_arduino.h
twi.c
Wire.cpp
......
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