EasyManua.ls Logo

Freenove ESP32 - Page 147

Default Icon
159 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Need support? support@freenove.com
145
Chapter 15 Dog
www.freenove.com
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
void onBleReceived(BLECharacteristic *pCharacteristic) {
std::string rxValue = pCharacteristic->getValue();
static String bleInputString = "";
if (rxValue.length() > 0) {
for (int i = 0; i < rxValue.length(); i++) {
bleInputString += rxValue[i];
if (rxValue[i] == '\n') {
enterMessageQueue(bleInputString);
bleInputString = "";
}
}
}
}
void onWiFiCmdReceived(WiFiClient *client) {
static String wifiInputString = "";
while (client->available()) {
char rv[1024];
int ret = client->read((uint8_t *)rv, sizeof(rv));
for (int i = 0; i < ret; i++) {
wifiInputString += rv[i];
if (rv[i] == '\n') {
Serial.print(wifiInputString);
enterMessageQueue(wifiInputString);
wifiInputString = "";
}
}
}
}
void onWiFiCmdTrasmit(WiFiClient *client) {
if (!mqTx.isEmpty()) {
client->write(mqTx.out().c_str());
}
}
void enterMessageQueue(String msg) {
Serial.print("msg : ");
Serial.print(msg);
switch (msg.charAt(0)) {
case ACTION_INSTALLATION:
case ACTION_CALIBRATE:
case ACTION_UP_DOWN:

Related product manuals