<commit_before>/**
 * @file at_drv.h
 * @brief The definition of class at_drv for the ESP8266. 
 * @author <NAME><<EMAIL>
 * @author <NAME><<EMAIL>> 
 * @date 2015.08
 * 
 * @par Copyright:
 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
 * Copyright (c) 2015 Logos Electromechanical LLC \n\n
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version. \n\n
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
#include "utility/at_drv.h"
#include <IPAddress.h>
#include <avr/pgmspace.h>

#define LOG_OUTPUT_DEBUG            (1)
#define LOG_OUTPUT_DEBUG_PREFIX     (1)

#define logDebug(arg)\
    do {\
        if (LOG_OUTPUT_DEBUG)\
        {\
            if (LOG_OUTPUT_DEBUG_PREFIX)\
            {\
                Serial.print("[LOG Debug: ");\
                Serial.print((const char*)__FILE__);\
                Serial.print(",");\
                Serial.print((unsigned int)__LINE__);\
                Serial.print(",");\
                Serial.print((const char*)__FUNCTION__);\
                Serial.print("] ");\
            }\
            Serial.print(arg);\
        }\
    } while(0)
		
// This flag tells the event handler whether incoming data should be treated
// as coming on one of the muxes (true) or whether it's a response to something.
bool IPDenable = true;

// Grab the serial stream when it comes in, assuming we are not waiting on other things
void serialEvent1(void) {
	if (IPDenable) {
		// place incoming data in appropriate buffer
	}
}

ATDrvClass::ATDrvClass(HardwareSerial &uart, uint32_t baud): m_puart(&uart)
{
    m_puart->begin(baud);
	m_puart->setTimeout(WL_AT_TIMEOUT);
    rx_empty();
	for (uint8_t i; i < MAX_SOCK_NUM; i++) {
		_rx_buffer_head[i] = 0;
		_rx_buffer_tail[i] = 0;
		_tx_buffer_head[i] = 0;
		_tx_buffer_tail[i] = 0;
	}
}

void ATDrvClass::rx_empty(void) 
{
    while(m_puart->available() > 0) {<commit_msg>Implemented the receive buffer interrupt handler. Now to see if it compiles!<commit_after>/**
 * @file at_drv.h
 * @brief The definition of class at_drv for the ESP8266. 
 * @author <NAME><<EMAIL>
 * @author <NAME><<EMAIL>> 
 * @date 2015.08
 * 
 * @par Copyright:
 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
 * Copyright (c) 2015 Logos Electromechanical LLC \n\n
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version. \n\n
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
#include "utility/at_drv.h"
#include <IPAddress.h>
#include <avr/pgmspace.h>

#define LOG_OUTPUT_DEBUG            (1)
#define LOG_OUTPUT_DEBUG_PREFIX     (1)

#define logDebug(arg)\
    do {\
        if (LOG_OUTPUT_DEBUG)\
        {\
            if (LOG_OUTPUT_DEBUG_PREFIX)\
            {\
                Serial.print("[LOG Debug: ");\
                Serial.print((const char*)__FILE__);\
                Serial.print(",");\
                Serial.print((unsigned int)__LINE__);\
                Serial.print(",");\
                Serial.print((const char*)__FUNCTION__);\
                Serial.print("] ");\
            }\
            Serial.print(arg);\
        }\
    } while(0)
		
// This flag tells the event handler whether incoming data should be treated
// as coming on one of the muxes (true) or whether it's a response to something.
bool IPDenable = true;

// Grab the serial stream when it comes in, assuming we are not waiting on other things
void serialEvent1(void) {
	uint16_t count = 0;
	if (IPDenable) {
		// place incoming data in appropriate buffer
		if(Serial1.find(F("+IPD,"))) {
			uint8_t mux = Serial1.parseInt();	// figure out which mux
			Serial1.find(F(","));
			uint16_t len = Serial1.parseInt();	// figure out how much data is inbound
			while(Serial1.available() && (count < len)) {
				if (!putCharRX(mux, Serial1.read())) {
					while (Serial1.available()) Serial1.read();
					WARN("More incoming serial data than room in the buffer -- dumping & exiting");
					break;
				} else count++;
			}
		}
		while (Serial1.available()) Serial1.read();
	}
}

ATDrvClass::ATDrvClass(HardwareSerial &uart, uint32_t baud): m_puart(&uart)
{
    m_puart->begin(baud);
	m_puart->setTimeout(WL_AT_TIMEOUT);
    rx_empty();
	for (uint8_t i; i < MAX_SOCK_NUM; i++) {
		_rx_buffer_head[i] = 0;
		_rx_buffer_tail[i] = 0;
		_tx_buffer_head[i] = 0;
		_tx_buffer_tail[i] = 0;
	}
}

void ATDrvClass::rx_empty(void) 
{
    while(m_puart->available() > 0) {
{'fraction_non_alphanumeric': 0.11377031612787998, 'fraction_numerical': 0.013931059117699589, 'mean_word_length': 2.9298245614035086, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 25, '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': '5487856', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1719, 'n_words': 595}