<commit_before>#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h>
#include <aisa_BMP180.h>
#include <string.h>

byte mac[] = {0x90, 0xA2, 0xDA, 0x0E, 0xF6, 0x8E};

IPAddress server(192,168,13,14);

EthernetClient client;

aisa_BMP180 * bmp;

const String arduinoName = "indoor_environment";

void setup()
{
    Serial.begin(57600);


    Serial.println(F("configuring ethernet..."));
    if (Ethernet.begin(mac) == 0)
    {
        Serial.println(F("Failed to configure Ethernet using DHCP"));
        while(1){}
    }

    delay(1000);
    Serial.println(F("ethernet configured."));

    bmp = new aisa_BMP180(arduinoName);

}

void loop()
{
    takeBmp180Reading();

    delay(5000);
}


void takeBmp180Reading()
{
    char parameters[110];
    char request[260];

    float degreesCelcius = bmp->getDegreesCelcius();
    float hectoPascals = bmp->getHectoPascals();
    float altitudeInMeters = bmp->getAltitudeInMeters();

    char degreesCelciusBuffer[15];
    char hectoPascalsBuffer[15];
    char altitudeInMetersBuffer[15];

    dtostrf(degreesCelcius, 1, 2, degreesCelciusBuffer);
    dtostrf(hectoPascals, 1, 2, hectoPascalsBuffer);
    dtostrf(altitudeInMeters, 1, 2, altitudeInMetersBuffer);


//    int length = sprintf(parameters, "sensorName=outside-deck&degreesCelcius=%s&hectoPascals=%s&altitudeInMeters=%s",
    int contentLength = sprintf(parameters,
        "{\"sensorName\": \"outside-deck\", \"degreesCelcius\": %s, \"hectoPascals\": %s, \"altitudeInMeters\": %s}",
        degreesCelciusBuffer,
        hectoPascalsBuffer,
        altitudeInMetersBuffer);

    Serial.println(parameters);
    Serial.print(F("Length: "));
    Serial.println(contentLength);


    int requestLength = sprintf(request,
        "POST /api/v1/arduino-home/bmp180 HTTP/1.1\r\nHost: blah\r\nUser-Agent: arduino-ethernet\r\nContent-Length: %d\r\nContent-Type: application/json\r\n\r\n%s\r\n",
        contentLength,
        parameters);

    Serial.println(F("start request -------------"));
    Serial.println(request);
    Serial.println(F("end request ---------------"));

    Serial.print(F("Request length: "));
    Serial.println(requestLength);

    if (client.connect(server, 1337))
    {
        Serial.println(F("connected to server..."));

        client.print(request);
//        client.println(F("Connection: close"));

        while(!client.available()){}

        while(client.available())
        {
            char c = client.read();
            Serial.print(c);
        }

        Serial.println();
        Serial.println();
    }
    else
    {
        Serial.println(F("unable to connect to server"));
    }
    client.stop();
    Serial.println("-----------");
}<commit_msg>indoor_environment with barometric pressure sensor<commit_after>#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h>
#include <aisa_BMP180.h>
#include <aisa_ethernet.h>
#include <string.h>

byte mac[] = {0x90, 0xA2, 0xDA, 0x0E, 0xF6, 0x8E};

IPAddress server(192,168,13,14);

//EthernetClient client;

aisa_ethernet * ethernet;

aisa_BMP180 * bmp;

const String arduinoName = "indoor_environment";

void setup()
{
    Serial.begin(57600);

    Serial.print(F("initializing..."));

    ethernet = new aisa_ethernet(mac);

    if(!ethernet->initialize())
    {
        Serial.println(F("Failed to configure ethernet"));
        while(1){}
    }

    delay(1000);

    bmp = new aisa_BMP180(arduinoName);

    Serial.println(F("done"));
}

void loop()
{
    takeBmp180Reading();

    delay(60000);
}


void takeBmp180Reading()
{
    char parameters[110];

    Serial.print(F("BMP180:"));

    float degreesCelcius = bmp->getDegreesCelcius();
    float hectoPascals = bmp->getHectoPascals();
    float altitudeInMeters = bmp->getAltitudeInMeters();

    char degreesCelciusBuffer[15];
    char hectoPascalsBuffer[15];
    char altitudeInMetersBuffer[15];

    dtostrf(degreesCelcius, 1, 2, degreesCelciusBuffer);
    dtostrf(hectoPascals, 1, 2, hectoPascalsBuffer);
    dtostrf(altitudeInMeters, 1, 2, altitudeInMetersBuffer);

    int contentLength = sprintf(parameters,
        "{\"sensorName\": \"outside-deck\", \"degreesCelcius\": %s, \"hectoPascals\": %s, \"altitudeInMeters\": %s}",
        degreesCelciusBuffer,
        hectoPascalsBuffer,
        altitudeInMetersBuffer);

    if (ethernet->post(server, 1337, "/api/v1/arduino-home/bmp180", parameters))
    {
        Serial.println(F(" Created"));
    }
    else
    {
        Serial.println(F(" error"));
    }
}
{'fraction_non_alphanumeric': 0.15820440183046416, 'fraction_numerical': 0.03573763347134452, 'mean_word_length': 3.3342776203966005, 'pattern_counts': {'":': 8, '<': 18, '<?xml version=': 0, '>': 26, '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': '4821008', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1622, 'n_words': 274}