vapor-ware / synse-emulator-plugin

Emulator plugin for Synse
GNU General Public License v3.0
3 stars 3 forks source link

LED color write should validate incoming raw data #1

Closed edaniszewski closed 6 years ago

edaniszewski commented 6 years ago

https://github.com/vapor-ware/synse-emulator-plugin/blob/master/devices/led.go#L59

it currently just sets whatever value it is given, even if the color isn't valid HEX. Will want to add some validation here so it more accurately emulates a real device.

edaniszewski commented 6 years ago

this was fixed in the PR linked above

edaniszewski ~ ➜  curl -H "Content-Type: application/json" -X POST -d '{"action": "color", "raw": "abcdefgh"}' localhost:5000/synse/2.0/write/rack-1/vec/f52d29fecf05a195af13f14c7306cfed
[
  {
    "context":{
      "action":"color",
      "raw":[
        "abcdefgh"
      ]
    },
    "transaction":"ba679hj9r54001s33g00"
  }
]
edaniszewski ~ ➜ curllocalhost:5000/synse/2.0/transaction/ba679hj9r54001s33g00
{
  "id":"ba679hj9r54001s33g00",
  "context":{
    "action":"color",
    "raw":[
      "abcdefgh"
    ]
  },
  "state":"error",
  "status":"done",
  "created":"2018-02-20T19:19:34.491248281Z",
  "updated":"2018-02-20T19:19:34.787202735Z",
  "message":"encoding\/hex: invalid byte: U+0067 'g'"