C Callback on Successful Device Add

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
symantix
Posts: 2
Joined: 06 Jan 2018 08:15

C Callback on Successful Device Add

Post by symantix » 19 May 2018 05:02

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!

symantix
Posts: 2
Joined: 06 Jan 2018 08:15

Re: C Callback on Successful Device Add

Post by symantix » 19 May 2018 20:02

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.

User avatar
PoltoS
Posts: 4092
Joined: 26 Jan 2011 19:36

Re: C Callback on Successful Device Add

Post by PoltoS » 02 Jun 2018 23:49

There is a much better API call for this: zway_device_add_callback()

Post Reply