72 lines
1.0 KiB
C
72 lines
1.0 KiB
C
#include <arduino.h>
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <ESP8266WiFi.h>
|
|
#include <WiFiUdp.h>
|
|
|
|
#include "../lib/cli/CLI/CLI.h"
|
|
#include "../lib/cli/CMDList/CMDList.h"
|
|
|
|
#include "commands.h"
|
|
|
|
#define WIFI_SSID "UPC46273"
|
|
#define WIFI_PASS "SPHZHKRY"
|
|
#define UDP_PORT 1234
|
|
|
|
#define BOAT_ID 1
|
|
|
|
WiFiUDP UDP;
|
|
|
|
bool running = true;
|
|
CMDList_t* cmdList;
|
|
|
|
bool rxBuffer_overflow = false;
|
|
|
|
int charOut(const char* line)
|
|
{
|
|
// don't print anything
|
|
return 0;
|
|
}
|
|
|
|
void setup() {
|
|
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
|
while (WiFi.status() != WL_CONNECTED)
|
|
{
|
|
delay(100);
|
|
Serial.print(".");
|
|
}
|
|
|
|
UDP.begin(UDP_PORT);
|
|
|
|
running = true;
|
|
|
|
cmdList = getCMDList();
|
|
|
|
// init cli
|
|
CLI_init((CLI_charOutFn)&charOut, cmdList);
|
|
|
|
while (running)
|
|
{
|
|
int packetSize = UDP.parsePacket();
|
|
while (packetSize) {
|
|
char c;
|
|
int len = UDP.read(&c, 1);
|
|
if (len == 1)
|
|
{
|
|
CLI_charIn(c);
|
|
packetSize -= c;
|
|
}
|
|
}
|
|
}
|
|
|
|
CLI_deinit();
|
|
CMDList_deinit(cmdList);
|
|
|
|
return;
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
}
|