|
|
@@ -407,8 +407,8 @@ int virtual_portal_send_status(VirtualPortal* virtual_portal, uint8_t* response)
|
|
|
|
|
|
// 4d01ff0000d0077d6c2a77a400000000
|
|
|
int virtual_portal_m(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* response) {
|
|
|
- virtual_portal->speaker = (message[1] == 1);
|
|
|
-
|
|
|
+ // Activate speaker for any non-zero value in the range 01-FF
|
|
|
+ virtual_portal->speaker = (message[1] != 0);
|
|
|
/*
|
|
|
char display[33] = {0};
|
|
|
for(size_t i = 0; i < BLOCK_SIZE; i++) {
|
|
|
@@ -419,7 +419,8 @@ int virtual_portal_m(VirtualPortal* virtual_portal, uint8_t* message, uint8_t* r
|
|
|
|
|
|
size_t index = 0;
|
|
|
response[index++] = 'M';
|
|
|
- response[index++] = message[1];
|
|
|
+ // Always respond with 01 if active, 00 if not
|
|
|
+ response[index++] = virtual_portal->speaker ? 0x01 : 0x00;
|
|
|
response[index++] = 0x00;
|
|
|
response[index++] = 0x19;
|
|
|
g72x_init_state(&virtual_portal->state);
|
|
|
@@ -656,14 +657,23 @@ int virtual_portal_process_message(
|
|
|
case 'M':
|
|
|
return virtual_portal_m(virtual_portal, message, response);
|
|
|
case 'Q': // Query
|
|
|
+ if (!virtual_portal->active) {
|
|
|
+ return 0; // No response if portal is not active
|
|
|
+ }
|
|
|
return virtual_portal_query(virtual_portal, message, response);
|
|
|
case 'R':
|
|
|
return virtual_portal_reset(virtual_portal, message, response);
|
|
|
case 'S': // Status
|
|
|
+ if (!virtual_portal->active) {
|
|
|
+ return 0; // No response if portal is not active
|
|
|
+ }
|
|
|
return virtual_portal_status(virtual_portal, response);
|
|
|
case 'V':
|
|
|
return 0;
|
|
|
case 'W': // Write
|
|
|
+ if (!virtual_portal->active) {
|
|
|
+ return 0; // No response if portal is not active
|
|
|
+ }
|
|
|
return virtual_portal_write(virtual_portal, message, response);
|
|
|
case 'Z':
|
|
|
return 0;
|
|
|
@@ -673,4 +683,4 @@ int virtual_portal_process_message(
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
-}
|
|
|
+}
|