ZWay: getting the device list.
Back after a while... and a son!
Here is a piece of code that can be used with the latest version of the ZWay library. It makes it possible to retrieve the Z-Wave device list and display the device names and associated XML file (each recognized device can be associated to an XML that contains a bunch of meta-data: name, description etc.).
Now the following step for me is to understand how to write callbacks to get notified when a Z-Wave event occurs.
Here is a piece of code that can be used with the latest version of the ZWay library. It makes it possible to retrieve the Z-Wave device list and display the device names and associated XML file (each recognized device can be associated to an XML that contains a bunch of meta-data: name, description etc.).
int main(int argc, char ** argv) {
ZWay theZWay;
ZWError result;
memset(&theZWay, 0, sizeof(theZWay));
result = zway_init(&theZWay, "/dev/ttyAMA0",
"/home/pi/src/razberry-proxy/config",
"/home/pi/src/razberry-proxy/translations",
"/home/pi/src/razberry-proxy/ZDDX", stdout, Warning);
if (result == NoError) {
result = zway_start(theZWay, &terminationCb);
if (result == NoError) {
printf("Discovering...\n");
result = zway_discover(theZWay);
if (result == NoError) {
printf("Getting device list\n");
ZWDevicesList devicesList = zway_devices_list(theZWay);
ZWBYTE * pDeviceNodeId = devicesList;
if (pDeviceNodeId != NULL) {
while (*pDeviceNodeId != 0) {
printf("Device node ID: %d\n", *pDeviceNodeId);
if (*pDeviceNodeId > 1) {
ZGuessedProduct * productsList = zway_device_guess(theZWay, *pDeviceNodeId);
struct _ZGuessedProduct * pProduct = *productsList;
printf("Guessed product (%p): score=%d product=%s file_name=%s\n", pProduct, pProduct->score, pProduct->product, pProduct->file_name);
zway_device_guess_free(productsList);
}
pDeviceNodeId++;
}
zway_devices_list_free(devicesList);
} else {
printf("No devices?\n");
}
}
printf("Stopping ZWay...\n");
result = zway_stop(theZWay);
}
}
if (result != NoError) {
printf("Error: %d\n", result);
}
zway_terminate(&theZWay);
return 0;
}
Now the following step for me is to understand how to write callbacks to get notified when a Z-Wave event occurs.
Thank you, I needed any simple example shown how to init Z-Way and get devices list
ReplyDelete