Sorry for the beginner questions, but I?m trying to build a .NET wrapper around 
the C-API, so I can use C# to write Windows and Xamarin apps against Iotivity. 
I?ve gotten the first few calls to work and can successfully call into the API 
and get OK results back.

However I?m struggling with getting any of the callbacks to work. It could 
either be an issue with my .NET interop layer, or with my approach and what I?m 
expecting to happen. I?d like to rule out the latter, or be enlightened wrt 
what I?m doing wrong. I?m trying to follow the doc, and create and discover a 
light. Should something like the code below work? (It's C# but should be pretty 
close to the C syntax from the Wiki). All calls are returning OK, but none of 
the two callbacks ever get hit.

Initialize:
  var initResult = OCStack.OCInit1(OCMode.OC_CLIENT_SERVER, 
OCTransportFlags.OC_IP_USE_V4, OCTransportFlags.OC_IP_USE_V4);

In a separate pulse thread, call this every 1ms:
  var processResult = OCStack.OCProcess();

Create a light resource:
  IntPtr lightHandle = IntPtr.Zero;
  OCStackResult res = OCStack.OCCreateResource(out lightHandle, "core.light", 
"oic.if.baseline", "/light/1", OCEntityHandlerResult, IntPtr.Zero,  
OCResourceProperty.OC_DISCOVERABLE | OCResourceProperty.OC_OBSERVABLE);


Create client:
  var cbData = new OCStack.OCCallbackData();
  cbData.cb = OCClientResponseHandler; //callback method
  var ret =  OCStack.OCDoResource(IntPtr.Zero, OCMethod.OC_REST_DISCOVER, 
"/light/1", null, null, OCConnectivityType.CT_DEFAULT, 
OCQualityOfService.OC_LOW_QOS, cbData, null, 0);


?OCClientResponseHandler? and ?OCEntityHandlerResult? callback methods never 
get hit.

Am I completely wrong in expecting that running both a client and a resource in 
the same process would work? And is this really all that?s needed to create a 
resource, and discover them?

If things seem ok, I?d appreciate a few pointers to some good places to put 
some breakpoints where these callbacks would be initiated from within Iotivity.

Once I start getting things working, I do plan on sharing all this on GitHub, 
and provide the cross-platform nuget packages so it?s easy to set up and use.

Thanks
/Morten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20161208/374e72fa/attachment.html>

Reply via email to