Page 1 of 1

C Callback on Successful Device Add

Posted: 19 May 2018 05:02
by symantix
Hi All!

I'm using the C stack to run a modified version of z-way-test to do some automated work I need done. One of the things that I need to capture on a device add is an added device's newly assigned address.

I've hooked in to the callback for the add function, but I'm unable to figure out how to grab the new address.

My callback is prototyped as:

void add_success_callback( const ZWay zway, ZWBYTE functionId, void *arg)
{
...
}

I'm starting the add process with this call:

zway_fc_add_node_to_network(zway, TRUE, TRUE, add_success_callback, NULL, NULL);

Any ideas on how I can get the new address sent as an argument to add_successs_callback()?

Thanks in advance for your assistance!

Re: C Callback on Successful Device Add

Posted: 19 May 2018 20:02
by symantix
I figured out the answer to my own question, but thought I would share a solution:

int newAddress;
ZDataHolder newData;

data_acquire_lock(ZDataRoot(zway));
newData = zway_find_controller_data(zway, "lastIncludedDevice");
zdata_get_integer(newData, &newAddress);
zdata_release_lock(ZDataRoot(zway));

printf("New Device Address: %d\n", newAddress);


Seems to do the job for my application.

Re: C Callback on Successful Device Add

Posted: 02 Jun 2018 23:49
by PoltoS
There is a much better API call for this: zway_device_add_callback()