Buttplug sex toy control library

chore: Tighten Id specifiers in json schema

Make sure we specify the correct Id ranges for messages.

+238 -107
+236 -104
buttplug/buttplug-schema/schema/buttplug-schema.json
··· 4 "version": 3, 5 "description": "The JSON Protocol format for the Buttplug Protocol.", 6 "components": { 7 - "Id": { 8 "description": "User-set id for the message. 0 denotes system message and is reserved.", 9 "type": "integer", 10 "minimum": 0, ··· 25 "type": "integer", 26 "minimum": 0 27 }, 28 - "IdMessage": { 29 "description": "Message types that are expected to have an Id and nothing else.", 30 "properties": { 31 - "Id": { "$ref": "#/components/Id" } 32 }, 33 "additionalProperties": false, 34 "minProperties": 1, ··· 47 "Id" 48 ] 49 }, 50 - "DeviceIndexMessage": { 51 "properties": { 52 - "Id": { "$ref": "#/components/Id" }, 53 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 54 }, 55 "additionalProperties": false, ··· 82 }, 83 "FeatureCount": { "$ref": "#/components/FeatureCount" }, 84 "StepCount": { "$ref": "#/components/StepCount" }, 85 - "ActuatorType": { 86 "description": "Denotes type of actuator (Vibrator, Linear, Oscillator, etc...)", 87 "type": "string" 88 } ··· 134 "FeatureDescriptor", 135 "SensorRange" 136 ] 137 - }, 138 "DeviceMessagesEx": { 139 "description": "A list of the messages a device will accept on this server implementation.", 140 "type": "object", ··· 147 "minItems": 1 148 }, 149 "VibrateCmd": { "$ref": "#/components/GenericMessageAttributes" }, 150 - "LinearCmd": { 151 "type": "array", 152 "items": { 153 "$ref": "#/components/GenericMessageAttributes", 154 "minItems": 1 155 } 156 }, 157 - "RotateCmd": { 158 "type": "array", 159 "items": { 160 "$ref": "#/components/GenericMessageAttributes", ··· 168 "FleshlightLaunchFW12Cmd": { "$ref": "#/components/NullMessageAttributes" }, 169 "BatteryLevelCmd": { "$ref": "#/components/NullMessageAttributes" }, 170 "RSSILevelCmd": { "$ref": "#/components/NullMessageAttributes" }, 171 - "SensorReadCmd": { 172 "type": "array", 173 "items": { 174 "$ref": "#/components/SensorMessageAttributes", 175 "minItems": 1 176 } 177 }, 178 - "SensorSubscribeCmd": { 179 "type": "array", 180 "items": { 181 "$ref": "#/components/SensorMessageAttributes", ··· 210 "Ok": { 211 "type": "object", 212 "description": "Signifies successful processing of the message indicated by the id.", 213 - "anyOf": [ { "$ref": "#/components/IdMessage" } ] 214 }, 215 "Ping": { 216 "type": "object", 217 "description": "Connection keep-alive message.", 218 - "anyOf": [ { "$ref": "#/components/IdMessage" } ] 219 }, 220 "Error": { 221 "type": "object", 222 "description": "Signifies the server encountered an error while processing the message indicated by the id.", 223 "properties": { 224 - "Id": { "$ref": "#/components/Id" }, 225 "ErrorMessage": { 226 "type": "string" 227 }, ··· 242 "type": "object", 243 "description": "Used for connection/application testing. Causes server to echo back the string sent. Sending string of 'Error' will result in a server error. ", 244 "properties": { 245 - "Id": { "$ref": "#/components/Id" }, 246 "TestString": { 247 "description": "String to be echo'd back from server. Setting this to 'Error' will cause an error to be thrown.", 248 "type": "string" ··· 258 "type": "object", 259 "description": "List of all available devices known to the system.", 260 "properties": { 261 - "Id": { "$ref": "#/components/Id" }, 262 "Devices": { 263 "description": "Array of device ids and names.", 264 "type": "array", ··· 315 "DeviceRemoved": { 316 "type": "object", 317 "description": "Notifies client that a device of a certain type has been removed from the server.", 318 - "anyOf": [ { "$ref": "#/components/DeviceIndexMessage" } ] 319 }, 320 "RequestDeviceList": { 321 "type": "object", 322 "description": "Request for the server to send a list of devices to the client.", 323 - "anyOf": [ { "$ref": "#/components/IdMessage" } ] 324 }, 325 "StartScanning": { 326 "type": "object", 327 "description": "Request for the server to start scanning for new devices.", 328 - "anyOf": [ { "$ref": "#/components/IdMessage" } ] 329 }, 330 "StopScanning": { 331 "type": "object", 332 "description": "Request for the server to stop scanning for new devices.", 333 - "anyOf": [ { "$ref": "#/components/IdMessage" } ] 334 }, 335 "ScanningFinished": { 336 "type": "object", ··· 341 "type": "object", 342 "description": "Request for server to stream log messages of a certain level to client.", 343 "properties": { 344 - "Id": { "$ref": "#/components/Id" }, 345 "LogLevel": { 346 "description": "Maximum level of log message to receive.", 347 "enum": [ "Off", "Fatal", "Error", "Warn", "Info", "Debug", "Trace" ] ··· 378 "type": "object", 379 "description": "Request server version, and relay client name.", 380 "properties": { 381 - "Id": { "$ref": "#/components/Id" }, 382 "ClientName": { 383 "description": "Name of the client software.", 384 "type": "string" ··· 399 "type": "object", 400 "description": "Server version information, in Major.Minor.Build format.", 401 "properties": { 402 - "Id": { "$ref": "#/components/Id" }, 403 "ServerName": { 404 "description": "Name of the server. Can be 0-length.", 405 "type": "string" ··· 442 "type": "object", 443 "description": "Sends speed and position command to the Fleshlight Launch Device denoted by the device index.", 444 "properties": { 445 - "Id": { "$ref": "#/components/Id" }, 446 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 447 "Speed": { 448 "description": "Speed at which to move to designated position.", ··· 469 "type": "object", 470 "description": "Sends a command string to a Lovense device. Command string will be verified by sender.", 471 "properties": { 472 - "Id": { "$ref": "#/components/Id" }, 473 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 474 "Command": { 475 "description": "Command to send to Lovense device.", ··· 487 "type": "object", 488 "description": "Sends a vibrate command to a device that supports vibration.", 489 "properties": { 490 - "Id": { "$ref": "#/components/Id" }, 491 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 492 "Speed": { 493 "description": "Device vibration speed (floating point, 0 < x < 1), stepping will be device specific.", ··· 507 "type": "object", 508 "description": "Sends a raw byte array to a device. Should only be used for testing/development.", 509 "properties": { 510 - "Id": { "$ref": "#/components/Id" }, 511 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 512 "Endpoint": { 513 "type": "string", ··· 541 "type": "object", 542 "description": "Request a raw byte array from a device. Should only be used for testing/development.", 543 "properties": { 544 - "Id": { "$ref": "#/components/Id" }, 545 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 546 "Endpoint": { 547 "type": "string", ··· 570 "type": "object", 571 "description": "Subscribe to an endpoint on a device to receive raw info back.", 572 "properties": { 573 - "Id": { "$ref": "#/components/Id" }, 574 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 575 "Endpoint": { 576 "type": "string", ··· 588 "type": "object", 589 "description": "Unsubscribe to an endpoint on a device.", 590 "properties": { 591 - "Id": { "$ref": "#/components/Id" }, 592 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 593 "Endpoint": { 594 "type": "string", ··· 606 "type": "object", 607 "description": "Raw byte array received from a device. Should only be used for testing/development.", 608 "properties": { 609 - "Id": { "$ref": "#/components/Id" }, 610 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 611 "Endpoint": { 612 "type": "string", ··· 635 "type": "object", 636 "description": "Sends a raw byte string to a Kiiroo Onyx/Pearl device.", 637 "properties": { 638 - "Id": { "$ref": "#/components/Id" }, 639 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 640 "Command": { 641 "description": "Command to send to Kiiroo device.", ··· 653 "type": "object", 654 "description": "Requests that a BatteryLevel be retreived.", 655 "properties": { 656 - "Id": { "$ref": "#/components/Id" }, 657 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 658 }, 659 "additionalProperties": false, ··· 666 "type": "object", 667 "description": "Returns a BatteryLevel read from a device.", 668 "properties": { 669 - "Id": { "$ref": "#/components/Id" }, 670 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 671 "BatteryLevel": { 672 "description": "Battery Level", ··· 686 "type": "object", 687 "description": "Requests that a RSSI level be retreived.", 688 "properties": { 689 - "Id": { "$ref": "#/components/Id" }, 690 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 691 }, 692 "additionalProperties": false, ··· 699 "type": "object", 700 "description": "Returns a BatteryLevel read from a device.", 701 "properties": { 702 - "Id": { "$ref": "#/components/Id" }, 703 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 704 "RSSILevel": { 705 "description": "RSSI Level", ··· 719 "type": "object", 720 "description": "Sends a raw byte string to a Kiiroo Onyx/Pearl device.", 721 "properties": { 722 - "Id": { "$ref": "#/components/Id" }, 723 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 724 "Speed": { 725 "description": "Rotation speed command for the Cyclone.", ··· 744 "type": "object", 745 "description": "Stops the all actions currently being taken by a device.", 746 "properties": { 747 - "Id": { "$ref": "#/components/Id" }, 748 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 749 }, 750 "additionalProperties": false, ··· 756 "StopAllDevices": { 757 "type": "object", 758 "description": "Stops all actions currently being taken by all connected devices.", 759 - "anyOf": [ { "$ref": "#/components/IdMessage" } ] 760 }, 761 "VibrateCmd": { 762 "type": "object", 763 "description": "Sends a vibrate command to a device that supports vibration.", 764 "properties": { 765 - "Id": { "$ref": "#/components/Id" }, 766 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 767 "Speeds": { 768 "description": "Device vibration speeds (floating point, 0 < x < 1) keyed on vibrator number, stepping will be device specific.", ··· 802 "type": "object", 803 "description": "Sends a generic scalar command to a device.", 804 "properties": { 805 - "Id": { "$ref": "#/components/Id" }, 806 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 807 "Scalars": { 808 "description": "Device actution scalar (floating point, range can vary) keyed on acutator index, stepping will be device specific.", ··· 822 "ActuatorType": { 823 "description": "Actuator type that is expected to be controlled with this subcommand.", 824 "type": "string" 825 - } 826 }, 827 "additionalProperties": false, 828 "required": [ ··· 845 "type": "object", 846 "description": "Sends a rotate command to a device that supports rotation.", 847 "properties": { 848 - "Id": { "$ref": "#/components/Id" }, 849 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 850 "Rotations": { 851 "description": "Device rotation speeds (floating point, 0 < x < 1) keyed on rotator number, stepping will be device specific.", ··· 890 "type": "object", 891 "description": "Sends a linear movement command to a device that supports linear movements.", 892 "properties": { 893 - "Id": { "$ref": "#/components/Id" }, 894 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 895 "Vectors": { 896 "description": "Device linear movement times (milliseconds) and positions (floating point, 0 < x < 1) keyed on linear actuator number, stepping will be device specific.", ··· 935 "type": "object", 936 "description": "Sends a request to read a sensor value.", 937 "properties": { 938 - "Id": { "$ref": "#/components/Id" }, 939 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 940 "SensorIndex": { "type": "integer" }, 941 "SensorType": { "type": "string" } ··· 946 "DeviceIndex", 947 "SensorIndex", 948 "SensorType" 949 - ] 950 }, 951 "SensorReading": { 952 "type": "object", 953 "description": "Returns from either a sensor read request or a subscribed sensor event.", 954 "properties": { 955 - "Id": { "$ref": "#/components/Id" }, 956 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 957 "SensorIndex": { "type": "integer" }, 958 "SensorType": { "type": "string" }, 959 - "Data": { 960 "type": "array", 961 "items": { 962 "type": "integer", ··· 972 "SensorIndex", 973 "SensorType", 974 "Data" 975 - ] 976 }, 977 "SensorSubscribeCmd": { 978 "type": "object", 979 "description": "Sends a request to subscribe for updates to a sensor value.", 980 "properties": { 981 - "Id": { "$ref": "#/components/Id" }, 982 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 983 "SensorIndex": { "type": "integer" }, 984 "SensorType": { "type": "string" } ··· 989 "DeviceIndex", 990 "SensorIndex", 991 "SensorType" 992 - ] 993 }, 994 "SensorUnsubscribeCmd": { 995 "type": "object", 996 "description": "Sends a request to subscribe for updates to a sensor value.", 997 "properties": { 998 - "Id": { "$ref": "#/components/Id" }, 999 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 1000 "SensorIndex": { "type": "integer" }, 1001 "SensorType": { "type": "string" } ··· 1006 "DeviceIndex", 1007 "SensorIndex", 1008 "SensorType" 1009 - ] 1010 - } 1011 }, 1012 - "type": "array", 1013 - "items": { 1014 - "title": "Messages", 1015 - "type": "object", 1016 - "description": "One or more messages validated by the Buttplug Message schema list.", 1017 - "properties": { 1018 - "BatteryLevelCmd": { "$ref": "#/messages/BatteryLevelCmd" }, 1019 - "BatteryLevelReading": { "$ref": "#/messages/BatteryLevelReading" }, 1020 - "DeviceList": { "$ref": "#/messages/DeviceList" }, 1021 - "DeviceAdded": { "$ref": "#/messages/DeviceAdded" }, 1022 - "DeviceRemoved": { "$ref": "#/messages/DeviceRemoved" }, 1023 - "Error": { "$ref": "#/messages/Error" }, 1024 - "FleshlightLaunchFW12Cmd": { "$ref": "#/messages/FleshlightLaunchFW12Cmd" }, 1025 - "KiirooCmd": { "$ref": "#/messages/KiirooCmd" }, 1026 - "ScalarCmd": { "$ref": "#/messages/ScalarCmd" }, 1027 - "LinearCmd": { "$ref": "#/messages/LinearCmd" }, 1028 - "Log": { "$ref": "#/messages/Log" }, 1029 - "LovenseCmd": { "$ref": "#/messages/LovenseCmd" }, 1030 - "Ok": { "$ref": "#/messages/Ok" }, 1031 - "Ping": { "$ref": "#/messages/Ping" }, 1032 - "RawReadCmd": { "$ref": "#/messages/RawReadCmd" }, 1033 - "RawReading": { "$ref": "#/messages/RawReading" }, 1034 - "RawWriteCmd": { "$ref": "#/messages/RawWriteCmd" }, 1035 - "RawSubscribeCmd": { "$ref": "#/messages/RawSubscribeCmd" }, 1036 - "RawUnsubscribeCmd": { "$ref": "#/messages/RawUnsubscribeCmd" }, 1037 - "RequestDeviceList": { "$ref": "#/messages/RequestDeviceList" }, 1038 - "RequestLog": { "$ref": "#/messages/RequestLog" }, 1039 - "RequestServerInfo": { "$ref": "#/messages/RequestServerInfo" }, 1040 - "RotateCmd": { "$ref": "#/messages/RotateCmd" }, 1041 - "RSSILevelCmd": { "$ref": "#/messages/RSSILevelCmd" }, 1042 - "RSSILevelReading": { "$ref": "#/messages/RSSILevelReading" }, 1043 - "ScanningFinished": { "$ref": "#/messages/ScanningFinished" }, 1044 - "SensorReadCmd": { "$ref": "#/messages/SensorReadCmd" }, 1045 - "SensorReading": { "$ref": "#/messages/SensorReading" }, 1046 - "SensorSubscribeCmd": { "$ref": "#/messages/SensorSubscribeCmd" }, 1047 - "SensorUnsubscribeCmd": { "$ref": "#/messages/SensorUnsubscribeCmd" }, 1048 - "ServerInfo": { "$ref": "#/messages/ServerInfo" }, 1049 - "SingleMotorVibrateCmd": { "$ref": "#/messages/SingleMotorVibrateCmd" }, 1050 - "StartScanning": { "$ref": "#/messages/StartScanning" }, 1051 - "StopAllDevices": { "$ref": "#/messages/StopAllDevices" }, 1052 - "StopDeviceCmd": { "$ref": "#/messages/StopDeviceCmd" }, 1053 - "StopScanning": { "$ref": "#/messages/StopScanning" }, 1054 - "Test": { "$ref": "#/messages/Test" }, 1055 - "VibrateCmd": { "$ref": "#/messages/VibrateCmd" }, 1056 - "VorzeA10CycloneCmd": { "$ref": "#/messages/VorzeA10CycloneCmd" } 1057 }, 1058 - "additionalProperties": false, 1059 - "minProperties": 1, 1060 - "maxProperties": 1 1061 }, 1062 - "minItems": 1, 1063 - "additionalProperties": false 1064 }
··· 4 "version": 3, 5 "description": "The JSON Protocol format for the Buttplug Protocol.", 6 "components": { 7 + "ClientId": { 8 + "description": "User-set id for the message. 0 denotes system message and is reserved.", 9 + "type": "integer", 10 + "minimum": 1, 11 + "maximum": 4294967295 12 + }, 13 + "ServerId": { 14 "description": "User-set id for the message. 0 denotes system message and is reserved.", 15 "type": "integer", 16 "minimum": 0, ··· 31 "type": "integer", 32 "minimum": 0 33 }, 34 + "ClientIdMessage": { 35 "description": "Message types that are expected to have an Id and nothing else.", 36 "properties": { 37 + "Id": { "$ref": "#/components/ClientId" } 38 + }, 39 + "additionalProperties": false, 40 + "minProperties": 1, 41 + "maxProperties": 1, 42 + "required": [ 43 + "Id" 44 + ] 45 + }, 46 + "ServerIdMessage": { 47 + "description": "Message types that are expected to have an Id and nothing else, from the server side, which may be either a reply or an event (id 0).", 48 + "properties": { 49 + "Id": { "$ref": "#/components/ServerId" } 50 }, 51 "additionalProperties": false, 52 "minProperties": 1, ··· 65 "Id" 66 ] 67 }, 68 + "SystemIdDeviceIndexMessage": { 69 + "properties": { 70 + "Id": { "$ref": "#/components/SystemId" }, 71 + "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 72 + }, 73 + "additionalProperties": false, 74 + "required": [ 75 + "Id", 76 + "DeviceIndex" 77 + ] 78 + }, 79 + "ClientIdDeviceIndexMessage": { 80 "properties": { 81 + "Id": { "$ref": "#/components/ClientId" }, 82 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 83 }, 84 "additionalProperties": false, ··· 111 }, 112 "FeatureCount": { "$ref": "#/components/FeatureCount" }, 113 "StepCount": { "$ref": "#/components/StepCount" }, 114 + "ActuatorType": { 115 "description": "Denotes type of actuator (Vibrator, Linear, Oscillator, etc...)", 116 "type": "string" 117 } ··· 163 "FeatureDescriptor", 164 "SensorRange" 165 ] 166 + }, 167 "DeviceMessagesEx": { 168 "description": "A list of the messages a device will accept on this server implementation.", 169 "type": "object", ··· 176 "minItems": 1 177 }, 178 "VibrateCmd": { "$ref": "#/components/GenericMessageAttributes" }, 179 + "LinearCmd": { 180 "type": "array", 181 "items": { 182 "$ref": "#/components/GenericMessageAttributes", 183 "minItems": 1 184 } 185 }, 186 + "RotateCmd": { 187 "type": "array", 188 "items": { 189 "$ref": "#/components/GenericMessageAttributes", ··· 197 "FleshlightLaunchFW12Cmd": { "$ref": "#/components/NullMessageAttributes" }, 198 "BatteryLevelCmd": { "$ref": "#/components/NullMessageAttributes" }, 199 "RSSILevelCmd": { "$ref": "#/components/NullMessageAttributes" }, 200 + "SensorReadCmd": { 201 "type": "array", 202 "items": { 203 "$ref": "#/components/SensorMessageAttributes", 204 "minItems": 1 205 } 206 }, 207 + "SensorSubscribeCmd": { 208 "type": "array", 209 "items": { 210 "$ref": "#/components/SensorMessageAttributes", ··· 239 "Ok": { 240 "type": "object", 241 "description": "Signifies successful processing of the message indicated by the id.", 242 + "anyOf": [ { "$ref": "#/components/ClientIdMessage" } ] 243 }, 244 "Ping": { 245 "type": "object", 246 "description": "Connection keep-alive message.", 247 + "anyOf": [ { "$ref": "#/components/ClientIdMessage" } ] 248 }, 249 "Error": { 250 "type": "object", 251 "description": "Signifies the server encountered an error while processing the message indicated by the id.", 252 "properties": { 253 + "Id": { "$ref": "#/components/ServerId" }, 254 "ErrorMessage": { 255 "type": "string" 256 }, ··· 271 "type": "object", 272 "description": "Used for connection/application testing. Causes server to echo back the string sent. Sending string of 'Error' will result in a server error. ", 273 "properties": { 274 + "Id": { "$ref": "#/components/ClientId" }, 275 "TestString": { 276 "description": "String to be echo'd back from server. Setting this to 'Error' will cause an error to be thrown.", 277 "type": "string" ··· 287 "type": "object", 288 "description": "List of all available devices known to the system.", 289 "properties": { 290 + "Id": { "$ref": "#/components/ClientId" }, 291 "Devices": { 292 "description": "Array of device ids and names.", 293 "type": "array", ··· 344 "DeviceRemoved": { 345 "type": "object", 346 "description": "Notifies client that a device of a certain type has been removed from the server.", 347 + "anyOf": [ { "$ref": "#/components/SystemIdDeviceIndexMessage" } ] 348 }, 349 "RequestDeviceList": { 350 "type": "object", 351 "description": "Request for the server to send a list of devices to the client.", 352 + "anyOf": [ { "$ref": "#/components/ClientIdMessage" } ] 353 }, 354 "StartScanning": { 355 "type": "object", 356 "description": "Request for the server to start scanning for new devices.", 357 + "anyOf": [ { "$ref": "#/components/ClientIdMessage" } ] 358 }, 359 "StopScanning": { 360 "type": "object", 361 "description": "Request for the server to stop scanning for new devices.", 362 + "anyOf": [ { "$ref": "#/components/ClientIdMessage" } ] 363 }, 364 "ScanningFinished": { 365 "type": "object", ··· 370 "type": "object", 371 "description": "Request for server to stream log messages of a certain level to client.", 372 "properties": { 373 + "Id": { "$ref": "#/components/ClientId" }, 374 "LogLevel": { 375 "description": "Maximum level of log message to receive.", 376 "enum": [ "Off", "Fatal", "Error", "Warn", "Info", "Debug", "Trace" ] ··· 407 "type": "object", 408 "description": "Request server version, and relay client name.", 409 "properties": { 410 + "Id": { "$ref": "#/components/ClientId" }, 411 "ClientName": { 412 "description": "Name of the client software.", 413 "type": "string" ··· 428 "type": "object", 429 "description": "Server version information, in Major.Minor.Build format.", 430 "properties": { 431 + "Id": { "$ref": "#/components/ClientId" }, 432 "ServerName": { 433 "description": "Name of the server. Can be 0-length.", 434 "type": "string" ··· 471 "type": "object", 472 "description": "Sends speed and position command to the Fleshlight Launch Device denoted by the device index.", 473 "properties": { 474 + "Id": { "$ref": "#/components/ClientId" }, 475 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 476 "Speed": { 477 "description": "Speed at which to move to designated position.", ··· 498 "type": "object", 499 "description": "Sends a command string to a Lovense device. Command string will be verified by sender.", 500 "properties": { 501 + "Id": { "$ref": "#/components/ClientId" }, 502 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 503 "Command": { 504 "description": "Command to send to Lovense device.", ··· 516 "type": "object", 517 "description": "Sends a vibrate command to a device that supports vibration.", 518 "properties": { 519 + "Id": { "$ref": "#/components/ClientId" }, 520 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 521 "Speed": { 522 "description": "Device vibration speed (floating point, 0 < x < 1), stepping will be device specific.", ··· 536 "type": "object", 537 "description": "Sends a raw byte array to a device. Should only be used for testing/development.", 538 "properties": { 539 + "Id": { "$ref": "#/components/ClientId" }, 540 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 541 "Endpoint": { 542 "type": "string", ··· 570 "type": "object", 571 "description": "Request a raw byte array from a device. Should only be used for testing/development.", 572 "properties": { 573 + "Id": { "$ref": "#/components/ClientId" }, 574 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 575 "Endpoint": { 576 "type": "string", ··· 599 "type": "object", 600 "description": "Subscribe to an endpoint on a device to receive raw info back.", 601 "properties": { 602 + "Id": { "$ref": "#/components/ClientId" }, 603 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 604 "Endpoint": { 605 "type": "string", ··· 617 "type": "object", 618 "description": "Unsubscribe to an endpoint on a device.", 619 "properties": { 620 + "Id": { "$ref": "#/components/ClientId" }, 621 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 622 "Endpoint": { 623 "type": "string", ··· 635 "type": "object", 636 "description": "Raw byte array received from a device. Should only be used for testing/development.", 637 "properties": { 638 + "Id": { "$ref": "#/components/ServerId" }, 639 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 640 "Endpoint": { 641 "type": "string", ··· 664 "type": "object", 665 "description": "Sends a raw byte string to a Kiiroo Onyx/Pearl device.", 666 "properties": { 667 + "Id": { "$ref": "#/components/ClientId" }, 668 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 669 "Command": { 670 "description": "Command to send to Kiiroo device.", ··· 682 "type": "object", 683 "description": "Requests that a BatteryLevel be retreived.", 684 "properties": { 685 + "Id": { "$ref": "#/components/ClientId" }, 686 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 687 }, 688 "additionalProperties": false, ··· 695 "type": "object", 696 "description": "Returns a BatteryLevel read from a device.", 697 "properties": { 698 + "Id": { "$ref": "#/components/ClientId" }, 699 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 700 "BatteryLevel": { 701 "description": "Battery Level", ··· 715 "type": "object", 716 "description": "Requests that a RSSI level be retreived.", 717 "properties": { 718 + "Id": { "$ref": "#/components/ClientId" }, 719 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 720 }, 721 "additionalProperties": false, ··· 728 "type": "object", 729 "description": "Returns a BatteryLevel read from a device.", 730 "properties": { 731 + "Id": { "$ref": "#/components/ClientId" }, 732 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 733 "RSSILevel": { 734 "description": "RSSI Level", ··· 748 "type": "object", 749 "description": "Sends a raw byte string to a Kiiroo Onyx/Pearl device.", 750 "properties": { 751 + "Id": { "$ref": "#/components/ClientId" }, 752 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 753 "Speed": { 754 "description": "Rotation speed command for the Cyclone.", ··· 773 "type": "object", 774 "description": "Stops the all actions currently being taken by a device.", 775 "properties": { 776 + "Id": { "$ref": "#/components/ClientId" }, 777 "DeviceIndex": { "$ref": "#/components/DeviceIndex" } 778 }, 779 "additionalProperties": false, ··· 785 "StopAllDevices": { 786 "type": "object", 787 "description": "Stops all actions currently being taken by all connected devices.", 788 + "anyOf": [ { "$ref": "#/components/ClientIdMessage" } ] 789 }, 790 "VibrateCmd": { 791 "type": "object", 792 "description": "Sends a vibrate command to a device that supports vibration.", 793 "properties": { 794 + "Id": { "$ref": "#/components/ClientId" }, 795 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 796 "Speeds": { 797 "description": "Device vibration speeds (floating point, 0 < x < 1) keyed on vibrator number, stepping will be device specific.", ··· 831 "type": "object", 832 "description": "Sends a generic scalar command to a device.", 833 "properties": { 834 + "Id": { "$ref": "#/components/ClientId" }, 835 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 836 "Scalars": { 837 "description": "Device actution scalar (floating point, range can vary) keyed on acutator index, stepping will be device specific.", ··· 851 "ActuatorType": { 852 "description": "Actuator type that is expected to be controlled with this subcommand.", 853 "type": "string" 854 + } 855 }, 856 "additionalProperties": false, 857 "required": [ ··· 874 "type": "object", 875 "description": "Sends a rotate command to a device that supports rotation.", 876 "properties": { 877 + "Id": { "$ref": "#/components/ClientId" }, 878 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 879 "Rotations": { 880 "description": "Device rotation speeds (floating point, 0 < x < 1) keyed on rotator number, stepping will be device specific.", ··· 919 "type": "object", 920 "description": "Sends a linear movement command to a device that supports linear movements.", 921 "properties": { 922 + "Id": { "$ref": "#/components/ClientId" }, 923 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 924 "Vectors": { 925 "description": "Device linear movement times (milliseconds) and positions (floating point, 0 < x < 1) keyed on linear actuator number, stepping will be device specific.", ··· 964 "type": "object", 965 "description": "Sends a request to read a sensor value.", 966 "properties": { 967 + "Id": { "$ref": "#/components/ClientId" }, 968 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 969 "SensorIndex": { "type": "integer" }, 970 "SensorType": { "type": "string" } ··· 975 "DeviceIndex", 976 "SensorIndex", 977 "SensorType" 978 + ] 979 }, 980 "SensorReading": { 981 "type": "object", 982 "description": "Returns from either a sensor read request or a subscribed sensor event.", 983 "properties": { 984 + "Id": { "$ref": "#/components/ServerId" }, 985 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 986 "SensorIndex": { "type": "integer" }, 987 "SensorType": { "type": "string" }, 988 + "Data": { 989 "type": "array", 990 "items": { 991 "type": "integer", ··· 1001 "SensorIndex", 1002 "SensorType", 1003 "Data" 1004 + ] 1005 }, 1006 "SensorSubscribeCmd": { 1007 "type": "object", 1008 "description": "Sends a request to subscribe for updates to a sensor value.", 1009 "properties": { 1010 + "Id": { "$ref": "#/components/ClientId" }, 1011 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 1012 "SensorIndex": { "type": "integer" }, 1013 "SensorType": { "type": "string" } ··· 1018 "DeviceIndex", 1019 "SensorIndex", 1020 "SensorType" 1021 + ] 1022 }, 1023 "SensorUnsubscribeCmd": { 1024 "type": "object", 1025 "description": "Sends a request to subscribe for updates to a sensor value.", 1026 "properties": { 1027 + "Id": { "$ref": "#/components/ClientId" }, 1028 "DeviceIndex": { "$ref": "#/components/DeviceIndex" }, 1029 "SensorIndex": { "type": "integer" }, 1030 "SensorType": { "type": "string" } ··· 1035 "DeviceIndex", 1036 "SensorIndex", 1037 "SensorType" 1038 + ] 1039 + } 1040 }, 1041 + "specs": { 1042 + "MessageSpecV3": { 1043 + "type": "array", 1044 + "items": { 1045 + "type": "object", 1046 + "description": "All messages valid in Buttplug Spec v3", 1047 + "properties": { 1048 + "DeviceList": { "$ref": "#/messages/DeviceList" }, 1049 + "DeviceAdded": { "$ref": "#/messages/DeviceAdded" }, 1050 + "DeviceRemoved": { "$ref": "#/messages/DeviceRemoved" }, 1051 + "Error": { "$ref": "#/messages/Error" }, 1052 + "ScalarCmd": { "$ref": "#/messages/ScalarCmd" }, 1053 + "LinearCmd": { "$ref": "#/messages/LinearCmd" }, 1054 + "Ok": { "$ref": "#/messages/Ok" }, 1055 + "Ping": { "$ref": "#/messages/Ping" }, 1056 + "RawReadCmd": { "$ref": "#/messages/RawReadCmd" }, 1057 + "RawReading": { "$ref": "#/messages/RawReading" }, 1058 + "RawWriteCmd": { "$ref": "#/messages/RawWriteCmd" }, 1059 + "RawSubscribeCmd": { "$ref": "#/messages/RawSubscribeCmd" }, 1060 + "RawUnsubscribeCmd": { "$ref": "#/messages/RawUnsubscribeCmd" }, 1061 + "RequestDeviceList": { "$ref": "#/messages/RequestDeviceList" }, 1062 + "RequestServerInfo": { "$ref": "#/messages/RequestServerInfo" }, 1063 + "RotateCmd": { "$ref": "#/messages/RotateCmd" }, 1064 + "ScanningFinished": { "$ref": "#/messages/ScanningFinished" }, 1065 + "SensorReadCmd": { "$ref": "#/messages/SensorReadCmd" }, 1066 + "SensorReading": { "$ref": "#/messages/SensorReading" }, 1067 + "SensorSubscribeCmd": { "$ref": "#/messages/SensorSubscribeCmd" }, 1068 + "SensorUnsubscribeCmd": { "$ref": "#/messages/SensorUnsubscribeCmd" }, 1069 + "ServerInfo": { "$ref": "#/messages/ServerInfo" }, 1070 + "StartScanning": { "$ref": "#/messages/StartScanning" }, 1071 + "StopAllDevices": { "$ref": "#/messages/StopAllDevices" }, 1072 + "StopDeviceCmd": { "$ref": "#/messages/StopDeviceCmd" }, 1073 + "StopScanning": { "$ref": "#/messages/StopScanning" } 1074 + }, 1075 + "additionalProperties": false, 1076 + "minProperties": 1, 1077 + "maxProperties": 1 1078 + }, 1079 + "minItems": 1 1080 }, 1081 + "MessageSpecV2": { 1082 + "type": "array", 1083 + "items": { 1084 + "type": "object", 1085 + "description": "All messages valid in Buttplug Spec v2.", 1086 + "properties": { 1087 + "BatteryLevelCmd": { "$ref": "#/messages/BatteryLevelCmd" }, 1088 + "BatteryLevelReading": { "$ref": "#/messages/BatteryLevelReading" }, 1089 + "DeviceList": { "$ref": "#/messages/DeviceList" }, 1090 + "DeviceAdded": { "$ref": "#/messages/DeviceAdded" }, 1091 + "DeviceRemoved": { "$ref": "#/messages/DeviceRemoved" }, 1092 + "Error": { "$ref": "#/messages/Error" }, 1093 + "LinearCmd": { "$ref": "#/messages/LinearCmd" }, 1094 + "Ok": { "$ref": "#/messages/Ok" }, 1095 + "Ping": { "$ref": "#/messages/Ping" }, 1096 + "RawReadCmd": { "$ref": "#/messages/RawReadCmd" }, 1097 + "RawReading": { "$ref": "#/messages/RawReading" }, 1098 + "RawWriteCmd": { "$ref": "#/messages/RawWriteCmd" }, 1099 + "RawSubscribeCmd": { "$ref": "#/messages/RawSubscribeCmd" }, 1100 + "RawUnsubscribeCmd": { "$ref": "#/messages/RawUnsubscribeCmd" }, 1101 + "RequestDeviceList": { "$ref": "#/messages/RequestDeviceList" }, 1102 + "RequestLog": { "$ref": "#/messages/RequestLog" }, 1103 + "RequestServerInfo": { "$ref": "#/messages/RequestServerInfo" }, 1104 + "RotateCmd": { "$ref": "#/messages/RotateCmd" }, 1105 + "RSSILevelCmd": { "$ref": "#/messages/RSSILevelCmd" }, 1106 + "RSSILevelReading": { "$ref": "#/messages/RSSILevelReading" }, 1107 + "ScanningFinished": { "$ref": "#/messages/ScanningFinished" }, 1108 + "ServerInfo": { "$ref": "#/messages/ServerInfo" }, 1109 + "StartScanning": { "$ref": "#/messages/StartScanning" }, 1110 + "StopAllDevices": { "$ref": "#/messages/StopAllDevices" }, 1111 + "StopDeviceCmd": { "$ref": "#/messages/StopDeviceCmd" }, 1112 + "StopScanning": { "$ref": "#/messages/StopScanning" }, 1113 + "VibrateCmd": { "$ref": "#/messages/VibrateCmd" } 1114 + }, 1115 + "additionalProperties": false, 1116 + "minProperties": 1, 1117 + "maxProperties": 1 1118 + }, 1119 + "minItems": 1 1120 + }, 1121 + "MessageSpecV1": { 1122 + "type": "array", 1123 + "items": { 1124 + "type": "object", 1125 + "description": "One or more messages validated by the Buttplug Message schema list.", 1126 + "properties": { 1127 + "DeviceList": { "$ref": "#/messages/DeviceList" }, 1128 + "DeviceAdded": { "$ref": "#/messages/DeviceAdded" }, 1129 + "DeviceRemoved": { "$ref": "#/messages/DeviceRemoved" }, 1130 + "Error": { "$ref": "#/messages/Error" }, 1131 + "FleshlightLaunchFW12Cmd": { "$ref": "#/messages/FleshlightLaunchFW12Cmd" }, 1132 + "KiirooCmd": { "$ref": "#/messages/KiirooCmd" }, 1133 + "LinearCmd": { "$ref": "#/messages/LinearCmd" }, 1134 + "Log": { "$ref": "#/messages/Log" }, 1135 + "Ok": { "$ref": "#/messages/Ok" }, 1136 + "Ping": { "$ref": "#/messages/Ping" }, 1137 + "RequestDeviceList": { "$ref": "#/messages/RequestDeviceList" }, 1138 + "RequestLog": { "$ref": "#/messages/RequestLog" }, 1139 + "RequestServerInfo": { "$ref": "#/messages/RequestServerInfo" }, 1140 + "RotateCmd": { "$ref": "#/messages/RotateCmd" }, 1141 + "ServerInfo": { "$ref": "#/messages/ServerInfo" }, 1142 + "StartScanning": { "$ref": "#/messages/StartScanning" }, 1143 + "StopAllDevices": { "$ref": "#/messages/StopAllDevices" }, 1144 + "StopDeviceCmd": { "$ref": "#/messages/StopDeviceCmd" }, 1145 + "StopScanning": { "$ref": "#/messages/StopScanning" }, 1146 + "Test": { "$ref": "#/messages/Test" }, 1147 + "VibrateCmd": { "$ref": "#/messages/VibrateCmd" }, 1148 + "VorzeA10CycloneCmd": { "$ref": "#/messages/VorzeA10CycloneCmd" } 1149 + }, 1150 + "additionalProperties": false, 1151 + "minProperties": 1, 1152 + "maxProperties": 1 1153 + }, 1154 + "minItems": 1 1155 + }, 1156 + "MessageSpecV0": { 1157 + "type": "array", 1158 + "items": { 1159 + "type": "object", 1160 + "description": "One or more messages validated by the Buttplug Message schema list.", 1161 + "properties": { 1162 + "DeviceList": { "$ref": "#/messages/DeviceList" }, 1163 + "DeviceAdded": { "$ref": "#/messages/DeviceAdded" }, 1164 + "DeviceRemoved": { "$ref": "#/messages/DeviceRemoved" }, 1165 + "Error": { "$ref": "#/messages/Error" }, 1166 + "FleshlightLaunchFW12Cmd": { "$ref": "#/messages/FleshlightLaunchFW12Cmd" }, 1167 + "KiirooCmd": { "$ref": "#/messages/KiirooCmd" }, 1168 + "Log": { "$ref": "#/messages/Log" }, 1169 + "Ok": { "$ref": "#/messages/Ok" }, 1170 + "Ping": { "$ref": "#/messages/Ping" }, 1171 + "RequestDeviceList": { "$ref": "#/messages/RequestDeviceList" }, 1172 + "RequestLog": { "$ref": "#/messages/RequestLog" }, 1173 + "RequestServerInfo": { "$ref": "#/messages/RequestServerInfo" }, 1174 + "ServerInfo": { "$ref": "#/messages/ServerInfo" }, 1175 + "SingleMotorVibrateCmd": { "$ref": "#/messages/SingleMotorVibrateCmd" }, 1176 + "StartScanning": { "$ref": "#/messages/StartScanning" }, 1177 + "StopAllDevices": { "$ref": "#/messages/StopAllDevices" }, 1178 + "StopDeviceCmd": { "$ref": "#/messages/StopDeviceCmd" }, 1179 + "StopScanning": { "$ref": "#/messages/StopScanning" }, 1180 + "Test": { "$ref": "#/messages/Test" }, 1181 + "VorzeA10CycloneCmd": { "$ref": "#/messages/VorzeA10CycloneCmd" } 1182 + }, 1183 + "additionalProperties": false, 1184 + "minProperties": 1, 1185 + "maxProperties": 1 1186 + }, 1187 + "minItems": 1 1188 + } 1189 }, 1190 + "anyOf": [ 1191 + { "$ref": "#/specs/MessageSpecV3" }, 1192 + { "$ref": "#/specs/MessageSpecV2" }, 1193 + { "$ref": "#/specs/MessageSpecV1" }, 1194 + { "$ref": "#/specs/MessageSpecV0" } 1195 + ] 1196 }
+2 -3
buttplug/src/core/messages/serializer/json_serializer.rs
··· 334 // Valid json and message type but not an array. 335 "{\"Ok\":{\"Id\":0}}", 336 // Valid json and message type but not an array. 337 - // TODO This should fail (Ok can't have an Id of 0), but currently doesn't. 338 - // "[{\"Ok\":{\"Id\":0}}]", 339 // Valid json and message type but with extra content 340 "[{\"Ok\":{\"NotAField\":\"NotAValue\",\"Id\":1}}]", 341 ]; ··· 347 .into()]); 348 for msg in incorrect_incoming_messages { 349 let res = serializer.deserialize(ButtplugSerializedMessage::Text(msg.to_owned())); 350 - assert!(res.is_err()); 351 if let Err(ButtplugSerializerError::MessageSpecVersionNotReceived) = res { 352 assert!(false, "Wrong error!"); 353 }
··· 334 // Valid json and message type but not an array. 335 "{\"Ok\":{\"Id\":0}}", 336 // Valid json and message type but not an array. 337 + "[{\"Ok\":{\"Id\":0}}]", 338 // Valid json and message type but with extra content 339 "[{\"Ok\":{\"NotAField\":\"NotAValue\",\"Id\":1}}]", 340 ]; ··· 346 .into()]); 347 for msg in incorrect_incoming_messages { 348 let res = serializer.deserialize(ButtplugSerializedMessage::Text(msg.to_owned())); 349 + assert!(res.is_err(), "{} should be an error", msg); 350 if let Err(ButtplugSerializerError::MessageSpecVersionNotReceived) = res { 351 assert!(false, "Wrong error!"); 352 }