Commit 7c6e1b56 authored by Hermann Mayer's avatar Hermann Mayer

Fixed variable lenght package sending.

parent 9c4cc683
// #define FirmwareVersion 0.2.1
//
// #include "vendor/arduino/Arduino.h"
//
// #include "lib/common.h"
// #include "lib/chip/io/atmega328.h"
//
// int main(void)
// {
// // Init Wiring
// init();
//
// // Setup slave and further hardware
// ATmega328 *slave = new ATmega328();
//
// for (;;)
// {
// slave->write(13, HIGH);
// _delay_ms(300);
// slave->write(13, LOW);
// _delay_ms(1000);
//
// // Development Pin Loop
// // pinJob(&ATmega328, 13, LEDBlink, 1000);
// }
//
// return 0;
// }
#define FirmwareVersion 0.2.1
#include "../vendor/arduino/Arduino.h"
#include "../vendor/rfm70/rfm70.h"
......@@ -41,7 +13,7 @@ char buffer[50];
void log(const char* message)
{
snprintf(buffer, 50, "[%15d] %s", (int) millis(), message);
snprintf(buffer, 50, "[%11ld] %s", millis(), message);
Serial.println((const char*) buffer);
}
......@@ -52,16 +24,16 @@ void log(String message)
void logBuffer(uint8_t length)
{
Serial.print("[Raw Message] ");
// Serial.print("[Raw Message] ");
for(byte i=1; i<length; i++) {
// for(byte i=1; i<length; i++) {
Serial.print("0x");
Serial.print(RFM70_buf[i], HEX);
Serial.print(", ");
}
// Serial.print("0x");
// Serial.print(RFM70_buf[i], HEX);
// Serial.print(", ");
// }
Serial.println("");
// Serial.println("");
Serial.print("[ Message] ");
for(byte i=1; i<length; i++) {
......@@ -105,18 +77,10 @@ int main(void)
init();
Serial.begin(9600);
Serial.println("Arduino Start");
RFM70.begin();
RFM70.Initialize();
RFMSendTime = millis();
log(String("CE: ") + String(CE, DEC));
log(String("CSN: ") + String(CSN, DEC));
log(String("SCK: ") + String(SCK, DEC));
log(String("MISO: ") + String(MISO, DEC));
log(String("MOSI: ") + String(MOSI, DEC));
log(String("IRQ: ") + String(IRQ, DEC));
char message[] = "Slave #1: Hello.";
for (;;)
......@@ -125,18 +89,13 @@ int main(void)
if (millis() > RFMSendTime) //send packet
{
RFMSendTime = millis() + RFMSendSpeed;
// RFM70_buf[0]=0X41;
// RFM70_buf[1]=0X42;
// RFM70_buf[2]=0X43;
// RFM70_buf[3]=0X44;
// Copy over message to buffer
for(unsigned int i = 0; i < sizeof(message); i++)
RFM70_buf[i] = (byte)message[i];
RFM70_buf[i+1] = (byte)message[i];
RFM70.Send_Packet(WR_TX_PLOAD,RFM70_buf,4);
RFM70.Send_Packet(WR_TX_PLOAD, RFM70_buf, sizeof(message));
log("Sending data");
// logBuffer(sizeof(RFM70_buf));
}
}
......
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