mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* SerialWifiInterface: misc tidy-ups
This commit is contained in:
parent
669e417e27
commit
5c4ec1bc22
3 changed files with 15 additions and 13 deletions
|
|
@ -194,8 +194,7 @@ build_flags =
|
|||
${Heltec_lora32_v3.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID="\"myssid\""
|
||||
-D WIFI_PWD="\"mypwd\""
|
||||
; -D ENABLE_PRIVATE_KEY_IMPORT=1
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ void SerialWifiInterface::disable() {
|
|||
|
||||
size_t SerialWifiInterface::writeFrame(const uint8_t src[], size_t len) {
|
||||
if (len > MAX_FRAME_SIZE) {
|
||||
Serial.printf("writeFrame(), frame too big, len=%d\n", len);
|
||||
WIFI_DEBUG_PRINTLN("writeFrame(), frame too big, len=%d\n", len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (deviceConnected && len > 0) {
|
||||
if (send_queue_len >= FRAME_QUEUE_SIZE) {
|
||||
Serial.println("writeFrame(), send_queue is full!");
|
||||
WIFI_DEBUG_PRINTLN("writeFrame(), send_queue is full!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -39,27 +39,22 @@ size_t SerialWifiInterface::writeFrame(const uint8_t src[], size_t len) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define SER_WRITE_MIN_INTERVAL 0
|
||||
|
||||
bool SerialWifiInterface::isWriteBusy() const {
|
||||
return millis() < _last_write + SER_WRITE_MIN_INTERVAL; // still too soon to start another write?
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t SerialWifiInterface::checkRecvFrame(uint8_t dest[]) {
|
||||
if (isWriteBusy())
|
||||
return 0;
|
||||
|
||||
if (!client) client = server.available();
|
||||
|
||||
if (client.connected()) {
|
||||
if (!deviceConnected) {
|
||||
Serial.println("Got connexion");
|
||||
WIFI_DEBUG_PRINTLN("Got connection");
|
||||
deviceConnected = true;
|
||||
}
|
||||
} else {
|
||||
if (deviceConnected) {
|
||||
deviceConnected = false;
|
||||
Serial.println("Disconnected");
|
||||
WIFI_DEBUG_PRINTLN("Disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
class SerialWifiInterface : public BaseSerialInterface {
|
||||
bool deviceConnected;
|
||||
bool _isEnabled;
|
||||
uint32_t _pin_code;
|
||||
unsigned long _last_write;
|
||||
unsigned long adv_restart_time;
|
||||
|
||||
|
|
@ -49,3 +48,12 @@ public:
|
|||
size_t writeFrame(const uint8_t src[], size_t len) override;
|
||||
size_t checkRecvFrame(uint8_t dest[]) override;
|
||||
};
|
||||
|
||||
#if WIFI_DEBUG_LOGGING && ARDUINO
|
||||
#include <Arduino.h>
|
||||
#define WIFI_DEBUG_PRINT(F, ...) Serial.printf("WiFi: " F, ##__VA_ARGS__)
|
||||
#define WIFI_DEBUG_PRINTLN(F, ...) Serial.printf("WiFi: " F "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
#define WIFI_DEBUG_PRINT(...) {}
|
||||
#define WIFI_DEBUG_PRINTLN(...) {}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue