I’m trying to use a Tracker to connect some BLE devices to my backend over cellular. What I’ve implemented so far works fine, except that I need the Tracker to receive information about the user operating it from my backend. I built a similar system with a Boron a while back and just subscribed to the webhook response, then iterated through the JSON it got back to get the data, and it worked fine. However, the Tracker doesn’t seem to actually subscribe to the webhook response event; the handler I assign to it is never called. I know the event firing the webhook is actually being sent, because it shows up on my backend. The device should receive its information from my backend as soon as it connects to the cloud, so I fire the event that fires the webhook on the first call of loop() after subscribing to the webhook response in setup(); is there a chance some sort of race condition is happening where the response arrives before the subscription is registered?
You could keep sending the event repeatedly and only stop sending after you successfully received the response (e.g. via a flag set inside the sub handler).
I just tried this, and even after sending the event several times, the response handler is never called. Earlier I tried waiting until 10 seconds had passed after the device had initially connected to the cloud to send the event, and that didn’t work either. The only two things I can think of that could be an issue here are 1) because the Tracker is in a product, is the syntax for webhook response events different? and 2) is there something that has to be done to the webhook configuration to allow response events to be sent for product webhooks? This is incredibly bizarre behavior; like I said, virtually the exact implementation I’m using now worked with a Boron without any problems, and the Boron was in a product IIRC.
IFAICT even product devices should be able to receive webhook responses they themselves had initiated via a
Particle.publish() call - otherwise I’d not see a lot of use in
Particle.subscribe() for these devices at all.
However, it may help if you could show the webhook definition and the related publish/subscribe calls.
But for an official statement we can ping @Colleen
By default, Tracker devices are unclaimed product devices. Since they are not claimed to a user account, they cannot receive events. In order to be able to subscribe to events you’d need to claim all of the devices, typically to a single account.
You can use function calls with unclaimed product devices, which is how the configuration service updates are handed.
That makes much more sense. This sounds like a dumb question, but how would I claim the device to a user account? I now see in its page on the console that the owner is given as ‘unowned’, but I don’t see a place to add an owner.
Just did some poking around and found how to claim through the CLI; everything works as it should now.
For posterity: Device Claiming | Tutorials | Particle
It would have been very helpful to me if this had been made a note in the documentation for subscribing in the Device OS API or in the tutorial on using custom firmware with the Tracker. Thanks!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.