51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#include <Arduino.h>
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include "pins.h"
|
|
#include "wifi.h"
|
|
#include "mqtt.h"
|
|
|
|
#if defined(DEVICE_ROLE_BOAT)
|
|
constexpr const char *deviceRole = "boat";
|
|
#elif defined(DEVICE_ROLE_REMOTE)
|
|
constexpr const char *deviceRole = "remote";
|
|
#else
|
|
#error "Select DEVICE_ROLE_BOAT or DEVICE_ROLE_REMOTE in platformio.ini"
|
|
#endif
|
|
|
|
#if defined(NETWORK_MODE_MQTT)
|
|
constexpr const char *networkMode = "mqtt";
|
|
#elif defined(NETWORK_MODE_AP)
|
|
constexpr const char *networkMode = "ap";
|
|
#else
|
|
#error "Select NETWORK_MODE_MQTT or NETWORK_MODE_AP in platformio.ini"
|
|
#endif
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
delay(100);
|
|
|
|
pinMode(Pins::batteryVoltage, INPUT);
|
|
|
|
#if defined(DEVICE_ROLE_BOAT)
|
|
pinMode(Pins::motorLeftForward, OUTPUT);
|
|
pinMode(Pins::motorLeftReverse, OUTPUT);
|
|
pinMode(Pins::motorRightForward, OUTPUT);
|
|
pinMode(Pins::motorRightReverse, OUTPUT);
|
|
pinMode(Pins::rudderServo, OUTPUT);
|
|
#else
|
|
pinMode(Pins::hallRudderSignal, INPUT);
|
|
#endif
|
|
|
|
WifiSetup();
|
|
setupMQTT();
|
|
Serial.printf("Stid maritime: role=%s, mode=%s, chip=%06X\n",
|
|
deviceRole, networkMode, ESP.getChipId());
|
|
Serial.println("Firmware skeleton ready; motors remain stopped.");
|
|
}
|
|
|
|
void loop() {
|
|
// Keep the initial firmware passive until the command and failsafe layers exist.
|
|
delay(1000);
|
|
}
|