diff options
author | Lesha Lomalkin <reg@lomalkin.ru> | 2021-12-04 16:40:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-04 16:40:17 +0300 |
commit | 4b8653e061175245b469cb309eaa6deb4c9ff5bc (patch) | |
tree | 4f59bd8edfac67a8c68e1276ecf93f0991c25084 /applications/subghz | |
parent | c2c17c761ef789e4e5b7d81e49cc6e98198e907e (diff) |
Subghz chat: add vibration on input message, send joined/left events … (#863)
* SubGhz: add vibration on input chat message, send joined/left events to room on start and exit app.
* SubGhz: optimize notification api usage
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
Diffstat (limited to 'applications/subghz')
-rw-r--r-- | applications/subghz/subghz_cli.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index 5246e478..cd6c6ac2 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -11,6 +11,8 @@ #include <lib/subghz/protocols/subghz_protocol_princeton.h> #include <lib/subghz/subghz_tx_rx_worker.h> +#include <notification/notification-messages.h> + #define SUBGHZ_FREQUENCY_RANGE_STR \ "299999755...348000000 or 386999938...464000000 or 778999847...928000000" @@ -388,14 +390,22 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) { string_init(input); string_t name; string_init(name); + string_t sysmsg; + string_init(sysmsg); char c; bool exit = false; + NotificationApp* notification = furi_record_open("notification"); + string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr()); string_set(input, name); printf("%s", string_get_cstr(input)); fflush(stdout); + string_printf(sysmsg, "\033[0;34m%s joined chat.\033[0m", furi_hal_version_get_name_ptr()); + subghz_tx_rx_worker_write( + subghz_txrx, (uint8_t*)string_get_cstr(sysmsg), strlen(string_get_cstr(sysmsg))); + while(!exit) { if(furi_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) { if(c == CliSymbolAsciiETX) { @@ -435,14 +445,23 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) { printf("%s", string_get_cstr(input)); fflush(stdout); + + notification_message(notification, &sequence_single_vibro); } osDelay(1); } + string_printf(sysmsg, "\033[0;31m%s left chat.\033[0m", furi_hal_version_get_name_ptr()); + subghz_tx_rx_worker_write( + subghz_txrx, (uint8_t*)string_get_cstr(sysmsg), strlen(string_get_cstr(sysmsg))); + osDelay(10); + printf("\r\nExit chat\r\n"); string_clear(input); string_clear(name); + string_clear(sysmsg); furi_hal_power_suppress_charge_exit(); + furi_record_close("notification"); if(subghz_tx_rx_worker_is_running(subghz_txrx)) { subghz_tx_rx_worker_stop(subghz_txrx); |