Skip to content

Commit

Permalink
[OTA] Set default configuration values for OTA Provider to prevent cr…
Browse files Browse the repository at this point in the history
…ash (project-chip#15052)

- Update README on application usage
  • Loading branch information
carol-apple authored Feb 11, 2022
1 parent b0c4805 commit 6380d38
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 113 deletions.
8 changes: 8 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ApplicationId
ApplicationIdentifier
ApplicationLauncher
ApplyUpdateRequest
ApplyUpdateResponse
approver
appspot
aps
Expand Down Expand Up @@ -280,6 +281,7 @@ debianutils
DEDEDEDE
deepnote
DelayedActionTime
delayedActionTimeSec
demangle
deployable
depottools
Expand Down Expand Up @@ -855,6 +857,7 @@ QRCodeUrl
QSPI
QueryImage
QueryImageResponse
queryImageStatus
qvCHIP
RADVD
raspberryPi
Expand Down Expand Up @@ -966,6 +969,7 @@ SoftDevice
softmmu
SoftwareDiagnostics
SoftwareVersion
softwareVersionStr
SoftwareVersionString
softwareVersionValid
SPI
Expand Down Expand Up @@ -1085,12 +1089,16 @@ UniFlash
unpair
unprovisioned
untrusted
updateAvailable
updateNotAvailable
UpdateTokens
upstreamed
URI
usbmodem
USBtoUART
uscif
UserConsentNeeded
userConsentState
userguide
USERINTERFACE
UserLabel
Expand Down
94 changes: 46 additions & 48 deletions examples/ota-provider-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,56 +6,54 @@ Cluster Server.
## Building

Suggest doing the following:
`scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false`

## Usage

`./ota-provider-app [-f/--filepath \<file\>] [-o/--otaImageList \<file\>]`

If `--filepath` is supplied, `ota-provider-app` will automatically serve that
file to the OTA Requestor (SoftwareVersion will be Requester version + 1).

If `--otaImageList` is supplied, `ota-provider-app` will parse the JSON file and
extract all required data. Then the most recent, valid software version will be
selected and the corresponding ota-file will be sent to the OTA Requestor.

Here's an example of the otaImageList file contents:
```
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false
```

{ "foo": 1, // ignored by parser "deviceSoftwareVersionModel": [ { "vendorId":
1, "productId": 1, "softwareVersion": 10, "softwareVersionString": "1.0.0",
"cDVersionNumber": 18, "softwareVersionValid": true,
"minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100,
"otaURL": "/tmp/ota.txt" }, { "vendorId": 1, "productId": 1, "softwareVersion":
20, "softwareVersionString": "1.0.1", "cDVersionNumber": 18,
"softwareVersionValid": false, "minApplicableSoftwareVersion": 0,
"maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" }, { "vendorId":
1, "productId": 1, "softwareVersion": 30, "softwareVersionString": "1.0.2",
"cDVersionNumber": 18, "softwareVersionValid": true,
"minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100,
"otaURL": "/tmp/ota.txt" }, { "vendorId": 1, "productId": 1, "softwareVersion":
40, "softwareVersionString": "1.1.0", "cDVersionNumber": 18,
"softwareVersionValid": true, "minApplicableSoftwareVersion": 0,
"maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" }, { "vendorId":
1, "productId": 1, "softwareVersion": 50, "softwareVersionString": "1.1.1",
"cDVersionNumber": 18, "softwareVersionValid": false,
"minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100,
"otaURL": "/tmp/ota.txt" } ] }

If neither `--filepath` nor `--otaImageList` are supplied, `ota-provider-app`
will respond to `QueryImage` with `NotAvailable` status.

## Current Features/Limitations

### Features

- can provide local filepath to serve as OTA image
- can complete full BDX transfer
- supports variable-length / startoffset for BDX transfer
## Usage

### Limitations:
| Command Line Options | Description |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -f/--filepath <file> | Path to a file containing an OTA image |
| -o/--otaImageList <file> | Path to a file containing a list of OTA images |
| -q/--queryImageStatus <updateAvailable \| busy \| updateNotAvailable> | Value for the Status field in the QueryImageResponse |
| -t/--delayedActionTimeSec <time> | Value in seconds for the DelayedActionTime field in the QueryImageResponse and ApplyUpdateResponse |
| -u/--userConsentState <granted \| denied \| deferred> | Current user consent state which results in various values for Status field in QueryImageResponse <br> Note that -q/--queryImageStatus overrides this option <li> granted: Status field in QueryImageResponse is set to updateAvailable <li> denied: Status field in QueryImageResponse is set to updateNotAvailable <li> deferred: Status field in QueryImageResponse is set to busy |
| -s/--softwareVersion <version> | Value for the SoftwareVersion field in the QueryImageResponse <br> Note that -o/--otaImageList overrides this option |
| -S/--softwareVersionStr <version string> | Value for the SoftwareVersionString field in the QueryImageResponse <br> Note that -o/--otaImageList overrides this option |
| -c/--UserConsentNeeded | If provided, value of UserConsentNeeded in the Query Image Response is set to true |

**Using `--filepath` and `--otaImageList`**

- The two options cannot be supplied together
- If neither option is supplied, the application will respond with
`NotAvailable` status
- If `--filepath` is supplied, the application will automatically serve that
file to the OTA Requestor (SoftwareVersion will be requester software
version + 1)
- If `--otaImageList` is supplied, the application will parse the JSON file
and extract all required data. The most recent/valid software version will
be selected and the corresponding OTA file will be sent to the OTA Requestor

An example of the `--otaImageList` file contents:

```
{ "foo": 1, // ignored by parser
"deviceSoftwareVersionModel":
[
{ "vendorId": 1, "productId": 1, "softwareVersion": 10, "softwareVersionString": "1.0.0", "cDVersionNumber": 18, "softwareVersionValid": true, "minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" },
{ "vendorId": 1, "productId": 1, "softwareVersion": 20, "softwareVersionString": "1.0.1", "cDVersionNumber": 18, "softwareVersionValid": false, "minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" },
{ "vendorId": 1, "productId": 1, "softwareVersion": 30, "softwareVersionString": "1.0.2", "cDVersionNumber": 18, "softwareVersionValid": true, "minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" },
{ "vendorId": 1, "productId": 1, "softwareVersion": 40, "softwareVersionString": "1.1.0", "cDVersionNumber": 18, "softwareVersionValid": true, "minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" },
{ "vendorId": 1, "productId": 1, "softwareVersion": 50, "softwareVersionString": "1.1.1", "cDVersionNumber": 18, "softwareVersionValid": false, "minApplicableSoftwareVersion": 0, "maxApplicableSoftwareVersion": 100, "otaURL": "/tmp/ota.txt" }
]
}
```

## Current Limitations

- Synchronous BDX transfer only
- using hardcoded test values for local and peer Node IDs
- does not check VID/PID
- no configuration for `AwaitNextAction`
- only one transfer at a time (does not check incoming `UpdateTokens`)
- Does not check VID/PID
- No configuration for `AwaitNextAction`
- Only one transfer at a time (does not check incoming `UpdateTokens`)
Loading

0 comments on commit 6380d38

Please sign in to comment.