Knowing BluzDk index in gateway?



I’m new in Bluz-land and have what I hope is a very basic question.

I have one Photon Gateway with 5 BluzDK’s connected. Each BluzDK is doing different stuff and almost all communication is local.

The gateway needs to now the address/index of each BluzDk, so it can send the relevant instructions to the right BluzDK, know if the BluzDK is connected etc.

But “poll_connections()” returns the address/index in an arbitrary order, so when I call “send_peripheral_data(id, data, length)”, how can I know which id to use ?

Is there a way to get further information about the connected BluzDK’s in the “CONNECTION_RESULTS” event ?

Br Michael


It could be possible to get the device ID. Are you coding the gateway to actually send commands based on an address? I guess I am wondering, do you need some unique value for each that doesn’t change? Or do you need to know the exact address for each one and you hard code it?

For example, are you able to say “The first device I see gets ID 1 and will always be ID 1” or do you need to say “I know that device with address X is my living room sensor and he gets Y commands”

Just trying to figure out the right solution to the problem. Thanks


I don’t really care about the address, I just wants to know, which BluzDK to send a command to and which BluzDk to expect a reply from. For instance - the gateway wants to instruct the green-house-device to turn on the heater or water plants, which channel should the gateway use? Or the gateway receives a request to do something and report back – who should the gateway send the reply to ?

I think both your examples could work for me. But something like: "I know my light system is at address 2, when I receive data I know it came from address X and if the address’ change, I will know it” would be perfect. All I really need is an address for each device and a way to know if it change.

This way it would be easy to implement a simple protocol, and have the clients tell the gateway-Photon what/who they are and at what channel they can be reached. Using the poll function I could broadcast a request to all clients or just “new” clients.

At the moment my setup “kind of works” by having the gateway code making a poll, send the “index” to the bluzDK’s, which returns the same index, a device type and an id/name. Now the gateway knows the outdoor sensor is index 0, mail-box is index 1, fish tank is index 2 and so on. In each sendData from BluzDK I include the index, so the gateway knows which bluzDk to send the reply to.

This leaves me with at least to problems. All communication must be initiated by the gateway after a poll , so the BluzDK gets the index. And if the list of devices change, the index’s can change, an I have a problem. I believe I can work around most of the issues, but my code gets filled with house-keeping code and trafik, so it would be nice if the gateway could help a little more :wink:


Thanks for the details. I agree we can add some more to let the user app better handle connections. I think the easiest and best way is a global address, not the index of the current connection.

I have opened a ticket to track this:


A global address would be great - as long as it is available in booth sending and receiving scenarios.
Thanks, Michael