|
|
@ -21,33 +21,49 @@ void CommunicationsController::initWifi() {
|
|
|
|
void CommunicationsController::init() {
|
|
|
|
void CommunicationsController::init() {
|
|
|
|
initOta();
|
|
|
|
initOta();
|
|
|
|
initWifi();
|
|
|
|
initWifi();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (WiFi.status() != WL_CONNECTED);
|
|
|
|
|
|
|
|
|
|
|
|
WebMonitor.begin();
|
|
|
|
WebMonitor.begin();
|
|
|
|
|
|
|
|
l4sServer.begin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CommunicationsController::process() {
|
|
|
|
byte CommunicationsController::process(float *azimuth, float *altitude) {
|
|
|
|
ArduinoOTA.handle();
|
|
|
|
ArduinoOTA.handle();
|
|
|
|
|
|
|
|
create_connection();
|
|
|
|
|
|
|
|
|
|
|
|
if (!l4s) {
|
|
|
|
if (l4s) {
|
|
|
|
return;
|
|
|
|
while (l4s.connected()) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (l4s.connected()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handle_client();
|
|
|
|
handle_client();
|
|
|
|
} else {
|
|
|
|
byte resp = parseLook4Sat(azimuth, altitude);
|
|
|
|
create_connection();
|
|
|
|
ArduinoOTA.handle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resp == 1) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CommunicationsController::handle_client() {
|
|
|
|
void CommunicationsController::handle_client() {
|
|
|
|
l4s.flush();
|
|
|
|
l4s.flush();
|
|
|
|
received = recv();
|
|
|
|
received = recv();
|
|
|
|
WebMonitor.println(received);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CommunicationsController::parseLook4Sat(float* azimuth, float* altitude) {
|
|
|
|
byte CommunicationsController::parseLook4Sat(float* azimuth, float* altitude) {
|
|
|
|
*azimuth = received.substring(0, 3).toFloat();
|
|
|
|
String tmp = received.substring(9);
|
|
|
|
*altitude = received.substring(3, 6).toFloat(); //TODO
|
|
|
|
int spaceIndex = tmp.indexOf(' ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (spaceIndex != -1) {
|
|
|
|
|
|
|
|
*azimuth = tmp.substring(0, spaceIndex).toFloat();
|
|
|
|
|
|
|
|
*altitude = tmp.substring(spaceIndex+1).toFloat();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CommunicationsController::create_connection() {
|
|
|
|
void CommunicationsController::create_connection() {
|
|
|
|