43 lines
929 B
Arduino
43 lines
929 B
Arduino
|
|
||
|
#include "RS-FEC.h"
|
||
|
|
||
|
char message[] = "Amogus is very suspicious creature!";
|
||
|
const int msglen = 60;
|
||
|
const uint8_t ECC_LENGTH = 10; //Max message lenght, and "gurdian bytes", Max corrected bytes ECC_LENGTH/2
|
||
|
char message_frame[msglen]; // The message size would be different, so need a container
|
||
|
char repaired[msglen];
|
||
|
char encoded[msglen + ECC_LENGTH];
|
||
|
|
||
|
RS::ReedSolomon<msglen, ECC_LENGTH> rs;
|
||
|
|
||
|
#define ir_mod_pin 12
|
||
|
|
||
|
void setup() {
|
||
|
pinMode(ir_mod_pin, OUTPUT);
|
||
|
tone(ir_mod_pin, 38000);
|
||
|
|
||
|
Serial.begin(1200);
|
||
|
while (!Serial); // wait for serial to initialize
|
||
|
|
||
|
memset(message_frame, 0, sizeof(message_frame)); // Clear the array
|
||
|
|
||
|
for(int i = 0; i <= msglen; i++) {
|
||
|
message_frame[i] = message[i];
|
||
|
} // Fill with the message
|
||
|
|
||
|
rs.Encode(message_frame, encoded);
|
||
|
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
|
||
|
for(int i = 0; i < sizeof(encoded); i++) {
|
||
|
Serial.print(encoded[i]);
|
||
|
}
|
||
|
|
||
|
Serial.println("");
|
||
|
|
||
|
delay(2500);
|
||
|
|
||
|
|
||
|
}
|