From 3d1fff533f5fb450c28ef045abd645c4ec07671e Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Thu, 23 Mar 2023 14:54:57 -0400 Subject: [PATCH] Support subghz chat messages. --- .../rock_paper_scissors/rock_paper_scissors.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c b/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c index 0405d11..a1839d2 100644 --- a/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c +++ b/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c @@ -162,6 +162,21 @@ static void rps_receive_data(GameContext* game_context, uint32_t tick) { } sender_name[index] = 0; + // subghz chat sends escape message. Ignore it. + if(index > 10 && message[0] == 0x1B && message[1] == '[' && message[3] == ';' && + message[6] == 'm') { + index = 7; + while(index < len && message[index] != ':' && message[index] != 0x1B) { + sender_name[index] = message[index]; + index++; + } + if(index < len && message[index] == 0x1B) { + // Skip over the "ESC [ 0 m", which is the reset color code. + // We should be at the ':' character. + index += 4; + } + } + // Skip the ':' character & check for a space. if(++index < len) { if(message[index++] != ' ') {