Hello,
You may have reviewed Section 5.3.5 of the OCF Specification here:
https://openconnectivity.org/specs/OCF_Core_Optional_Specification_v2.1.1.pdf
Figure 3 depicts the internal state machine that drives the SW Update process.
The IoTivity-Lite stack performs those state transitions internally based on
the progress of the actual update as reported by the application. For that the
stack provides callback interfaces to developers to implement all the steps
of the process and return a success/failure status for each.
You've probably seen this in apps/smart_home_server_with_mock_swupdate.cpp that
mostly returns a success result for each step to be able to test out all the
transitions.
On this point in your e-mail:
> Yes, I've followed the step on README, and also I tried to change the option
> to
> number [1]: All NCRs '*'. But still Unauthorized. Then, today I try to fill
> the
> href resource with /sw (softwareupdate URI). Turns out it worked!
Yes, the SW Update resource (as also /oic/sec/pstat) is from a protected group
of resources to which wildcards don't apply in ACEs. In other words, the device
owner needs to explicitly call out such resources in the ACE to provide access
to Clients. It seems that you had worked this out.
Lastly, there isn't a Client sample that triggers the SW Update process, and I
understand that that's what you're trying to build. Making it work requires you
to
provide properly formatted requests.
Below is the entire SW Update sequence triggered (and captured) by OCF's
Certification Test Tool (as Client) on
apps/smart_home_server_with_mock_swupdate.cpp. It shows you the
exact payloads sent/received and I thought it might be instructive for you as
you build your Client. You will notice that it largely follows all the
transitions in
figure 3.
Hope this helps.
Thanks,
-Kishen.
*Idle* (initial state)
Observe response from /oic/sec/pstat:
{"rt":["oic.r.pstat"],"if":["oic.if.baseline"],"dos":{"p":false,"s":3},"cm":0,"tm":0,"om":4,"sm":4,"isop":true,"rowneruuid":"11111111-2222-3333-4444-555555555555"}
Observe response from /sw:
{"lastupdate":"1970-01-01T00:00:00Z","nv":"","purl":"","signed":"vendor","swupdateaction":"idle","swupdateresult":0,"swupdatestate":"idle","updatetime":"1970-01-01T00:00:00Z"}
...
(Client kicks off SW Update process)
POST /sw request payload:
{"swupdateaction": "isac", "purl": "coaps://[fd00::1001]:49442", "updatetime":
"2020-01-22T11:27:20Z"}
..
*new_version_check*
Observe response from /oic/sec/pstat:
{"rt":["oic.r.pstat"],"if":["oic.if.baseline"],"dos":{"p":false,"s":3},"cm":256,"tm":0,"om":4,"sm":4,"isop":true,"rowneruuid":"11111111-2222-3333-4444-555555555555"}
Observe response from /sw:
{"lastupdate":"1970-01-01T00:00:00Z","nv":"","purl":"coaps://[fd00::1001]:49442","signed":"vendor","swupdateaction":"isac","swupdateresult":1,"swupdatestate":"nsa","updatetime":"2020-01-22T11:27:20Z"}
...
*version_validation*
Observe response from /sw:
{"lastupdate":"1970-01-01T00:00:00Z","nv":"","purl":"coaps://[fd00::1001]:49442","signed":"vendor","swupdateaction":"isvv","swupdateresult":1,"swupdatestate":"svv","updatetime":"2020-01-22T11:27:20Z"}
...
*version_available*
Observe response from /oic/sec/pstat:
{"rt":["oic.r.pstat"],"if":["oic.if.baseline"],"dos":{"p":false,"s":3},"cm":320,"tm":0,"om":4,"sm":4,"isop":true,"rowneruuid":"11111111-2222-3333-4444-555555555555"}
Observe response from /sw:
{"lastupdate":"1970-01-01T00:00:00Z","nv":"","purl":"coaps://[fd00::1001]:49442","signed":"vendor","swupdateaction":"isvv","swupdateresult":1,"swupdatestate":"sva","updatetime":"2020-01-22T11:27:20Z"}
...
*upgrading*
Observe response from /oic/sec/pstat:
{"rt":["oic.r.pstat"],"if":["oic.if.baseline"],"dos":{"p":false,"s":3},"cm":448,"tm":0,"om":4,"sm":4,"isop":true,"rowneruuid":"11111111-2222-3333-4444-555555555555"}
Observe response from /sw:
{"lastupdate":"2020-01-22T11:27:20.002464Z","nv":"","purl":"coaps://[fd00::1001]:49442","signed":"vendor","swupdateaction":"upgrade","swupdateresult":1,"swupdatestate":"upgrading","updatetime":"2020-01-22T11:27:20Z"}
...
*idle*
Observe response from /oic/sec/pstat:
{"rt":["oic.r.pstat"],"if":["oic.if.baseline"],"dos":{"p":false,"s":3},"cm":0,"tm":0,"om":4,"sm":4,"isop":true,"rowneruuid":"11111111-2222-3333-4444-555555555555"}
Observe response from /sw:
{"lastupdate":"2020-01-22T11:27:20.002464Z","nv":"","purl":"coaps://[fd00::1001]:49442","signed":"vendor","swupdateaction":"idle","swupdateresult":1,"swupdatestate":"idle","updatetime":"2020-01-22T11:27:20Z"}
...
--
Kishen Maloor
Intel Corporation
From: <[email protected]> on behalf of George Nash
<[email protected]>
Date: Thursday, March 5, 2020 at 11:08 AM
To: "[email protected]" <[email protected]>,
"[email protected]" <[email protected]>
Subject: Re: [dev] Iotivity Client
The `swupdateaction` must be a string oc_rep_set_text_sring(root,
swupdateaction, “<action>”); where action is one of the following strings
[“idle”, “isac”, “isvv”, “upgrade”];
It is converted internally to an enum what you must send is a string.
The OC_STATUS_NOT_ACCEPTABLE comes from the software updates post handler code.
Possible sources:
* you tried to write a read only property. (I don’t see that in your code.)
* the “purl” is longer than 63 characters. (it only supports short urls
smaller than 63 characters.)
* the “purl” is not a string
* the “swupdate” is not a string (and smaller than 63 characters)
* the “updatetime” is not a string
* the “updatetime” string is larger than 63 charaters
* the “updatetime” does not conform to the RFC3339 (i.e. the string could
not be parsed to a clock time)
* the “updatetime” is a time in the past. We only update at a future time
past times are ignored.
* If “purl” is marked as an invalid url by the validate_purl callback
* (probably some others I have missed.)
The response code OC_STATUS_SERVICE_UNAVAILABLE is the equivalent of a “503
Service Unavailable Error that indicates the server is temporarily unable to
handle the request” I have no clue why you would be getting that response code.
George Nash
From: [email protected] <[email protected]> On
Behalf Of [email protected]
Sent: Thursday, March 5, 2020 8:16 AM
To: [email protected]
Subject: Re: [dev] Iotivity Client
George,
Ups, sorry my bad. Missing separator. I mean R,U,N (Read, Update, Notify).
Yes, I've followed the step on README, and also I tried to change the option to
number [1]: All NCRs '*'. But still Unauthorized. Then, today I try to fill the
href resource with /sw (softwareupdate URI). Turns out it worked! I can get the
oic.r.softwareupdate property values. I put the screenshot of my server's ACE.
In the last 2 ACE, I put the href.
Another problem is, after I successfully observe and get the values when I try
to oc_do_post, the oc_status code was 11 (OC_STATUS_NOT_ACCEPTABLE) or 17
(OC_STATUS_NOT_AVAILABLE). This is my code for oc_do_post:
1 if (oc_init_post(swupdate_uri, swupdate_server, NULL, &post_swupdate,
HIGH_QOS, NULL)) {
2 oc_rep_start_root_object();
3 oc_rep_set_text_string(root, purl, "http://127.0.0.1");
4 //oc_rep_set_int(root, swupdateaction, 0);
5 //oc_rep_set_text_string(root, updatetime, "2020-03-05T20:00:00Z");
6 oc_rep_end_root_object();
7 if (oc_do_post())
8 PRINT("Sent POST request\n");
9 else
10 PRINT("Could not send POST request\n");
11 }
When I comment line 4 and 5, the oc_status code was 11. Then, when I uncomment
line 4 and 5, the oc_status code was 17. Any idea why this happens?
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#10369):
https://iotivity.groups.io/g/iotivity-dev/message/10369
Mute This Topic: https://groups.io/mt/69378274/21656
Group Owner: [email protected]
Unsubscribe: https://iotivity.groups.io/g/iotivity-dev/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-