This project is read-only.

Asynchronous Communication

Jul 24, 2013 at 12:42 PM
In HomeOS documentation it is written to receive asynchronous I have to override AsyncReturn but in update version of HomeOS I have to do following

In the app:
  • call the Subscribe method on the port
  • override the OnNotification method
In documentation I found how to call subscribe method
switchPort.Subscribe("roleswitch", "getdimmer", this.ControlPort, this.switchPortCapability, this.ControlPortCapability);
but this.switchPortCapability is not well explained how to do so therefore I followed Dummy app and found I have to call subscribe method like this
if (Subscribe(port, RoleDummy.Instance, RoleDummy.OpEchoSubName))
  logger.Log("{0} subscribed to port {1}", this.ToString(), port.ToString());
  logger.Log("failed to subscribe to port {1}", this.ToString(), port.ToString());
When I debug the PortRegistered method in Apps.Dummy here GetCapabilityFromPlatform(port) gives me null and when I further dig into GetCapabilityFromPlatform
VCapability capability = GetCapability(targetPort, Constants.UserSystem); 
GetCapability is giving me null and Constants.UserSystem is
public static readonly UserInfo UserSystem = new UserInfo(0, "system", "system", DateTime.MinValue, DateTime.MaxValue, "");
I tried to change argument of username and password from system to my Hub username and password but all in vain. So what I am missing ?
Jul 24, 2013 at 9:32 PM
Sorry the developer doc is still work in progress. It's coming soon

You need to do a few things for asynchronous communication.
In the app:
  • call the Subscribe method on the port
  • override the OnNotification method
  • In the driver: call the Notify method
    Dummy driver and app use these APIs. The AsyncReturn API is old.
Jul 25, 2013 at 8:40 AM
Thanks Danny, we are anxiously waiting for developer document.

The thing I was asking that we were trying to execute Dummy app and diver module but Dummy App module was unable to subscribe. Because method
GetCapability(VModule requestingModule, VPort targetPort, string username, string password)
was returning NULL. We didn't know why this is happening but on exploring platform GetCapability method, we figured out that it is due to policy enforcement. In document "Getting_Started_with_Lab_of_Things.docx" just found that passing argument -p to platform will turn off policy enforcement. On passing "-p" we found that platform has stopped working. On exploring ProcessArguments we came to know that we have to pass "-p false" to turn off policy enforcement. That was the thing we were missing. So the solution to our problem is that we have to pass
-p false
as argument to Platform until we get proper documentation on policy enforcement.


Research Engineer
System and Networking Research Lab
Jul 26, 2013 at 9:45 PM
Thanks Zohaib, I made a correction to the document per what you found.