| 142 | } |
| 143 | |
| 144 | void onClientConnect(void* arg, AsyncClient* client) { |
| 145 | Serial.println("New client connected"); |
| 146 | if (autoFlashStep == AUTOFLASH_USBFLASHER_RUNNING) { |
| 147 | #ifdef HAS_TFT |
| 148 | if (tftOverride == true) { |
| 149 | tft2.fillRect(0, 62, tft2.width(), 18, TFT_BLUE); |
| 150 | tft2.setCursor(10, 63, 2); |
| 151 | tft2.setTextColor(TFT_GREEN); |
| 152 | tft2.print("TCP connected"); |
| 153 | } |
| 154 | #endif |
| 155 | } else { |
| 156 | autoFlashStep = AUTOFLASH_START_USBFLASHER; |
| 157 | } |
| 158 | webFlashMode = FLASHMODE_OFF; |
| 159 | if (connectedClient == NULL) { |
| 160 | connectedClient = client; |
| 161 | client->onData(&onDataReceived, NULL); |
| 162 | client->onDisconnect([](void* arg, AsyncClient* c) { |
| 163 | Serial.println("Client disconnected"); |
| 164 | |
| 165 | if (zbsflasherp != nullptr) { |
| 166 | zbsflasherp->zbs->reset(); |
| 167 | delete zbsflasherp; |
| 168 | zbsflasherp = nullptr; |
| 169 | } |
| 170 | |
| 171 | pinMode(FLASHER_EXT_MISO, INPUT); |
| 172 | pinMode(FLASHER_EXT_CLK, INPUT); |
| 173 | |
| 174 | #ifdef HAS_TFT |
| 175 | if (autoFlashStep == AUTOFLASH_USBFLASHER_RUNNING && tftOverride == true) { |
| 176 | tft2.fillRect(0, 62, tft2.width(), 18, TFT_BLUE); |
| 177 | tft2.setCursor(10, 63, 2); |
| 178 | tft2.setTextColor(TFT_YELLOW); |
| 179 | tft2.print("TCP disconnected"); |
| 180 | } |
| 181 | #endif |
| 182 | connectedClient = NULL; |
| 183 | }); |
| 184 | } else { |
| 185 | client->close(true); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void sendDataToClient(const uint8_t* data, size_t len) { |
| 190 | if (connectedClient != NULL) { |
nothing calls this directly
no test coverage detected