<commit_before>/*
   Temperature Server

   Install the library from https://github.com/Links2004/arduinoWebSockets
*/

// Set the WiFi access details
#define WIFI_SSID "******"
#define WIFI_PASS "******"
// Set the MQTT server details
#define MQTT_SERVER "******"
#define MQTT_PORT 1883

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WebSocketsServer.h>
#include <ESP8266WebServer.h>
#include <PubSubClient.h>


// Include the file that has the html.
#include "html.h"
// Include the Denbit library.
#include <Denbit.h>
// Initialize the denbit.
Denbit denbit;



// Assign readable names to the led pin numbers
const int ledRed =  15;
const int ledGreen =  14;
const int ledBlue =  10;

const char* ssid = WIFI_SSID;
const char* password = <PASSWORD>;
const char* mqtt_server = MQTT_SERVER;
uint16_t mqtt_port = MQTT_PORT;

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time the temperature was updated

// How long to wait before temperature readings.
const long interval = 5000;

// The mqtt message
char msg[30];
// The mqtt client id
char client_id[20];

WiFiClient espClient;
PubSubClient mqtt_client(espClient);

ESP8266WebServer server = ESP8266WebServer(80);
WebSocketsServer webSocket = WebSocketsServer(81);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

  switch (type) {
    case WStype_DISCONNECTED:
      Serial.printf("[%u] Disconnected!\n", num);
      break;
    case WStype_CONNECTED: {
        IPAddress ip = webSocket.remoteIP(num);
        Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);

        // send message to client
        webSocket.sendTXT(num, "Connected");
      }
      break;
  }

}

void setup() {
  Serial.begin(115200);
  //Serial.setDebugOutput(true);

  WiFi.begin(ssid, password);
  Serial.println("Connecting");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  String str = WiFi.localIP().toString();
  str.toCharArray(client_id, 30);

  mqtt_client.setServer(mqtt_server, mqtt_port);<commit_msg>Ensure that previous wifi settings are removed<commit_after>/*
   Temperature Server

   Install the library from https://github.com/Links2004/arduinoWebSockets
*/

// Set the WiFi access details
#define WIFI_SSID "******"
#define WIFI_PASS "******"
// Set the MQTT server details
#define MQTT_SERVER "******"
#define MQTT_PORT 1883

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WebSocketsServer.h>
#include <ESP8266WebServer.h>
#include <PubSubClient.h>


// Include the file that has the html.
#include "html.h"
// Include the Denbit library.
#include <Denbit.h>
// Initialize the denbit.
Denbit denbit;



// Assign readable names to the led pin numbers
const int ledRed =  15;
const int ledGreen =  14;
const int ledBlue =  10;

const char* ssid = WIFI_SSID;
const char* password = <PASSWORD>;
const char* mqtt_server = MQTT_SERVER;
uint16_t mqtt_port = MQTT_PORT;

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time the temperature was updated

// How long to wait before temperature readings.
const long interval = 5000;

// The mqtt message
char msg[30];
// The mqtt client id
char client_id[20];

WiFiClient espClient;
PubSubClient mqtt_client(espClient);

ESP8266WebServer server = ESP8266WebServer(80);
WebSocketsServer webSocket = WebSocketsServer(81);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

  switch (type) {
    case WStype_DISCONNECTED:
      Serial.printf("[%u] Disconnected!\n", num);
      break;
    case WStype_CONNECTED: {
        IPAddress ip = webSocket.remoteIP(num);
        Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);

        // send message to client
        webSocket.sendTXT(num, "Connected");
      }
      break;
  }

}

void setup() {
  Serial.begin(115200);
  //Serial.setDebugOutput(true);

    // Ensure that previous wifi settings are removed 
  WiFi.disconnect();
  WiFi.softAPdisconnect(true);

  // "Station" mode
  WiFi.mode(WIFI_STA);

  WiFi.begin(ssid, password);
  Serial.println("Connecting");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  String str = WiFi.localIP().toString();
  str.toCharArray(client_id, 30);

  mqtt_client.setServer(mqtt_server, mqtt_port);
{'fraction_non_alphanumeric': 0.12847708625175105, 'fraction_numerical': 0.024814888933360015, 'mean_word_length': 3.8760975609756096, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, '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': '6745619', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1696, 'n_words': 475}