We have Remote Things set up so that they only send data to the platform when the value changes. When a new device is connected, there may be a period of time between when it initially connects & starts sending data & when a Thing is instantiated on the platform. The problem is that the SDK does not know that the Thing does not exist (is unbound) and subsequently filters property values that are not changing.
For example, I might have a property such as the IP address of the Thing. When it connects, its starts trying to update the property on the platform. This fails because the Thing does not yet exist on the platform. By the time the Thing does exist, the SDK is now filtering out the IP address from being sent to the platform because it is not changing.
One solution would be to not send data to the platform if the Thing is unbound (does not exist on the platform). We're using the Java SDK - is there a way for our edge device to find out from the platform if it has been bound?
After you have connected, before you are binding, you can execute Services/REST API calls on the platform.
So the agent could
1. Connect
2. Ask is there a RemoteThing to Bind to
3. Bind
4. Start sending data
Thanks for sharing this. We'd like more control over the binding process and so don't really want to automatically bind a remote thing that is sending data. Are there any examples of the agent learning of the binding status of a remote thing from the platform?
would the following be helpful? I got this from a team member
this is from the C sdk I think
There is a “twApi_RegisterBindEventCallback” callback that can be registered for bound and unbound workflows.
**
* \brief Registers a function to be called when an entity is bound or unbound
* (see callback function signature bindEvent_cb()).
*
* \param[in] entityName Callbacks are filtered to the specified
* entity. A NULL value receives all callbacks.
* \param[in] cb The function to be called.
* \param[in] userdata An opaque pointer that is passed into the
* callback function.
*
* \return #TW_OK if successful, positive integral on error code (see
* twErrors.h) if an error was encountered.
*/
int twApi_RegisterBindEventCallback(char * entityName, bindEvent_cb cb, void * userdata);
[UPDATE]:
I don't see this API in the java SDK. It also occurred to me that a virtual thing could already be created for the remote thing and so I wouldn't see the callback.
The issue I'm facing is that remote thing property values are not seen in the virtual thing on the platform. In our system, remote things are bound in the edge before the corresponding virtual things are created. Once the remote things are bound, the property values are cached in the SDK and values of properties that don't change often are not seen in the virtual thing once it is created. I know we can change the property attributes to always push but that doesn't seem like an appropriate way to address this issue.
I'm looking for a way to determine IF a remote thing has a virtual thing for it on the platform. If it does not, I will delay setting properties for the remote thing via the SDK. An alternative to this would be to flush the SDK cache for the bound remote thing properties once a virtual thing has been defined for the remote thing. Both of these options require determining if a remote thing has a corresponding virtual thing.
This looks like it would allow us to do just what we want to do! Thanks for the pointer!
If it works, we'll mark it as the solution.
We addressed this problem by implementing a Thing service and calling the service from our connected client each time a remote thing new to the connected client instance shows up. The code from this post: Creating a Thing from a Virtual Thing Service (Java SDK) was leveraged for our purposes.