mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-14 07:46:30 +02:00
Fix response type prefix (LoadProhibitedCause)
This commit is contained in:
@ -117,6 +117,10 @@ void STATE(JsonDocument &msg){
|
|||||||
// Do something with message
|
// Do something with message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count of responses handled by RESPONSES_STRUCT
|
||||||
|
// increase increase if another response handler is added
|
||||||
|
int nrOfResponses = 2;
|
||||||
|
|
||||||
RESPONSES_STRUCT responses[] = {
|
RESPONSES_STRUCT responses[] = {
|
||||||
{"ota", OTA},
|
{"ota", OTA},
|
||||||
{"state", STATE},
|
{"state", STATE},
|
||||||
@ -145,7 +149,7 @@ void text(uint8_t * payload, size_t length){
|
|||||||
// Handle each TYPE of message
|
// Handle each TYPE of message
|
||||||
int b = 0;
|
int b = 0;
|
||||||
|
|
||||||
for( b=0 ; strlen(responses[b].type) ; b++ )
|
for( b=0 ; b<nrOfResponses ; b++ )
|
||||||
{
|
{
|
||||||
if( strncmp(doc_in["type"], responses[b].type, strlen(responses[b].type)) == 0 ) {
|
if( strncmp(doc_in["type"], responses[b].type, strlen(responses[b].type)) == 0 ) {
|
||||||
responses[b].func(doc_in);
|
responses[b].func(doc_in);
|
||||||
|
@ -163,7 +163,7 @@ async def _register(websocket, message):
|
|||||||
Logger.info("Client(%s) mac: %s", name, mac)
|
Logger.info("Client(%s) mac: %s", name, mac)
|
||||||
# Some code
|
# Some code
|
||||||
|
|
||||||
response = {'response_type': 'registry', 'state': 'ok'}
|
response = {'type': 'registry', 'state': 'ok'}
|
||||||
await websocket.send(json.dumps(response))
|
await websocket.send(json.dumps(response))
|
||||||
|
|
||||||
|
|
||||||
@ -173,13 +173,13 @@ async def _state(websocket, message):
|
|||||||
Logger.info("Client(%s) mac: %s", name, mac)
|
Logger.info("Client(%s) mac: %s", name, mac)
|
||||||
# Some code
|
# Some code
|
||||||
|
|
||||||
response = {'response_type': 'state', 'state': 'ok'}
|
response = {'type': 'state', 'state': 'ok'}
|
||||||
await websocket.send(json.dumps(response))
|
await websocket.send(json.dumps(response))
|
||||||
|
|
||||||
|
|
||||||
async def _unhandleld(websocket, msg):
|
async def _unhandleld(websocket, msg):
|
||||||
Logger.info("Unhandled message from device: %s", str(msg))
|
Logger.info("Unhandled message from device: %s", str(msg))
|
||||||
response = {'response_type': 'response', 'state': 'nok'}
|
response = {'type': 'response', 'state': 'nok'}
|
||||||
await websocket.send(json.dumps(response))
|
await websocket.send(json.dumps(response))
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user