[SOLVED] Bluz Gateway Photon+Bluz DK Local Communication-Not Publishing



I am trying out your example from here:


When I compile code for Gateway Photon, it failed at this line:

bluz_peripherals_available++ (not declared)

So I declared it as integer and flash it successfully. Using Gateway Library version 1.6.

On the DK side, the sample code flash successfully. I restart the Gateway Photon and wait till it gets connected to Particle cloud then turned on Bluz_DK but I don’t see any publish event (Bluz Devices Online) from DK on Particle Console.

What am I missing???



Thanks for the notice on the missing line! I fixed that in the docs so it will get pushed out to production soon, it is on staging currently.

As for the example, I just tried this again to make sure and everything is working ok here. A few questions:

  1. Is the DK blinking white? This indicates it is connected to the gateway but not to the cloud. If it is blinking green, then it isn’t connecting to the gateway at all.
  2. You mentioned that you don’t see any events from the DK, but this is expected. The Photon would send the events on behalf of the DK. You should also see polling responses from the Photon indicating there are devices online, this should happen regardless of whether there are DK’s connected. Do you see events like this?

If you aren’t seeing the “Bluz Devices Online” event from the Photon at all, then I suspect it wasn’t flashed properly with the example in the tutorial. If you do, but it always says “O O O”, which indicates no devices are connected, then there is probably an issue with getting the DK connected to the gateway.

If you do see that Bluz Devices Online event with “X O O” but not any data from the DK (“Hi” in this example), then I suspect the DK didn’t get updated properly.

Let me know


@eric, please see my answers below:

  1. Yes, DK is blinking white.
  2. I meant DK events were not get published by Photon. Sorry. No, I do NOT see any polling responses like you mentioned. All I saw were “module-info” and “bluz gateway device id” in particle console.

I do not see any “Bluz Device Online” event with “X O O” or “O O O”. How do I put the DK back to AUTOMATIC mode without connecting D6. Is there a factory reset mode? I want to flash it again. But when I did it DK flash seems to be successful.



If the DK is blinking white, you probably have the correct code on it. If the Photon is not publishing the “Bluz Devices Online” event, then it sounds like the Photon does not have the proper code.

You should try re-flashing the Photon with the example code, I think that is the issue.


@eric, I just re-flashed the Photon Gateway with the code below but still NO Bluz DK events.

// This #include statement was automatically added by the Particle IDE.
#include “bluz_gateway/bluz_gateway.h”


bluz_gateway gateway;
int bluz_peripherals_available;

void handle_custom_data(uint8_t data, uint16_t length) {
//if you use BLE.send from any connected DK, the data will end up here
Particle.publish(“Bluz Custom Data”, String((char

void handle_gateway_event(uint8_t event, uint8_t *data, uint16_t length) {
//will return any polling queries from the gateway here
uint8_t rsp[2] = {‘H’, ‘i’};
switch (event) {
String online_devices = “”;
for (int i = 0; i < length; i++) {
if (data[i] == 0) {
online_devices +="O ";
} else {
online_devices +="X ";
gateway.send_peripheral_data(i, rsp, 2);
Particle.publish(“Bluz Devices Online”, online_devices);

void setup() {

//register the callback functions


void loop() {
if (millis() > timeToNextPoll) {
timeToNextPoll = POLL_CONNECTIONS_INTERVAL + millis();


@eric, I also just re-flashed the bluz-dk, and re-start gateway and dk. Still no DK events published by Photon. What am I missing? I am using Bluz_Gateway library 1.6.0.

Bluz_DK code:

#include "application.h"

bool sendData = false;

void dataCallbackHandler(uint8_t *data, uint16_t length) {
sendData = true;

void setup() {

if (digitalRead(D6) == HIGH) {


void loop() {
if (sendData)
uint8_t rsp[2] = {‘H’, ‘i’};
BLE.sendData(rsp, 2);
sendData = false;



Can you add a Particle.publish somewhere else in the code? Or if you flash simple publish code to the Photon, does it work? If the Photon isn’t publishing basic events, then there is something wrong with the device.


@eric, Photon is publish, please is below. Looks like DK is not sending event to Photon to publish.


@eric, looks like the callbacks are not getting called.



Can you try updating your gateway to he latest firmware here: http://staging-console.bluz.io/

After you login, it should show you the gateway and just have a button to update. It can take a minute or two, but then you should be able to try again.


@eric, i tried staging but after I login all I see was header on the page saying Welcome to the bluz console Gateways. There is noting for me to click on or do anything with it. Please explain??


The only reason you shouldn’t see the device in there is if your Photon doesn’t have the correct variable.

There is a Particle.variable inside the blua-gateway library called gatewayID. When the Photon starts, it polls the nrf51 on-board for the gateway for it’s ID and stores it in this variable. The console then looks for all Photons with that specific variable on your account, and if it finds one, it lists it.

So if it isn’t showing up in console, then it can’t find the Photon or it can’t find the variable on it.

A few questions:

  • Did you login to console with the same account that your Photon is claimed to?
  • Can you open the (new) Particle app and look at the Photon? It gives you a list of variables under the “Data” tab and you should see one called gatewayID listed with another ID like “b1e2…”. Alternatively, you could look at the Particle CLI if that is easier.


@eric, I got it working. Thanks for your help. Just FYI, for very first Custom Data, meaning right after Photon reboot, the data only comes through “i” instead of “Hi” but consequent publish events come thru “Hi.”