diff --git a/cybergarden-aggregator/lib/TransmitterModule/TransmitterModule.h b/cybergarden-aggregator/lib/TransmitterModule/TransmitterModule.h index b57f4b6..79ece7c 100644 --- a/cybergarden-aggregator/lib/TransmitterModule/TransmitterModule.h +++ b/cybergarden-aggregator/lib/TransmitterModule/TransmitterModule.h @@ -14,7 +14,7 @@ private: RH_ASK *rhAsk; public: TransmitterModule() { - rhAsk = new RH_ASK(2000, 4, 5, 0); + rhAsk = new RH_ASK(2000, 5, 4, 0); } bool init() { return rhAsk->init(); diff --git a/cybergarden-aggregator/platformio.ini b/cybergarden-aggregator/platformio.ini index 9b58c2e..24bbb6d 100644 --- a/cybergarden-aggregator/platformio.ini +++ b/cybergarden-aggregator/platformio.ini @@ -15,5 +15,4 @@ framework = arduino monitor_speed = 115200 lib_deps = mikem/RadioHead@^1.120 - bblanchon/ArduinoJson@^6.21.3 rweather/Crypto@^0.4.0 diff --git a/cybergarden-aggregator/src/main.cpp b/cybergarden-aggregator/src/main.cpp index dee7707..fbdf17e 100644 --- a/cybergarden-aggregator/src/main.cpp +++ b/cybergarden-aggregator/src/main.cpp @@ -12,7 +12,6 @@ #endif #include "Uuid.h" -#include String serverName = "http://gw.cg.k-lab.su/api/v1/measures/register"; @@ -99,9 +98,13 @@ bool sendPayload(MeasureData &data) { MeasureData data; void loop() { - data.sensor_id = 0; - data.sensor_type = 1; - data.payload = rand() & 0xffff; - sendPayload(data); - delay(5000); + if (transmissionModule.receive(sensor_id, data)) { + data.sensor_id = sensor_id; + data.sensor_type = data.sensor_type; + data.payload = data.payload; + analogWrite(LED_BUILTIN, 255); + sendPayload(data); + delay(100); + analogWrite(LED_BUILTIN, 0); + } } \ No newline at end of file diff --git a/cybergarden-sensor/lib/TransmissionModule/TransmissionModule.cpp b/cybergarden-sensor/lib/TransmissionModule/TransmissionModule.cpp index 96191b5..061a01b 100644 --- a/cybergarden-sensor/lib/TransmissionModule/TransmissionModule.cpp +++ b/cybergarden-sensor/lib/TransmissionModule/TransmissionModule.cpp @@ -25,12 +25,8 @@ void TransmissionModule::transmit(MeasureData &data) cipher->addAuthData(authdata + posn, len); } - for (posn = 0; posn < data_size; posn += inc) { - len = data_size - posn; - if (len > inc) - len = inc; - cipher->encrypt(buffer + posn, (uint8_t*)&data + 1 + posn, len); - } + cipher->encrypt(buffer + 1, (uint8_t*)&data, data_size); + buffer[0] = data.sensor_id; //************************* //Encryption Testing @@ -55,10 +51,7 @@ void TransmissionModule::transmit(MeasureData &data) // Serial.println("works"); // } - uint8_t msg[MSG_LENGTH]; - msg[0] = data.sensor_id; - memcpy(msg + 1, (void *) &data, 4); uint8_t encoded[MSG_LENGTH + ECC_LENGTH]; - reedSolomonModule->encode(msg, encoded); + reedSolomonModule->encode(buffer, encoded); transmitterModule->send(encoded, MSG_LENGTH + ECC_LENGTH); } diff --git a/cybergarden-sensor/lib/TransmitterModule/TransmitterModule.h b/cybergarden-sensor/lib/TransmitterModule/TransmitterModule.h index 94bdae9..6fae96f 100644 --- a/cybergarden-sensor/lib/TransmitterModule/TransmitterModule.h +++ b/cybergarden-sensor/lib/TransmitterModule/TransmitterModule.h @@ -8,8 +8,8 @@ #ifndef KEMPT_KINKAJOU_TRANSMITTERMODULE_H #define KEMPT_KINKAJOU_TRANSMITTERMODULE_H -#define RH_TRANSMIT_PIN 5 -#define RH_RECEIVE_PIN 4 +#define RH_TRANSMIT_PIN 4 +#define RH_RECEIVE_PIN 5 class TransmitterModule { private: