Hi Kevin, > ==> Basically I understand this situation. but what if a server updates its > Observable > Resource by itself without any POST/PUT requests from outside? > Can current stack send notification automatically in this case?
No. The application code needs to call oc_notify_observers() whenever it induces or becomes aware of a change in the resource's state. For e.g., consider the resource's state as some data structure/value (temperature) that’s just been written into/changed. Application code should be written such that this change somehow leads to an oc_notify_observers() call. When oc_notify_observers() is called, it makes the stack capture the most current state (by leveraging the resource's GET handler) and sends notifications with that representation to all of the resource's observers. apps/server_multithread_linux.c has a trivial example of this pattern. Thanks, -Kishen. -- Kishen Maloor Intel Corporation From: Joo-Chul Kevin Lee <cms.r...@gmail.com> Date: Wednesday, July 24, 2019 at 12:08 AM To: "Maloor, Kishen" <kishen.mal...@intel.com> Cc: iotivity-dev <iotivity-dev@lists.iotivity.org> Subject: Re: [dev] [iotivity-lite] how to handle notification in iotivity-lite? Hi Kishen, I'm very happy to receive your reply! I've been waiting for you :) BTW, thank you for explanation. Some of them matches what I have guessed. But, I have additional question.. please see inline Thanks & BR :) - Kevin On Wed, Jul 24, 2019 at 3:41 PM Maloor, Kishen <kishen.mal...@intel.com<mailto:kishen.mal...@intel.com>> wrote: Hi Kevin, Notifications are constructed and sent internally by the stack following a few triggers as explained below. Notifications are automatically sent following all POST/PUT requests to any Observable resource. This is handled internally by capturing the most recent resource state and packaging it into a notification. ==> Basically I understand this situation. but what if a server updates its Observable Resource by itself without any POST/PUT requests from outside? Can current stack send notification automatically in this case? The resource's state is whatever is usually read by the GET handler of the resource. If you want notifications to be periodic, you must use oc_resource_set_periodic_observable() on the resource specifying a frequency of that observation. In this case, the stack internally polls the resource and sends out a notification with its most recent state every time a notification is scheduled. The application doesn't have to do thing. If you need to send notifications asynchronously, you will instead use oc_resource_set_observable() on the resource, and later call oc_notify_observers() (synchronizing with oc_main_poll()) from any task in your application that produces a change in the resource's state (again data structures read by the resource's GET handler). -Kishen. -- Kishen Maloor Intel Corporation From: <iotivity-dev@lists.iotivity.org<mailto:iotivity-dev@lists.iotivity.org>> on behalf of Joo-Chul Lee <cms.r...@gmail.com<mailto:cms.r...@gmail.com>> Date: Tuesday, July 23, 2019 at 7:28 PM To: iotivity-dev <iotivity-dev@lists.iotivity.org<mailto:iotivity-dev@lists.iotivity.org>> Subject: [dev] [iotivity-lite] how to handle notification in iotivity-lite? Hi iotivity folks, I have a question about notification mechanism in IoTivity-lite. In IoTivity classic, server can check existence of “observe option” in callback function registered to specific Resource. and therefore the server can send following notification responses based on its notification logic. However, I can’t find such codes in IoTivity-lite samples. How can server know if there is “observe option” in request message? Could anyone explain how notification works in IoTivity-lite stack ? Thanks & BR :) - Kevin -- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Joo-Chul Kevin Lee, ETRI 161 Gajeong-dong, Yuseong-gu, daejon, 305-700, KOREA E-mail: r...@etri.re.kr/cms.r...@gmail.com<http://r...@etri.re.kr/cms.r...@gmail.com> Tel: +82-42-860-1021 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -- -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Joo-Chul Kevin Lee, ETRI 161 Gajeong-dong, Yuseong-gu, daejon, 305-700, KOREA E-mail: r...@etri.re.kr/cms.r...@gmail.com<http://r...@etri.re.kr/cms.r...@gmail.com> Tel: +82-42-860-1021 -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10245): https://lists.iotivity.org/g/iotivity-dev/message/10245 Mute This Topic: https://lists.iotivity.org/mt/32580414/21656 Group Owner: iotivity-dev+ow...@lists.iotivity.org Unsubscribe: https://lists.iotivity.org/g/iotivity-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-