Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for any JSON data type in device command value #480

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

FelixTing
Copy link
Member

fix: #479

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/device-sdk-c/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

From the latest compose builder run make run no-secty
Run the Random generator example with the following device profile:

{
  "name": "ExampleSensor",
  "manufacturer": "IoTechSystems",
  "model": "IoT3",
  "description": "Random Example Sensor",
  "labels": ["sensor"],
  "apiVersion": "v3",

  "deviceResources":
  [
    {
      "name": "SensorOne",
       "description": "A Sensor generating values between 0 & 100",
       "attributes": { "SensorID": "Sen1" , "SensorType": 1 },
       "properties": { "valueType": "Uint64", "readWrite": "R", "units": "Random" }
    },
    {
       "name": "SensorTwo",
       "description": "A Sensor generating values between 1 & 1000",
       "attributes": { "SensorID": "Sen2", "SensorType": 2 },
       "properties": { "valueType": "Uint64", "readWrite": "R", "units": "Random" }
    },
    {
       "name": "Switch",
       "description": "A generic switch",
       "attributes": { "SwitchID": "Switch1" },
       "properties": { "valueType": "Bool", "readWrite": "RW", "units": "State" }
    }
  ],
  "deviceCommands": [
    {
      "name": "Switch",
      "readWrite": "RW",
      "resourceOperations": [
        {
          "deviceResource": "Switch"
        }
      ]
    }
  ]
}

Issue a device command:

curl -X PUT 'http://0:59999/api/v3/device/name/RandomDevice1/Switch' -d '{"Switch": true}'

Verify the response contains the following message:

{"apiVersion":"v3","requestId":"fec37887-22a0-4012-bb4c-2679424fc64f","statusCode":200,"message":"Data written successfully"}

Verify the Switch value has been set to true:

{"apiVersion":"v3","event":{"apiVersion":"v3","deviceName":"RandomDevice1","id":"0a12e61c-d45d-4349-b3f0-1c8728fbfb2b","origin":1693387122547996130,"profileName":"ExampleSensor","readings":[{"apiVersion":"v3","deviceName":"RandomDevice1","id":"bcef5fe4-e7a6-4f35-adbf-508a5d49c256","origin":1693387122547996130,"profileName":"ExampleSensor","resourceName":"Switch","value":"true","valueType":"Bool"}],"sourceName":"Switch"},"statusCode":200}

New Dependency Instructions (If applicable)

Copy link
Member

@iain-anderson iain-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FelixTing FelixTing merged commit b62e37a into edgexfoundry:main Aug 31, 2023
3 checks passed
@FelixTing FelixTing deleted the issue-479 branch August 31, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

edgex_device_runput2 only supports string value.
2 participants