virtual_portal.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. #include "virtual_portal.h"
  2. #include "wav_player_hal.h"
  3. #include "string.h"
  4. #include <stm32wbxx_ll_dma.h>
  5. #include <furi_hal.h>
  6. #define TAG "VirtualPortal"
  7. #define BLOCK_SIZE 16
  8. #define PORTAL_SIDE_RING 0
  9. #define PORTAL_SIDE_RIGHT 0
  10. #define PORTAL_SIDE_TRAP 1
  11. #define PORTAL_SIDE_LEFT 2
  12. const NotificationSequence sequence_set_backlight = {
  13. &message_display_backlight_on,
  14. &message_do_not_reset,
  15. NULL,
  16. };
  17. const NotificationSequence sequence_set_leds = {
  18. &message_red_0,
  19. &message_blue_0,
  20. &message_green_0,
  21. &message_do_not_reset,
  22. NULL,
  23. };
  24. static float lerp(float start, float end, float t) {
  25. return start + (end - start) * t;
  26. }
  27. static void wav_player_dma_isr(void* ctx) {
  28. VirtualPortal* virtual_portal = (VirtualPortal*)ctx;
  29. // half of transfer
  30. if(LL_DMA_IsActiveFlag_HT1(DMA1)) {
  31. LL_DMA_ClearFlag_HT1(DMA1);
  32. if (!virtual_portal->playing_audio) {
  33. return;
  34. }
  35. if (virtual_portal->count < SAMPLES_COUNT / 2) {
  36. virtual_portal->playing_audio = false;
  37. wav_player_speaker_stop();
  38. return;
  39. }
  40. // fill first half of buffer
  41. for (int i = 0; i < SAMPLES_COUNT / 2; i++) {
  42. virtual_portal->audio_buffer[i] = *virtual_portal->tail;
  43. if (++virtual_portal->tail == virtual_portal->end) {
  44. virtual_portal->tail = virtual_portal->current_audio_buffer;
  45. }
  46. virtual_portal->count--;
  47. }
  48. }
  49. // transfer complete
  50. if(LL_DMA_IsActiveFlag_TC1(DMA1)) {
  51. LL_DMA_ClearFlag_TC1(DMA1);
  52. if (!virtual_portal->playing_audio) {
  53. return;
  54. }
  55. if (virtual_portal->count < SAMPLES_COUNT / 2) {
  56. virtual_portal->playing_audio = false;
  57. wav_player_speaker_stop();
  58. return;
  59. }
  60. // fill second half of buffer
  61. for (int i = SAMPLES_COUNT / 2; i < SAMPLES_COUNT; i++) {
  62. virtual_portal->audio_buffer[i] = *virtual_portal->tail;
  63. if (++virtual_portal->tail == virtual_portal->end) {
  64. virtual_portal->tail = virtual_portal->current_audio_buffer;
  65. }
  66. virtual_portal->count--;
  67. }
  68. }
  69. }
  70. void virtual_portal_tick(void* ctx) {
  71. VirtualPortal* virtual_portal = (VirtualPortal*)ctx;
  72. (void)virtual_portal;
  73. VirtualPortalLed* led = &virtual_portal->right;
  74. if (!led->running) {
  75. return;
  76. }
  77. uint32_t elapsed = furi_get_tick() - led->start_time;
  78. if (elapsed < led->delay) {
  79. float t_phase = fminf((float)elapsed / (float)led->delay, 1);
  80. if (led->two_phase) {
  81. if (led->current_phase == 0) {
  82. // Phase 1: Increase channels that need to go up, hold others constant
  83. if (led->target_r > led->last_r) {
  84. led->r = lerp(led->last_r, led->target_r, t_phase);
  85. }
  86. if (led->target_g > led->last_g) {
  87. led->g = lerp(led->last_g, led->target_g, t_phase);
  88. }
  89. if (led->target_b > led->last_b) {
  90. led->b = lerp(led->last_b, led->target_b, t_phase);
  91. }
  92. } else {
  93. // Phase 2: Decrease channels that need to go down
  94. if (led->target_r < led->last_r) {
  95. led->r = lerp(led->last_r, led->target_r, t_phase);
  96. }
  97. if (led->target_g < led->last_g) {
  98. led->g = lerp(led->last_g, led->target_g, t_phase);
  99. }
  100. if (led->target_b < led->last_b) {
  101. led->b = lerp(led->last_b, led->target_b, t_phase);
  102. }
  103. }
  104. } else {
  105. // Simple one-phase transition: all channels change together
  106. led->r = lerp(led->last_r, led->target_r, t_phase);
  107. led->g = lerp(led->last_g, led->target_g, t_phase);
  108. led->b = lerp(led->last_b, led->target_b, t_phase);
  109. }
  110. furi_hal_light_set(LightRed, led->r);
  111. furi_hal_light_set(LightGreen, led->g);
  112. furi_hal_light_set(LightBlue, led->b);
  113. } else if (led->two_phase && led->current_phase == 0) {
  114. // Move to phase 2 - save the current state as our "last" values for phase 2
  115. led->last_r = led->r;
  116. led->last_g = led->g;
  117. led->last_b = led->b;
  118. led->start_time = furi_get_tick();
  119. led->current_phase++;
  120. } else {
  121. // Transition complete - set final values
  122. led->r = led->target_r;
  123. led->g = led->target_g;
  124. led->b = led->target_b;
  125. furi_hal_light_set(LightRed, led->r);
  126. furi_hal_light_set(LightGreen, led->g);
  127. furi_hal_light_set(LightBlue, led->b);
  128. led->running = false;
  129. }
  130. }
  131. void queue_led_command(VirtualPortal* virtual_portal, int side, uint8_t r, uint8_t g, uint8_t b, uint16_t duration) {
  132. VirtualPortalLed* led = &virtual_portal->left;
  133. switch (side) {
  134. case PORTAL_SIDE_RIGHT:
  135. led = &virtual_portal->right;
  136. break;
  137. case PORTAL_SIDE_TRAP:
  138. led = &virtual_portal->trap;
  139. break;
  140. case PORTAL_SIDE_LEFT:
  141. led = &virtual_portal->left;
  142. break;
  143. }
  144. // Store current values as last values
  145. led->last_r = led->r;
  146. led->last_g = led->g;
  147. led->last_b = led->b;
  148. // Set target values
  149. led->target_r = r;
  150. led->target_g = g;
  151. led->target_b = b;
  152. if (duration) {
  153. // Determine if we need a two-phase transition
  154. bool increasing = (r > led->last_r) || (g > led->last_g) || (b > led->last_b);
  155. bool decreasing = (r < led->last_r) || (g < led->last_g) || (b < led->last_b);
  156. led->two_phase = increasing && decreasing;
  157. // Set up transition parameters
  158. led->start_time = furi_get_tick();
  159. if (led->two_phase) {
  160. // If two-phase, each phase gets half the duration
  161. led->delay = duration / 2;
  162. } else {
  163. led->delay = duration;
  164. }
  165. // Start in phase 0
  166. led->current_phase = 0;
  167. led->running = true;
  168. } else {
  169. // Immediate change, no transition
  170. if (side == PORTAL_SIDE_RIGHT) {
  171. led->r = r;
  172. led->g = g;
  173. led->b = b;
  174. furi_hal_light_set(LightRed, r);
  175. furi_hal_light_set(LightGreen, g);
  176. furi_hal_light_set(LightBlue, b);
  177. }
  178. led->running = false;
  179. }
  180. }
  181. VirtualPortal* virtual_portal_alloc(NotificationApp* notifications) {
  182. VirtualPortal* virtual_portal = malloc(sizeof(VirtualPortal));
  183. virtual_portal->notifications = notifications;
  184. notification_message(virtual_portal->notifications, &sequence_set_backlight);
  185. notification_message(virtual_portal->notifications, &sequence_set_leds);
  186. for (int i = 0; i < POF_TOKEN_LIMIT; i++) {
  187. virtual_portal->tokens[i] = pof_token_alloc();
  188. }
  189. virtual_portal->sequence_number = 0;
  190. virtual_portal->active = false;
  191. virtual_portal->volume = 10.0f;
  192. virtual_portal->led_timer = furi_timer_alloc(virtual_portal_tick,
  193. FuriTimerTypePeriodic, virtual_portal);
  194. virtual_portal->head = virtual_portal->current_audio_buffer;
  195. virtual_portal->tail = virtual_portal->current_audio_buffer;
  196. virtual_portal->end = &virtual_portal->current_audio_buffer[SAMPLES_COUNT_BUFFERED];
  197. furi_timer_start(virtual_portal->led_timer, 10);
  198. if(furi_hal_speaker_acquire(1000)) {
  199. virtual_portal->got_speaker = true;
  200. wav_player_speaker_init(8000);
  201. wav_player_dma_init((uint32_t)virtual_portal->audio_buffer, SAMPLES_COUNT);
  202. furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, wav_player_dma_isr, virtual_portal);
  203. wav_player_dma_start();
  204. }
  205. return virtual_portal;
  206. }
  207. void virtual_portal_cleanup(VirtualPortal* virtual_portal) {
  208. notification_message(virtual_portal->notifications, &sequence_reset_rgb);
  209. notification_message(virtual_portal->notifications, &sequence_display_backlight_on);
  210. }
  211. void virtual_portal_free(VirtualPortal* virtual_portal) {
  212. for (int i = 0; i < POF_TOKEN_LIMIT; i++) {
  213. pof_token_free(virtual_portal->tokens[i]);
  214. virtual_portal->tokens[i] = NULL;
  215. }
  216. furi_timer_stop(virtual_portal->led_timer);
  217. furi_timer_free(virtual_portal->led_timer);
  218. if (virtual_portal->got_speaker) {
  219. furi_hal_speaker_release();
  220. wav_player_speaker_stop();
  221. wav_player_dma_stop();
  222. }
  223. wav_player_hal_deinit();
  224. furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL);
  225. free(virtual_portal);
  226. }
  227. void virtaul_portal_set_leds(uint8_t r, uint8_t g, uint8_t b) {
  228. furi_hal_light_set(LightRed, r);
  229. furi_hal_light_set(LightGreen, g);
  230. furi_hal_light_set(LightBlue, b);
  231. }
  232. void virtaul_portal_set_backlight(uint8_t brightness) {
  233. furi_hal_light_set(LightBacklight, brightness);
  234. }
  235. void virtual_portal_load_token(VirtualPortal* virtual_portal, PoFToken* pof_token) {
  236. furi_assert(pof_token);
  237. FURI_LOG_D(TAG, "virtual_portal_load_token");
  238. PoFToken* target = NULL;
  239. uint8_t empty[4] = {0, 0, 0, 0};
  240. // first try to "reload" to the same slot it used before based on UID
  241. for (int i = 0; i < POF_TOKEN_LIMIT; i++) {
  242. if (memcmp(virtual_portal->tokens[i]->UID, pof_token->UID, sizeof(pof_token->UID)) == 0) {
  243. // Found match
  244. if (virtual_portal->tokens[i]->loaded) {
  245. // already loaded, no-op
  246. return;
  247. } else {
  248. FURI_LOG_D(TAG, "Found matching UID at index %d", i);
  249. target = virtual_portal->tokens[i];
  250. break;
  251. }
  252. }
  253. }
  254. // otherwise load into first slot with no set UID
  255. if (target == NULL) {
  256. for (int i = 0; i < POF_TOKEN_LIMIT; i++) {
  257. if (memcmp(virtual_portal->tokens[i]->UID, empty, sizeof(empty)) == 0) {
  258. FURI_LOG_D(TAG, "Found empty UID at index %d", i);
  259. // By definition an empty UID slot would not be loaded, so I'm not checking. Fight me.
  260. target = virtual_portal->tokens[i];
  261. break;
  262. }
  263. }
  264. }
  265. // Re-use first unloaded slot
  266. if (target == NULL) {
  267. for (int i = 0; i < POF_TOKEN_LIMIT; i++) {
  268. if (virtual_portal->tokens[i]->loaded == false) {
  269. FURI_LOG_D(TAG, "Re-using previously used slot %d", i);
  270. target = virtual_portal->tokens[i];
  271. break;
  272. }
  273. }
  274. }
  275. if (target == NULL) {
  276. FURI_LOG_W(TAG, "Failed to find slot to token into");
  277. return;
  278. }
  279. furi_assert(target);
  280. // TODO: make pof_token_copy()
  281. target->change = pof_token->change;
  282. target->loaded = pof_token->loaded;
  283. memcpy(target->dev_name, pof_token->dev_name, sizeof(pof_token->dev_name));
  284. memcpy(target->UID, pof_token->UID, sizeof(pof_token->UID));
  285. const NfcDeviceData* data = nfc_device_get_data(pof_token->nfc_device, NfcProtocolMfClassic);
  286. nfc_device_set_data(target->nfc_device, NfcProtocolMfClassic, data);
  287. }
  288. uint8_t virtual_portal_next_sequence(VirtualPortal* virtual_portal) {
  289. if (virtual_portal->sequence_number == 0xff) {
  290. virtual_portal->sequence_number = 0;
  291. }
  292. return virtual_portal->sequence_number++;
  293. }
  294. int virtual_portal_activate(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
  295. FURI_LOG_D(TAG, "process %c", message[0]);
  296. virtual_portal->active = message[1] != 0;
  297. response[0] = message[0];
  298. response[1] = message[1];
  299. response[2] = 0xFF;
  300. response[3] = 0x77;
  301. return 4;
  302. }
  303. int virtual_portal_reset(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
  304. FURI_LOG_D(TAG, "process %c", message[0]);
  305. virtual_portal->active = false;
  306. // virtual_portal->sequence_number = 0;
  307. for (int i = 0; i < POF_TOKEN_LIMIT; i++) {
  308. if (virtual_portal->tokens[i]->loaded) {
  309. virtual_portal->tokens[i]->change = true;
  310. }
  311. }
  312. uint8_t index = 0;
  313. response[index++] = 'R';
  314. response[index++] = 0x02;
  315. response[index++] = 0x1B;
  316. // response[index++] = 0x0a;
  317. // response[index++] = 0x03;
  318. // response[index++] = 0x02;
  319. // https://github.com/tresni/PoweredPortals/wiki/USB-Protocols
  320. // Wii Wireless: 01 29 00 00
  321. // Wii Wired: 02 0a 03 02 (Giants: works)
  322. // Arduboy: 02 19 (Trap team: works)
  323. return index;
  324. }
  325. int virtual_portal_status(VirtualPortal* virtual_portal, uint8_t* response) {
  326. response[0] = 'S';
  327. bool update = false;
  328. for (size_t i = 0; i < POF_TOKEN_LIMIT; i++) {
  329. // Can't use bit_lib since it uses the opposite endian
  330. if (virtual_portal->tokens[i]->loaded) {
  331. response[1 + i / 4] |= 1 << ((i % 4) * 2 + 0);
  332. }
  333. if (virtual_portal->tokens[i]->change) {
  334. update = true;
  335. response[1 + i / 4] |= 1 << ((i % 4) * 2 + 1);
  336. }
  337. virtual_portal->tokens[i]->change = false;
  338. }
  339. response[5] = virtual_portal_next_sequence(virtual_portal);
  340. response[6] = 1;
  341. // Let me know when a status that actually has a change is sent
  342. if (update) {
  343. char display[33] = {0};
  344. memset(display, 0, sizeof(display));
  345. for (size_t i = 0; i < BLOCK_SIZE; i++) {
  346. snprintf(display + (i * 2), sizeof(display), "%02x", response[i]);
  347. }
  348. FURI_LOG_I(TAG, "> S %s", display);
  349. }
  350. return 7;
  351. }
  352. int virtual_portal_send_status(VirtualPortal* virtual_portal, uint8_t* response) {
  353. if (virtual_portal->active) {
  354. return virtual_portal_status(virtual_portal, response);
  355. }
  356. return 0;
  357. }
  358. // 4d01ff0000d0077d6c2a77a400000000
  359. int virtual_portal_m(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
  360. virtual_portal->speaker = (message[1] == 1);
  361. /*
  362. char display[33] = {0};
  363. for(size_t i = 0; i < BLOCK_SIZE; i++) {
  364. snprintf(display + (i * 2), sizeof(display), "%02x", message[i]);
  365. }
  366. FURI_LOG_I(TAG, "M %s", display);
  367. */
  368. size_t index = 0;
  369. response[index++] = 'M';
  370. response[index++] = message[1];
  371. response[index++] = 0x00;
  372. response[index++] = 0x19;
  373. return index;
  374. }
  375. int virtual_portal_l(VirtualPortal* virtual_portal, uint8_t* message) {
  376. UNUSED(virtual_portal);
  377. /*
  378. char display[33] = {0};
  379. memset(display, 0, sizeof(display));
  380. for(size_t i = 0; i < BLOCK_SIZE; i++) {
  381. snprintf(display + (i * 2), sizeof(display), "%02x", message[i]);
  382. }
  383. FURI_LOG_I(TAG, "L %s", display);
  384. */
  385. uint8_t side = message[1]; // 0: left, 2: right
  386. uint8_t brightness = 0;
  387. switch (side) {
  388. case 0:
  389. case 2:
  390. queue_led_command(virtual_portal, side, message[2], message[3], message[4], 0);
  391. break;
  392. case 1:
  393. brightness = message[2];
  394. virtaul_portal_set_backlight(brightness);
  395. break;
  396. case 3:
  397. brightness = 0xff;
  398. virtaul_portal_set_backlight(brightness);
  399. break;
  400. }
  401. return 0;
  402. }
  403. int virtual_portal_j(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
  404. /*
  405. char display[33] = {0};
  406. memset(display, 0, sizeof(display));
  407. for(size_t i = 0; i < BLOCK_SIZE; i++) {
  408. snprintf(display + (i * 2), sizeof(display), "%02x", message[i]);
  409. }
  410. FURI_LOG_I(TAG, "J %s", display);
  411. */
  412. uint8_t side = message[1];
  413. uint16_t delay = message[6] << 8 | message[5];
  414. queue_led_command(virtual_portal, side, message[2], message[3], message[4], delay);
  415. // Delay response
  416. // furi_delay_ms(delay); // causes issues
  417. // UNUSED(delay);
  418. // https://marijnkneppers.dev/posts/reverse-engineering-skylanders-toys-to-life-mechanics/
  419. size_t index = 0;
  420. response[index++] = 'J';
  421. return index;
  422. }
  423. int virtual_portal_query(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
  424. int index = message[1];
  425. int blockNum = message[2];
  426. int arrayIndex = index & 0x0f;
  427. FURI_LOG_I(TAG, "Query %d %d", arrayIndex, blockNum);
  428. PoFToken* pof_token = virtual_portal->tokens[arrayIndex];
  429. if (!pof_token->loaded) {
  430. response[0] = 'Q';
  431. response[1] = 0x00 | arrayIndex;
  432. response[2] = blockNum;
  433. return 3;
  434. }
  435. NfcDevice* nfc_device = pof_token->nfc_device;
  436. const MfClassicData* data = nfc_device_get_data(nfc_device, NfcProtocolMfClassic);
  437. const MfClassicBlock block = data->block[blockNum];
  438. response[0] = 'Q';
  439. response[1] = 0x10 | arrayIndex;
  440. response[2] = blockNum;
  441. memcpy(response + 3, block.data, BLOCK_SIZE);
  442. return 3 + BLOCK_SIZE;
  443. }
  444. int virtual_portal_write(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
  445. int index = message[1];
  446. int blockNum = message[2];
  447. int arrayIndex = index & 0x0f;
  448. char display[33] = {0};
  449. for (size_t i = 0; i < BLOCK_SIZE; i++) {
  450. snprintf(display + (i * 2), sizeof(display), "%02x", message[3 + i]);
  451. }
  452. FURI_LOG_I(TAG, "Write %d %d %s", arrayIndex, blockNum, display);
  453. PoFToken* pof_token = virtual_portal->tokens[arrayIndex];
  454. if (!pof_token->loaded) {
  455. response[0] = 'W';
  456. response[1] = 0x00 | arrayIndex;
  457. response[2] = blockNum;
  458. return 3;
  459. }
  460. NfcDevice* nfc_device = pof_token->nfc_device;
  461. MfClassicData* data = mf_classic_alloc();
  462. nfc_device_copy_data(nfc_device, NfcProtocolMfClassic, data);
  463. MfClassicBlock* block = &data->block[blockNum];
  464. memcpy(block->data, message + 3, BLOCK_SIZE);
  465. nfc_device_set_data(nfc_device, NfcProtocolMfClassic, data);
  466. mf_classic_free(data);
  467. response[0] = 'W';
  468. response[1] = 0x10 | arrayIndex;
  469. response[2] = blockNum;
  470. return 3;
  471. }
  472. void virtual_portal_process_audio(
  473. VirtualPortal* virtual_portal,
  474. uint8_t* message,
  475. uint8_t len) {
  476. for (size_t i = 0; i < len; i += 2) {
  477. int16_t int_16 =
  478. (((int16_t)message[i + 1]) + ((int16_t)message[i] << 8));
  479. float data = (((float)int_16 / INT16_MAX) * 2) - 1;
  480. data *= virtual_portal->volume; // volume
  481. data = tanhf(data); // hyperbolic tangent limiter
  482. data *= UINT8_MAX / 2; // scale -128..127
  483. data += UINT8_MAX / 2; // to unsigned
  484. if (data < 0) {
  485. data = 0;
  486. }
  487. if (data > 255) {
  488. data = 255;
  489. }
  490. *virtual_portal->head = data;
  491. virtual_portal->count++;
  492. if (++virtual_portal->head == virtual_portal->current_audio_buffer + sizeof(virtual_portal->current_audio_buffer)) {
  493. virtual_portal->head = virtual_portal->current_audio_buffer;
  494. }
  495. }
  496. if (!virtual_portal->playing_audio && virtual_portal->count > SAMPLES_COUNT / 2) {
  497. wav_player_speaker_start();
  498. virtual_portal->playing_audio = true;
  499. }
  500. }
  501. // 32 byte message, 32 byte response;
  502. int virtual_portal_process_message(
  503. VirtualPortal* virtual_portal,
  504. uint8_t* message,
  505. uint8_t* response) {
  506. memset(response, 0, 32);
  507. switch (message[0]) {
  508. case 'A':
  509. return virtual_portal_activate(virtual_portal, message, response);
  510. case 'C': // Ring color R G B
  511. queue_led_command(virtual_portal, PORTAL_SIDE_RING, message[1], message[2], message[3], 0);
  512. return 0;
  513. case 'J':
  514. // https://github.com/flyandi/flipper_zero_rgb_led
  515. return virtual_portal_j(virtual_portal, message, response);
  516. case 'L':
  517. return virtual_portal_l(virtual_portal, message);
  518. case 'M':
  519. return virtual_portal_m(virtual_portal, message, response);
  520. case 'Q': // Query
  521. return virtual_portal_query(virtual_portal, message, response);
  522. case 'R':
  523. return virtual_portal_reset(virtual_portal, message, response);
  524. case 'S': // Status
  525. return virtual_portal_status(virtual_portal, response);
  526. case 'V':
  527. return 0;
  528. case 'W': // Write
  529. return virtual_portal_write(virtual_portal, message, response);
  530. case 'Z':
  531. return 0;
  532. default:
  533. FURI_LOG_W(TAG, "Unhandled command %c", message[0]);
  534. return 0; // No response
  535. }
  536. return 0;
  537. }