issue #2 - unused var gives errors in latest SDK
This commit is contained in:
parent
b6fef49575
commit
9d123a5963
@ -127,47 +127,47 @@ static void subghz_demo_receive_data(DemoContext* instance) {
|
|||||||
unsigned int number;
|
unsigned int number;
|
||||||
char senderName[9];
|
char senderName[9];
|
||||||
switch (purpose) {
|
switch (purpose) {
|
||||||
case DemoRfPurposeCounter:
|
case DemoRfPurposeCounter:
|
||||||
// We expect this mesage to contain both the count and the sender name.
|
// We expect this mesage to contain both the count and the sender name.
|
||||||
if (sscanf((const char*)message+game_name_len+2, "%04u:%8s", &number, senderName) == 2) {
|
if (sscanf((const char*)message+game_name_len+2, "%04u:%8s", &number, senderName) == 2) {
|
||||||
// IMPORTANT: The code processing the event needs to furi_string_free the senderName!
|
// IMPORTANT: The code processing the event needs to furi_string_free the senderName!
|
||||||
FuriString* name = furi_string_alloc();
|
FuriString* name = furi_string_alloc();
|
||||||
furi_string_set(name, senderName);
|
furi_string_set(name, senderName);
|
||||||
// The counter is supposed to be a 4 digit number.
|
// The counter is supposed to be a 4 digit number.
|
||||||
if (number >= 10000U) {
|
if (number >= 10000U) {
|
||||||
FURI_LOG_W(TAG, "Number was >= 10000U. >%s<", message);
|
FURI_LOG_W(TAG, "Number was >= 10000U. >%s<", message);
|
||||||
number %= 10000U;
|
number %= 10000U;
|
||||||
}
|
|
||||||
DemoEvent event = {.type = DemoEventReceivedCounter, .number = number, .senderName = name};
|
|
||||||
furi_message_queue_put(instance->queue, &event, FuriWaitForever);
|
|
||||||
} else {
|
|
||||||
FURI_LOG_W(TAG, "Failed to parse counter message. >%s<", message);
|
|
||||||
}
|
}
|
||||||
|
DemoEvent event = {.type = DemoEventReceivedCounter, .number = number, .senderName = name};
|
||||||
|
furi_message_queue_put(instance->queue, &event, FuriWaitForever);
|
||||||
|
} else {
|
||||||
|
FURI_LOG_W(TAG, "Failed to parse counter message. >%s<", message);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DemoRfPurposeTone:
|
case DemoRfPurposeTone:
|
||||||
// We expect this message to contain both the frequency and the sender name.
|
// We expect this message to contain both the frequency and the sender name.
|
||||||
if (sscanf((const char*)message+game_name_len+2, "%u:%8s", &number, senderName) == 2) {
|
if (sscanf((const char*)message+game_name_len+2, "%u:%8s", &number, senderName) == 2) {
|
||||||
// IMPORTANT: The code processing the event needs to furi_string_free the senderName!
|
// IMPORTANT: The code processing the event needs to furi_string_free the senderName!
|
||||||
FuriString* name = furi_string_alloc();
|
FuriString* name = furi_string_alloc();
|
||||||
furi_string_set(name, senderName);
|
furi_string_set(name, senderName);
|
||||||
DemoEvent event = {.type = DemoEventReceivedTone, .number = number, .senderName = name};
|
DemoEvent event = {.type = DemoEventReceivedTone, .number = number, .senderName = name};
|
||||||
furi_message_queue_put(instance->queue, &event, FuriWaitForever);
|
furi_message_queue_put(instance->queue, &event, FuriWaitForever);
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_W(TAG, "Failed to parse tone message. >%s<", message);
|
FURI_LOG_W(TAG, "Failed to parse tone message. >%s<", message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Add parsing for other messages here.
|
// Add parsing for other messages here.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (version <= MAJOR_VERSION) {
|
if (version <= MAJOR_VERSION) {
|
||||||
// The version is same or less than ours, so we should know about the message purpose.
|
// The version is same or less than ours, so we should know about the message purpose.
|
||||||
FURI_LOG_W(TAG, "Message purpose not handled for known version. >%s<", message);
|
FURI_LOG_W(TAG, "Message purpose not handled for known version. >%s<", message);
|
||||||
} else {
|
} else {
|
||||||
// The version is newer, so it's not surprising we don't know about the purpose.
|
// The version is newer, so it's not surprising we don't know about the purpose.
|
||||||
FURI_LOG_T(TAG, "Message purpose not handled. >%s<", message);
|
FURI_LOG_T(TAG, "Message purpose not handled. >%s<", message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -211,7 +211,6 @@ static void subghz_demo_send_count(void* ctx) {
|
|||||||
static void subghz_demo_send_tone(void* ctx, unsigned int frequency) {
|
static void subghz_demo_send_tone(void* ctx, unsigned int frequency) {
|
||||||
furi_assert(ctx);
|
furi_assert(ctx);
|
||||||
DemoContext* demo_context = ctx;
|
DemoContext* demo_context = ctx;
|
||||||
DemoData* data = demo_context->data;
|
|
||||||
FuriMessageQueue* queue = demo_context->queue;
|
FuriMessageQueue* queue = demo_context->queue;
|
||||||
DemoEvent event = {.type = DemoEventSendTone, .number = frequency};
|
DemoEvent event = {.type = DemoEventSendTone, .number = frequency};
|
||||||
furi_message_queue_put(queue, &event, FuriWaitForever);
|
furi_message_queue_put(queue, &event, FuriWaitForever);
|
||||||
@ -280,8 +279,7 @@ static void subghz_demo_update_remote_counter(DemoContext* demo_context, DemoEve
|
|||||||
// Our DemoEventReceivedTone handler invokes this method.
|
// Our DemoEventReceivedTone handler invokes this method.
|
||||||
// We play a quick (100ms) tone of the desired frequency.
|
// We play a quick (100ms) tone of the desired frequency.
|
||||||
static void subghz_demo_play_tone(DemoContext* demo_context, DemoEvent* event) {
|
static void subghz_demo_play_tone(DemoContext* demo_context, DemoEvent* event) {
|
||||||
DemoData* data = demo_context->data;
|
UNUSED(demo_context);
|
||||||
|
|
||||||
unsigned int frequency = event->number;
|
unsigned int frequency = event->number;
|
||||||
FURI_LOG_I(TAG, "Playing frequency %04u", frequency);
|
FURI_LOG_I(TAG, "Playing frequency %04u", frequency);
|
||||||
|
|
||||||
@ -425,67 +423,67 @@ int32_t subghz_demo_app(void* p) {
|
|||||||
do {
|
do {
|
||||||
if (furi_message_queue_get(demo_context->queue, &event, FuriWaitForever) == FuriStatusOk) {
|
if (furi_message_queue_get(demo_context->queue, &event, FuriWaitForever) == FuriStatusOk) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case DemoEventTypeKey:
|
case DemoEventTypeKey:
|
||||||
// Short press of OK button, queue DemoEventSendCounter event with the current count.
|
// Short press of OK button, queue DemoEventSendCounter event with the current count.
|
||||||
if(event.input.type == InputTypeShort && event.input.key == InputKeyOk) {
|
if(event.input.type == InputTypeShort && event.input.key == InputKeyOk) {
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
|
||||||
subghz_demo_send_count(demo_context);
|
|
||||||
furi_mutex_release(demo_context->mutex);
|
|
||||||
}
|
|
||||||
// Short press of UP button, queue DemoEventSendTone event.
|
|
||||||
else if(event.input.type == InputTypeShort && event.input.key == InputKeyUp) {
|
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
|
||||||
subghz_demo_send_tone(demo_context, 440U);
|
|
||||||
furi_mutex_release(demo_context->mutex);
|
|
||||||
}
|
|
||||||
// Long press of UP button, queue DemoEventSendTone event.
|
|
||||||
else if (event.input.type == InputTypeLong && event.input.key == InputKeyUp) {
|
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
|
||||||
subghz_demo_send_tone(demo_context, 880U);
|
|
||||||
furi_mutex_release(demo_context->mutex);
|
|
||||||
}
|
|
||||||
// Short press of back button exits the program.
|
|
||||||
else if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) {
|
|
||||||
processing = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DemoEventTypeTick:
|
|
||||||
// Every timer tick we update the counter.
|
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
subghz_demo_update_local_counter(demo_context);
|
subghz_demo_send_count(demo_context);
|
||||||
furi_mutex_release(demo_context->mutex);
|
furi_mutex_release(demo_context->mutex);
|
||||||
break;
|
}
|
||||||
case DemoEventSendCounter:
|
// Short press of UP button, queue DemoEventSendTone event.
|
||||||
// Actually send the counter value to the other Flipper Zero.
|
else if(event.input.type == InputTypeShort && event.input.key == InputKeyUp) {
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
subghz_demo_broadcast_counter(demo_context, event.number);
|
subghz_demo_send_tone(demo_context, 440U);
|
||||||
furi_mutex_release(demo_context->mutex);
|
furi_mutex_release(demo_context->mutex);
|
||||||
break;
|
}
|
||||||
case DemoEventSendTone:
|
// Long press of UP button, queue DemoEventSendTone event.
|
||||||
// Actually send the frequency value to the other Flipper Zero.
|
else if (event.input.type == InputTypeLong && event.input.key == InputKeyUp) {
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
subghz_demo_broadcast_tone(demo_context, event.number);
|
subghz_demo_send_tone(demo_context, 880U);
|
||||||
furi_mutex_release(demo_context->mutex);
|
furi_mutex_release(demo_context->mutex);
|
||||||
break;
|
}
|
||||||
case DemoEventDataDetected:
|
// Short press of back button exits the program.
|
||||||
// Another Flipper sent us data! Process it, potentially queuing an event.
|
else if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) {
|
||||||
subghz_demo_receive_data(demo_context);
|
processing = false;
|
||||||
break;
|
}
|
||||||
case DemoEventReceivedCounter:
|
break;
|
||||||
// Process the counter sent by the other Flipper Zero.
|
case DemoEventTypeTick:
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
// Every timer tick we update the counter.
|
||||||
subghz_demo_update_remote_counter(demo_context, &event);
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
furi_mutex_release(demo_context->mutex);
|
subghz_demo_update_local_counter(demo_context);
|
||||||
break;
|
furi_mutex_release(demo_context->mutex);
|
||||||
case DemoEventReceivedTone:
|
break;
|
||||||
// Process the tone sent by the other Flipper Zero.
|
case DemoEventSendCounter:
|
||||||
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
// Actually send the counter value to the other Flipper Zero.
|
||||||
subghz_demo_play_tone(demo_context, &event);
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
furi_mutex_release(demo_context->mutex);
|
subghz_demo_broadcast_counter(demo_context, event.number);
|
||||||
break;
|
furi_mutex_release(demo_context->mutex);
|
||||||
default:
|
break;
|
||||||
FURI_LOG_E(TAG, "Queue had unknown message type: %u", event.type);
|
case DemoEventSendTone:
|
||||||
break;
|
// Actually send the frequency value to the other Flipper Zero.
|
||||||
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
|
subghz_demo_broadcast_tone(demo_context, event.number);
|
||||||
|
furi_mutex_release(demo_context->mutex);
|
||||||
|
break;
|
||||||
|
case DemoEventDataDetected:
|
||||||
|
// Another Flipper sent us data! Process it, potentially queuing an event.
|
||||||
|
subghz_demo_receive_data(demo_context);
|
||||||
|
break;
|
||||||
|
case DemoEventReceivedCounter:
|
||||||
|
// Process the counter sent by the other Flipper Zero.
|
||||||
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
|
subghz_demo_update_remote_counter(demo_context, &event);
|
||||||
|
furi_mutex_release(demo_context->mutex);
|
||||||
|
break;
|
||||||
|
case DemoEventReceivedTone:
|
||||||
|
// Process the tone sent by the other Flipper Zero.
|
||||||
|
furi_mutex_acquire(demo_context->mutex, FuriWaitForever);
|
||||||
|
subghz_demo_play_tone(demo_context, &event);
|
||||||
|
furi_mutex_release(demo_context->mutex);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FURI_LOG_E(TAG, "Queue had unknown message type: %u", event.type);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If message contains a sender name furi_string, free it.
|
// If message contains a sender name furi_string, free it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user