<commit_before>#include <RS485.h>
#include <SoftwareSerial.h>

#include "globals.h"
#include "WiredCommunication.h"
#include "XBeeCommunication.h"

#define MAX_SENSORS 32
String baseId = "ZZZZZ";
//String nodeId = "test1";

SoftwareSerial xbee(5, 6); // RX, TX
WiredCommunication wiredbus;
XBeeCommunication xcomm("test1");//Change here for different nodes


int  numSensors = -1; // Starts off at 99 so that the base recognizes first message as startup message. SET TO 3 FOR TESTING
int retryCount = 0;//retry count for adding messages to queue
int check = 0;//checks for success of adding to queue
String messageFromBase = "";


char sensorStatus[MAX_SENSORS]; // keeps track of status of each sensor
bool dataChanged = false; // Set to true if any sensor's status has changed. XBee only sends if this is true.
bool sendOk = false;
int sendCount;

/*
    Setup block
    Initializes communication protocols and initiates other setup related tasks.
*/
void setup()
{
    DEBUG_INIT(9600);
    DEBUG_PRINTLN("New System Startup - Sender");

    xbee.begin(9600);
    
    // Wait for sensors to power up and calibrate
    delay(2000);
	
    DEBUG_PRINTLN(numSensors); delay(2000);
	String response = "";
    
    while(numSensors < 0){
		sendOk = xcomm.sendMessage(baseId, "N");
		if(sendOk){
			response = xcomm.getMessage();
			xcomm.sendMessage(baseId, "OK");
			response.trim();
			numSensors = response.toInt();
			DEBUG_PRINTLN(numSensors);
		}
    }
    
    //numSensors = 3;//used for demo-ing
}

void loop()
{
    /*
        Loops through all the sensors asking for a status.
        Records the responses or time outs in sensorStatus[]
    */<commit_msg>Fixed Node Parsing<commit_after>#include <RS485.h>
#include <SoftwareSerial.h>

#include "globals.h"
#include "WiredCommunication.h"
#include "XBeeCommunication.h"

#define MAX_SENSORS 32
String baseId = "00000";
//String nodeId = "test1";

SoftwareSerial xbee(5, 6); // RX, TX
WiredCommunication wiredbus;
XBeeCommunication xcomm("test1");//Change here for different nodes


int  numSensors = -1; // Starts off at 99 so that the base recognizes first message as startup message. SET TO 3 FOR TESTING
int retryCount = 0;//retry count for adding messages to queue
int check = 0;//checks for success of adding to queue
String messageFromBase = "";


char sensorStatus[MAX_SENSORS]; // keeps track of status of each sensor
bool dataChanged = false; // Set to true if any sensor's status has changed. XBee only sends if this is true.
bool sendOk = false;
int sendCount;

/*
    Setup block
    Initializes communication protocols and initiates other setup related tasks.
*/
void setup()
{
    DEBUG_INIT(9600);
    DEBUG_PRINTLN("New System Startup - Sender");

    xbee.begin(9600);
    
    // Wait for sensors to power up and calibrate
    delay(2000);
	
    DEBUG_PRINTLN(numSensors); delay(2000);
	String response = "";
    
    while(numSensors < 0){
		sendOk = xcomm.sendMessage(baseId, "N");
		if(sendOk){
			response = xcomm.getMessage();
			xcomm.sendMessage(baseId, "OK");
			
			uint8_t start = 0;
			uint8_t end = response.indexOf(',');
			
			start = end + 1;
			end = response.indexOf(',', start);
			String numberResponse = response.substring(start, end);
		
			numberResponse.trim();
			numSensors = numberResponse.toInt();
			DEBUG_PRINTLN(numSensors);
		}
    }
    
    //numSensors = 3;//used for demo-ing
}

void loop()
{
    /*
        Loops through all the sensors asking for a status.
        Records the responses or time outs in sensorStatus[]
    */
{'fraction_non_alphanumeric': 0.10797060486150367, 'fraction_numerical': 0.0211984171848502, 'mean_word_length': 3.4684343434343434, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '4472201', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1096, 'n_words': 370}