Broadcasting Photon's presence on the network?

My Photon came in yesterday and this little sucker looks great! Nice work!

Is “Multicast_Presence_Announcement()” gone on the Photon or is there another way to broadcast it’s presence on the network?

I pretty much let my Core collect dust while the TCP client/server stuff was bunk and thought I’d give my code a go again on the Photon.

I have no idea what new method is used to broadcast it’s presence on the network once it comes online. My nodejs UDP server running tells the core the IP to connect to the server once the multicast happens.

Pretty sure this was code @zachary (or maybe it was @dave) had wrote ages ago in node for me, but any insight as to how people are detecting the devices coming online the first time would be awesome! (bonus points if I can do this all via the local network and not have to use the cloud)

1 Like

Hi @Endoplasmic — great question!

Bleeding edge development for the Photon is on the develop branch of firmware. You can see on the develop branch on line 472 of system/src/system_cloud.cpp that Multicast_Presence_Announcement() (defined near the end of that same file) is still called in Spark_Handshake(). That said, our mobile app is not currently using this feature.

Now, the rub, and the reason I bet you’re asking is that you can no longer call Multicast_Presence_Announcement() from your user code. This is a consequence of our separation and dynamic linking of user and system code. The separation gets us blazing fast OTA and better cross-device compatibility (because everyone uses the same high-level APIs). However, it means you can’t access every low level call anymore without doing some work.

In any case, the presence announcement is just a simple UDP multicast packet, nothing too spooky. It’s easy to code this from a user app — so I did:

The CoAP header function that wraps the ID was copied straight from the communication library.

Bonus points achieved: only Wi-Fi, no cloud. :wink:

6 Likes

We can add Multicast_Presence_Announcement() to our public API for the 0.4.1 release at the end of this sprint, if that’s useful.

3 Likes