/*
 * mainloop.h
 *
 *  Created on: Sep 11, 2019
 *      Author: abody
 */

#ifndef MAINLOOP_H_
#define MAINLOOP_H_

#if defined(__cplusplus)
extern "C" {
#endif

void MainLoop();

#if defined(__cplusplus)
}
#endif

#if defined(__cplusplus)
#include <f4ll_cpp/serialconsole.h>
#include "globals.h"

struct GlobalsInitializer {
	GlobalsInitializer(f4ll_cpp::SerialConsole<257> *console) {
		g_console = console;
	}
};

class Application : public GlobalsInitializer, public f4ll_cpp::SerialConsole<257>::ISerialConsoleCallback {
public:
	Application();
	void Loop();

private:
	virtual void LineReceived(void *userParam, f4ll_cpp::SerialConsole<257>::Buffer *buffer);
	virtual void TransmissionComplete(void *userParam, f4ll_cpp::SerialConsole<257>::Buffer *buffer);

	f4ll_cpp::SerialConsole<257>	m_console;
	volatile bool m_lineReceived = false;
	volatile f4ll_cpp::SerialConsole<257>::Buffer *m_rcvdBuffer;
	char m_appBuffer[128];

	volatile bool m_transmissionCompleted = true;
};
#endif	//	__cplusplus


#endif /* MAINLOOP_H_ */
