Added macro for controling serial port
This commit is contained in:
parent
b6fcf94191
commit
411cec08c7
@ -153,8 +153,8 @@ bool Config::saveFile() {
|
|||||||
createJson(doc);
|
createJson(doc);
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serializeJson(doc, configFile);
|
serializeJson(doc, configFile);
|
||||||
@ -192,8 +192,8 @@ bool Config::loadFile() {
|
|||||||
DynamicJsonDocument doc(3000);
|
DynamicJsonDocument doc(3000);
|
||||||
DeserializationError err = deserializeJson(doc, configFile);
|
DeserializationError err = deserializeJson(doc, configFile);
|
||||||
#if LOG_LEVEL == 6
|
#if LOG_LEVEL == 6
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
@ -395,8 +395,8 @@ bool AdvancedConfig::saveFile() {
|
|||||||
doc[PARAM_HW_IGNORE_LOW_ANGLES] = this->isIgnoreLowAnges();
|
doc[PARAM_HW_IGNORE_LOW_ANGLES] = this->isIgnoreLowAnges();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serializeJson(doc, configFile);
|
serializeJson(doc, configFile);
|
||||||
@ -434,8 +434,8 @@ bool AdvancedConfig::loadFile() {
|
|||||||
DynamicJsonDocument doc(512);
|
DynamicJsonDocument doc(512);
|
||||||
DeserializationError err = deserializeJson(doc, configFile);
|
DeserializationError err = deserializeJson(doc, configFile);
|
||||||
#if LOG_LEVEL == 6
|
#if LOG_LEVEL == 6
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
|
@ -314,14 +314,14 @@ void GyroSensor::calibrateSensor() {
|
|||||||
Log.verbose(F("GYRO: Calibrating sensor" CR));
|
Log.verbose(F("GYRO: Calibrating sensor" CR));
|
||||||
#endif
|
#endif
|
||||||
// accelgyro.PrintActiveOffsets();
|
// accelgyro.PrintActiveOffsets();
|
||||||
// Serial.print( CR );
|
// EspSerial.print( CR );
|
||||||
|
|
||||||
accelgyro.setDLPFMode(MPU6050_DLPF_BW_5);
|
accelgyro.setDLPFMode(MPU6050_DLPF_BW_5);
|
||||||
accelgyro.CalibrateAccel(6); // 6 = 600 readings
|
accelgyro.CalibrateAccel(6); // 6 = 600 readings
|
||||||
accelgyro.CalibrateGyro(6);
|
accelgyro.CalibrateGyro(6);
|
||||||
|
|
||||||
accelgyro.PrintActiveOffsets();
|
accelgyro.PrintActiveOffsets();
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
|
|
||||||
_calibrationOffset.ax = accelgyro.getXAccelOffset();
|
_calibrationOffset.ax = accelgyro.getXAccelOffset();
|
||||||
_calibrationOffset.ay = accelgyro.getYAccelOffset();
|
_calibrationOffset.ay = accelgyro.getYAccelOffset();
|
||||||
|
@ -203,11 +203,9 @@ void printBuildOptions() {
|
|||||||
|
|
||||||
SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
SerialDebug::SerialDebug(const uint32_t serialSpeed) {
|
||||||
// Start serial with auto-detected rate (default to defined BAUD)
|
// Start serial with auto-detected rate (default to defined BAUD)
|
||||||
//Serial.flush();
|
EspSerial.begin(serialSpeed);
|
||||||
Serial.begin(serialSpeed);
|
EspSerial.println("Serial connection established");
|
||||||
Serial.println("Serial connection established");
|
getLog()->begin(LOG_LEVEL, &EspSerial, true);
|
||||||
|
|
||||||
getLog()->begin(LOG_LEVEL, &Serial, true);
|
|
||||||
getLog()->setPrefix(printTimestamp);
|
getLog()->setPrefix(printTimestamp);
|
||||||
getLog()->notice(F("SDBG: Serial logging started at %u." CR), serialSpeed);
|
getLog()->notice(F("SDBG: Serial logging started at %u." CR), serialSpeed);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <ble.hpp>
|
#include <ble.hpp>
|
||||||
|
#undef LOG_LEVEL_ERROR
|
||||||
|
#undef LOG_LEVEL_INFO
|
||||||
#include <calc.hpp>
|
#include <calc.hpp>
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
#include <gyro.hpp>
|
#include <gyro.hpp>
|
||||||
|
@ -92,4 +92,11 @@ extern RunMode runMode;
|
|||||||
// #define PIN_A0 A4
|
// #define PIN_A0 A4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP32C3) && defined(USE_SERIAL0)
|
||||||
|
#define EspSerial Serial0
|
||||||
|
// #warning "Using Serial0 for output RX/TX pins on ESP32C3"
|
||||||
|
#else
|
||||||
|
#define EspSerial Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // SRC_MAIN_HPP_
|
#endif // SRC_MAIN_HPP_
|
||||||
|
@ -174,11 +174,11 @@ class TemplatingEngine {
|
|||||||
void dumpAll() {
|
void dumpAll() {
|
||||||
int max = sizeof(_items) / sizeof(KeyVal);
|
int max = sizeof(_items) / sizeof(KeyVal);
|
||||||
for (int i = 0; i < max; i++) {
|
for (int i = 0; i < max; i++) {
|
||||||
Serial.print("Key=\'");
|
EspSerial.print("Key=\'");
|
||||||
Serial.print(_items[i].key.c_str());
|
EspSerial.print(_items[i].key.c_str());
|
||||||
Serial.print("\', Val=\'");
|
EspSerial.print("\', Val=\'");
|
||||||
Serial.print(_items[i].val.c_str());
|
EspSerial.print(_items[i].val.c_str());
|
||||||
Serial.println("\'");
|
EspSerial.println("\'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ void WebServerHandler::webHandleConfig() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -280,8 +280,8 @@ void WebServerHandler::webHandleStatus() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -631,8 +631,8 @@ void WebServerHandler::webHandleConfigAdvancedRead() {
|
|||||||
doc[PARAM_HW_IGNORE_LOW_ANGLES] = myAdvancedConfig.isIgnoreLowAnges();
|
doc[PARAM_HW_IGNORE_LOW_ANGLES] = myAdvancedConfig.isIgnoreLowAnges();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -714,8 +714,8 @@ void WebServerHandler::webHandleFormulaRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String out;
|
String out;
|
||||||
@ -829,8 +829,8 @@ void WebServerHandler::webHandleTestPush() {
|
|||||||
doc.clear();
|
doc.clear();
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
serializeJson(doc, Serial);
|
serializeJson(doc, EspSerial);
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_server->send(200, "application/json", out.c_str());
|
_server->send(200, "application/json", out.c_str());
|
||||||
@ -921,8 +921,8 @@ void WebServerHandler::webHandleConfigFormatRead() {
|
|||||||
out += "\"}";
|
out += "\"}";
|
||||||
|
|
||||||
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(WEB_DISABLE_LOGGING)
|
||||||
Serial.print(out.c_str());
|
EspSerial.print(out.c_str());
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_server->send(200, "application/json", out.c_str());
|
_server->send(200, "application/json", out.c_str());
|
||||||
|
@ -176,23 +176,23 @@ void WifiConnection::connectAsync(int wifiIndex) {
|
|||||||
|
|
||||||
bool WifiConnection::waitForConnection(int maxTime) {
|
bool WifiConnection::waitForConnection(int maxTime) {
|
||||||
#if DEBUG_LEVEL == 6
|
#if DEBUG_LEVEL == 6
|
||||||
WiFi.printDiag(Serial);
|
WiFi.printDiag(EspSerial);
|
||||||
#endif
|
#endif
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
if (i % 10) Serial.print(".");
|
if (i % 10) EspSerial.print(".");
|
||||||
|
|
||||||
if (i++ >
|
if (i++ >
|
||||||
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
||||||
writeErrorLog("WIFI: Failed to connect to wifi %d", WiFi.status());
|
writeErrorLog("WIFI: Failed to connect to wifi %d", WiFi.status());
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
return false; // Return to main that we have failed to connect.
|
return false; // Return to main that we have failed to connect.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial.print(CR);
|
EspSerial.print(CR);
|
||||||
Log.notice(F("WIFI: Connected to wifi %s ip=%s." CR), WiFi.SSID().c_str(),
|
Log.notice(F("WIFI: Connected to wifi %s ip=%s." CR), WiFi.SSID().c_str(),
|
||||||
getIPAddress().c_str());
|
getIPAddress().c_str());
|
||||||
Log.notice(F("WIFI: Using mDNS name %s." CR), myConfig.getMDNS());
|
Log.notice(F("WIFI: Using mDNS name %s." CR), myConfig.getMDNS());
|
||||||
|
Loading…
Reference in New Issue
Block a user