C Sample....really exhausted !!

Discussions about RaZberry - Z-Wave board for Raspberry computer
gilpel
Posts: 14
Joined: 14 Jul 2013 14:30

Re: C Sample....really exhausted !!

Post by gilpel »

Hello,

Thanks for your quick reply.
This is an expected behavior....
Clear.

Regarding the second question, I was expecting managing as I do with the ZWAVE API

Code: Select all

http://192.168.0.9:8083/ZWaveAPI/Run/devices[7].instances[0].commandClasses[0x30]
which returns

Code: Select all

{"supported":true,"name":"SensorBinary","data":{"name":"devices.7.instances.0.commandClasses.48.data","type":"NoneType","value":null,"updateTime":1398611448,"invalidateTime":1398611447,"version":{"name":"version","type":"int","value":1,"updateTime":1398611448,"invalidateTime":1398611447},"security":{"name":"security","type":"bool","value":false,"updateTime":1398611448,"invalidateTime":1398611447},"interviewDone":{"name":"interviewDone","type":"bool","value":true,"updateTime":1398611454,"invalidateTime":1398611447},"interviewCounter":{"name":"interviewCounter","type":"int","value":5,"updateTime":1398611454,"invalidateTime":1398611447},"typemask":{"name":"typemask","type":"int","value":2,"updateTime":1398611454,"invalidateTime":1398611447},"1":{"name":"1","type":"NoneType","value":null,"updateTime":1398876569,"invalidateTime":1398611453,"sensorTypeString":{"name":"sensorTypeString","type":"str","value":"General purpose","updateTime":1398611454,"invalidateTime":1398611453},"level":{"name":"level","type":"bool","value":false,"updateTime":1398876569,"invalidateTime":1398611453}}},"id":48}

I also just tried to manage with :

basic_level_holder = zway_find_device_instance_cc_data(zway, 7, 0, 0x80, "last");

but basic_level_holder is null !
Regards
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: C Sample....really exhausted !!

Post by pofs »

There's no simple way to get JSON in C API. If you need it, you should enumerate data holders and manually serialize them as JSON.
To recursively enumerate DHs, do something like this:

Code: Select all

ZDataHolder cc_data = zway_find_device_instance_cc_data(zway, 7, 0, NULL);
PrintSubtree(zway, cc_data, 0);
...
void PrintSubtree(ZWay zway, ZDataHolder parent, int indent) {
  // print indented name
  for (int i = 0; i < indent; i++)
    printf("  ");
  printf("%s\n", zway_data_get_name(zway, parent));

  ZDataIterator child = zway_data_first_child(zway, parent);
  while (child != NULL) {
    PrintSubtree(zway, child->data, indent + 1);
    child = zway_data_next_child(child);
  }
}
but basic_level_holder is null !
Are you sure there's a Battery CC for this particular device? Is it returned by HTTP API?
gilpel
Posts: 14
Joined: 14 Jul 2013 14:30

Re: C Sample....really exhausted !!

Post by gilpel »

Hi,

Battery CC request is now working (don't know really what I did !!).

Thanks a lot for your help.
gilpel
Posts: 14
Joined: 14 Jul 2013 14:30

Re: C Sample....really exhausted !!

Post by gilpel »

Hello,

I'm looking for a way to initiate a single callback in order to receive a value change on any devices, and then retreiving the value and the device ID in the callbacK...this rather than setting a callback for each devices.

Hope this is clear.

Thanks for your help.
pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: C Sample....really exhausted !!

Post by pofs »

Well, there's no such way. You'll need to setup a callback for each device.

One of the reasons is, DataHolder has no particular knowledge which device, instance or command class it belongs to (and more than that, it might not belong to any, e.g. controller.data object). So even if there was a way to use a single callback for each value change, it would be hard to distinguish between devices (actually you could do it by parsing DH path, but that's ugly).

I can't imagine a scenario where you need to watch every change for every single command class on every device. Can you give some specifics on what you're trying to achieve?
zuzzurellone
Posts: 3
Joined: 25 Jun 2014 17:48

Re: C Sample....really exhausted !!

Post by zuzzurellone »

Hello , I'm quite lost in between the C API topic that I tried to understand. I'm not an experienced developper I basicly need to include two sensors to a z-wave network that I suppose to create. Where to start with C API. Can anybody show a way please, I would be really thankful
Post Reply