<commit_before>// This #include statement was automatically added by the Spark IDE.
#include "application.h"
#include "libraries/AES/AES.h"
#include "libraries/AnalogSensor/AnalogSensor.h"
#include "libraries/DHT/DHT.h"
#include "libraries/HttpClient/HttpClient.h"
#include "key.h"

SYSTEM_MODE(MANUAL);

IPAddress server(192,168,1,174);

DHT dht(D0, DHT22);
AnalogSensor light(A2, 1);
AnalogSensor pot(A4, 2);
String myIDStr = Spark.deviceID();
String API_VERSION = String("v1.0");
HttpClient http;
char path[64];


http_request_t request;
http_response_t response;
http_header_t headers[] = {
    { "Content-Type", "application/json" },
    { "Accept" , "application/json" },
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

void connect_wifi(){
    while(!WiFi.ready()){
        WiFi.connect();
        Serial.println("Connecting to Wifi...");
        delay(500);
    }
}

void setup() {
    Serial.begin(9600);
    light.init();
    pot.init();
    dht.begin();
    RGB.control(true);
    RGB.brightness(5);
    connect_wifi();
    Serial.println("running");
    Serial.println(request.path);
    String s_path = String("/api/"+API_VERSION+"/node/"+myIDStr+"/sensors");
    s_path.toCharArray(path, 64);
    //request.ip = server;
    request.hostname = "crtlabsdev.realtors.org";
    request.port = 80;
    request.path = path;
}

unsigned int nextTime = 0;
void loop() {
    light.read();
    pot.read();
    if (nextTime > millis()) return;
    if(WiFi.ready()){
        char json_body[128];
        char body_out[128];
        sprintf(json_body, "{\"light\":%d , \"pot\":%d, \"temperature\":%.2f, \"humidity\":%.2f}", light.read(), pot.read(), dht.readTemperature(false), dht.readHumidity());
        aes_128_encrypt(json_body, KEY, body_out);<commit_msg>send dummy cookie along to not crush session store<commit_after>// This #include statement was automatically added by the Spark IDE.
#include "application.h"
#include "libraries/AES/AES.h"
#include "libraries/AnalogSensor/AnalogSensor.h"
#include "libraries/DHT/DHT.h"
#include "libraries/HttpClient/HttpClient.h"
#include "key.h"

SYSTEM_MODE(MANUAL);

IPAddress server(192,168,1,174);

DHT dht(D0, DHT22);
AnalogSensor light(A2, 1);
AnalogSensor pot(A4, 2);
String myIDStr = Spark.deviceID();
String API_VERSION = String("v1.0");
HttpClient http;
char path[64];
char cookie[64];


http_request_t request;
http_response_t response;
http_header_t headers[] = {
    { "Content-Type", "application/json" },
    { "Accept" , "application/json" },
    { "Cookie", "lablog=2983749283749287349827349" },
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

void connect_wifi(){
    while(!WiFi.ready()){
        WiFi.connect();
        Serial.println("Connecting to Wifi...");
        delay(500);
    }
}

void setup() {
    Serial.begin(9600);
    light.init();
    pot.init();
    dht.begin();
    RGB.control(true);
    RGB.brightness(5);
    connect_wifi();
    Serial.println("running");
    Serial.println(request.path);
    String s_path = String("/api/"+API_VERSION+"/node/"+myIDStr+"/sensors");
    s_path.toCharArray(path, 64);
    String cook = String("lablog="+myIDStr);
    cook.toCharArray(cookie, 64);
    //request.ip = server;
    request.hostname = "crtlabsdev.realtors.org";
    request.port = 80;
    request.path = path;
}

unsigned int nextTime = 0;
void loop() {
    light.read();
    pot.read();
    if (nextTime > millis()) return;
    if(WiFi.ready()){
        char json_body[128];
        char body_out[128];
        sprintf(json_body, "{\"light\":%d , \"pot\":%d, \"temperature\":%.2f, \"humidity\":%.2f}", light.read(), pot.read(), dht.readTemperature(false), dht.readHumidity());
        aes_128_encrypt(json_body, KEY, body_out);
{'fraction_non_alphanumeric': 0.17204587890104028, 'fraction_numerical': 0.031741797812750064, 'mean_word_length': 3.734848484848485, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4961868', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1322, 'n_words': 264}