| 339 | CC_interface *ccflasherp = nullptr; |
| 340 | |
| 341 | void processFlasherCommand(struct flasherCommand* cmd, uint8_t transportType) { |
| 342 | uint8_t* tempbuffer; |
| 343 | uint8_t temp_buff[16]; |
| 344 | uint32_t spi_speed = 0; |
| 345 | uint8_t powerPinCount = 1; |
| 346 | static uint32_t curspeed = 0; |
| 347 | uint8_t numPowerPins; |
| 348 | |
| 349 | #ifdef HAS_RGB_LED |
| 350 | shortBlink(CRGB::White); |
| 351 | #else |
| 352 | quickBlink(2); |
| 353 | #endif |
| 354 | |
| 355 | switch (cmd->command) { |
| 356 | case CMD_GET_VERSION: |
| 357 | wsSerial("> get version"); |
| 358 | temp_buff[0] = FLASHER_VERSION >> 24; |
| 359 | temp_buff[1] = FLASHER_VERSION >> 16; |
| 360 | temp_buff[2] = FLASHER_VERSION >> 8; |
| 361 | temp_buff[3] = FLASHER_VERSION; |
| 362 | sendFlasherAnswer(cmd->command, temp_buff, 4, transportType); |
| 363 | break; |
| 364 | case CMD_RESET_ESP: |
| 365 | wsSerial("reset"); |
| 366 | sendFlasherAnswer(cmd->command, NULL, 0, transportType); |
| 367 | delay(100); |
| 368 | ESP.restart(); |
| 369 | break; |
| 370 | case CMD_SET_POWER: |
| 371 | wsSerial("> power"); |
| 372 | switch (selectedFlasherPort) { |
| 373 | case 0: |
| 374 | numPowerPins = sizeof(powerPins); |
| 375 | powerControl(cmd->data[0], (uint8_t*)powerPins, numPowerPins); |
| 376 | break; |
| 377 | case 1: |
| 378 | numPowerPins = sizeof(powerPins2); |
| 379 | powerControl(cmd->data[0], (uint8_t*)powerPins2, numPowerPins); |
| 380 | break; |
| 381 | case 2: |
| 382 | numPowerPins = sizeof(powerPins3); |
| 383 | powerControl(cmd->data[0], (uint8_t*)powerPins3, numPowerPins); |
| 384 | break; |
| 385 | } |
| 386 | sendFlasherAnswer(CMD_SET_POWER, NULL, 0, transportType); |
| 387 | break; |
| 388 | case CMD_RESET: |
| 389 | wsSerial("> reset tag"); |
| 390 | if (zbsflasherp != nullptr) { |
| 391 | zbsflasherp->zbs->reset(); |
| 392 | delete zbsflasherp; |
| 393 | zbsflasherp = nullptr; |
| 394 | } |
| 395 | if (nrfflasherp != nullptr) { |
| 396 | nrfflasherp->nrf_soft_reset(); |
| 397 | delete nrfflasherp; |
| 398 | nrfflasherp = nullptr; |
no test coverage detected