<commit_before>// #define DEBUG_MODE
// #define DEBUG_LEVEL_VERBOSE

#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <MqttWrapper.h>
#include <PubSubClient.h>
#include <WiFiHelper.h>
#include "mqtt_configuration.h"


const char* ssid     = "CMMC.32";
const char* pass     = "<PASSWORD>";

MqttWrapper *mqtt;
WiFiHelper *wifi;

void hook_prepare_data(JsonObject** root)
{
    JsonObject& data = (*(*root))["d"];

    data["myName"] = "NAT";
    data["adc"] = analogRead(A0);;

}

void hook_publish_data(char* data)
{
    Serial.print("PUBLISH: ->");
    Serial.println(data);
}

void init_hardware()
{
    Serial.begin(115200);
    pinMode(0, INPUT_PULLUP);
    delay(10);
    Serial.println();
    Serial.println();
}

void init_wifi()
{
    wifi = new WiFiHelper(ssid, pass);
    wifi->on_connected([](const char* message)
    {
        Serial.println (message);
    });
    wifi->on_disconnected([](const char* message)
    {
        Serial.println (message);
    });
    wifi->connect();
}

void init_mqtt()
{
    String organization = String("r6crrd");
    String url = organization + ".messaging.internetofthings.ibmcloud.com";

    mqtt = new MqttWrapper(url.c_str()  , 1883, hook_configuration);

    // publish only; no callback
    mqtt->set_prepare_data_hook(hook_prepare_data, 2000);<commit_msg>Add start text.<commit_after>// #define DEBUG_MODE
// #define DEBUG_LEVEL_VERBOSE

#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <MqttWrapper.h>
#include <PubSubClient.h>
#include <WiFiHelper.h>
#include "mqtt_configuration.h"


const char* ssid     = "CMMC.47";
const char* pass     = "<PASSWORD>";

MqttWrapper *mqtt;
WiFiHelper *wifi;

void hook_prepare_data(JsonObject** root)
{
    JsonObject& data = (*(*root))["d"];

    data["myName"] = "NAT";
    data["adc"] = analogRead(A0);;

}

void hook_publish_data(char* data)
{
    Serial.print("PUBLISH: ->");
    Serial.println(data);
}

void init_hardware()
{
    Serial.begin(115200);
    pinMode(0, INPUT_PULLUP);
    delay(10);
    Serial.println();
    Serial.println();
    Serial.println("START");
}

void init_wifi()
{
    wifi = new WiFiHelper(ssid, pass);
    wifi->on_connecting([](const char* message)
    {
        Serial.println (message);
    });
    wifi->on_connected([](const char* message)
    {
        Serial.println (message);
    });
    wifi->on_disconnected([](const char* message)
    {
        Serial.println (message);
    });
    wifi->connect();
}

void init_mqtt()
{
    String organization = String("r6crrd");
    String url = organization + ".messaging.internetofthings.ibmcloud.com";

    mqtt = new MqttWrapper(url.c_str()  , 1883, hook_configuration);

    // publish only; no callback
    mqtt->set_prepare_data_hook(hook_prepare_data, 2000);
{'fraction_non_alphanumeric': 0.15972473741398044, 'fraction_numerical': 0.018109380659181457, 'mean_word_length': 3.6893039049235994, 'pattern_counts': {'":': 0, '<': 15, '<?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': '7317523', 'n_tokens_mistral': 1055, 'n_tokens_neox': 994, 'n_words': 185}