Ensure valid instance number

This commit is contained in:
LordGrey 2024-04-25 23:34:53 +02:00
parent 42e809581e
commit 12499c8cbb
17 changed files with 44 additions and 23 deletions

View File

@ -67,8 +67,7 @@ _http/s Support_
| leddevice | getProperties | Yes | Yes | Yes |
| leddevice | identify | Yes | Yes | Yes |
| logging | start | Yes | No | Yes |
| logging | stop | Yes | Yes | Yes |
| logging | update | Yes | Yes | Yes |
| logging | stop | Yes | No | Yes |
| processing | - | Yes | Yes | Yes |
| serverinfo | - | Yes | Yes | Yes |
| serverinfo | getInfo | Yes | Yes | Yes |

View File

@ -119,8 +119,7 @@ public:
ToggleIdle,
ToggleSuspend,
TokenRequired,
Unsubscribe,
Update
Unsubscribe
};
static QString toString(Type type) {
@ -171,7 +170,6 @@ public:
case ToggleSuspend: return "toggleSuspend";
case TokenRequired: return "tokenRequired";
case Unsubscribe: return "unsubscribe";
case Update: return "update";
default: return "unknown";
}
}
@ -301,8 +299,7 @@ public:
{ {"leddevice", "getProperties"}, { Command::LedDevice, SubCommand::GetProperties, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"leddevice", "identify"}, { Command::LedDevice, SubCommand::Identify, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"logging", "start"}, { Command::Logging, SubCommand::Start, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
{ {"logging", "stop"}, { Command::Logging, SubCommand::Stop, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"logging", "update"}, { Command::Logging, SubCommand::Update, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"logging", "stop"}, { Command::Logging, SubCommand::Stop, Authorization::Yes, InstanceCmd::No, NoListenerCmd::Yes} },
{ {"processing", ""}, { Command::Processing, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"serverinfo", ""}, { Command::ServerInfo, SubCommand::Empty, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },
{ {"serverinfo", "getInfo"}, { Command::ServerInfo, SubCommand::GetInfo, Authorization::Yes, InstanceCmd::Yes, NoListenerCmd::Yes} },

View File

@ -8,7 +8,9 @@
"enum" : ["adjustment"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["clear"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["clearall"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["color"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -10,7 +10,9 @@
"enum" : ["componentstate"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -13,7 +13,9 @@
"enum" : ["getconfig","getschema","setconfig","restoreconfig","reload"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["create-effect"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -9,7 +9,9 @@
"enum" : ["delete-effect"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["effect"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["image"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -8,7 +8,9 @@
"enum" : ["ledcolors"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -7,9 +7,6 @@
"required" : true,
"enum" : ["logging"]
},
"instance" : {
"type" : "integer"
},
"tan" : {
"type" : "integer"
},

View File

@ -8,7 +8,9 @@
"enum" : ["processing"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"tan" : {
"type" : "integer"

View File

@ -12,7 +12,9 @@
"enum": ["getInfo", "subscribe", "unsubscribe", "getSubscriptions", "getSubscriptionCommands"]
},
"instance" : {
"type" : "integer"
"type" : "integer",
"minimum": 0,
"maximum": 255
},
"data": {
"type": ["null", "array"],

View File

@ -233,7 +233,9 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
const quint8 instance = static_cast<quint8>(message.value("instance").toInt());
if (!setHyperionInstance(instance))
{
cmd.isInstanceCmd = InstanceCmd::No;
sendErrorReply(QString("Invalid or stopped instance: %1").arg(instance), cmd);
return;
}
}