iotivity / iotivity-lite

To contribute code to the project, please visit
https://iotivity.org/get-involved
Apache License 2.0
126 stars 67 forks source link

About the function to delete and recreate OCF Device programmatically #589

Open Askidea opened 10 months ago

Askidea commented 10 months ago

@jkralik @Danielius1922

I'm trying to integrate bridge functionality into iotivity-lite. However, the latest library does not seem to support the ability to dynamically delete and recreate OCF Devices.

As an example, I created an 5 devices, or OCF Client, OCF Bridge and three VODs (Virtual OCF Device) in one android app. Then, when I deleted VOD#1 and tried to create it again, an error occurred and the app crashed. When I looked at the files/credentials directory of the app package with Android Studio's Device Explorer, I confirmed that u_ids_0~4 (also ael, cred, pstat, ... etc) were created. VOD#1 corresponds to u_ids_2.

In the case of ZigBee VOD, VOD must be dynamically created or deleted during the process of connecting and resetting the ZigBee device. Of course, it is required to manage the VOD index well, but first, I wonder if there will be any problems when dynamically deleting and re-creating the OCF Device (or VOD) in the latest iotivity-lite library.

Can anyone answer this issue?

joochlee commented 10 months ago

which iotivity-lite version are you using? current latest iotivity-lite does not include bridge support yet.

Askidea commented 10 months ago

@joochlee Based on the recent iotivity-lite (commit fc89bd6e), I am working on merging some of the ocfbridging branch's bridge-related source code and our Zigbee library into the iotivity source code. The point I want to know is whether the current iotivity-lite library supports the case of programmatically deleting and recreating a device. Looking at the source, I see that the OcPlaformclass has an addDevice() member function but no removeDevice(), so I am wondering if it is not supported. My guess is that the current iotivity library only allows adding devices in InitHandler and does not consider deleting them later. If so, it seems that it will also affect the VOD create/delete function.

joochlee commented 10 months ago

ocfbridging is tool old branch. Currently I'm trying to merge new bridging support code to iotivity-lite stack, but it does not include Android API supports.. Another API is required to add and delete VODs dynamically. So current latest iotivity-lite stack only provides the way to add OCF Device(s) statically in InitHandler as you said.