particle-iot / android-app

Spark Android App
https://www.spark.io/
Other
91 stars 60 forks source link

Smart config problem #5

Closed tangkechen closed 10 years ago

tangkechen commented 10 years ago

HI Now I am interesting how Android APP config SPARK core over WIFI,I hava found when I enter SSID's password and press CONNECT button , amount of data is been sent out from my android device ,and the speed is about 512k/s,when I look for the process of data transformation, I find the data had sent to 224.0.1.187:5685, google this ip and find the IP is IANA and a multicast address . Several questions confuse me:

1.How the APP does in order to send SSID's password?what the format of multicast information?what is the protocol?what is the detail of protocol?where is the source shows this process?can I change the IP to 224.0.1.186.. and port to 5686..?can I add other information in the multicast information,such as port's initial level?when the multicast information has been successfully sent ,what the SPARK core replies?

2.what does the SPARK core do when it received the multicast information? where is the source?

can you answer the above question ?

Best regards FRT

towynlin commented 10 years ago

Hi @tangkechen, great question!

The mobile app uses TI's Smart Config technology to broadcast AES encrypted Wi-Fi credentials to listening CC3000 Wi-Fi modules. TI does not make the source code for Smart Config available. See TI's CC3000 Smart Config page for more info.

As explained there, after the Wi-Fi module successfully connects to the Wi-Fi network, it multicasts mDNS packets locally to tell the mobile app that it has connected. Our call into the CC3000 API to send mDNS is in spark_wlan.cpp on line 540.

Check out the CC3000 firmware API documentation.

Separate from Smart Config, the Spark Core also announces its presence on the local network with a multicast CoAP message that includes the Core ID. See spark_utilities.cpp line 542.

This message is sent on the IANA registered multicast IP address for "All CoAP Nodes" 224.0.1.187. The default CoAP port according to the CoAP spec is 5683.

If you write firmware in the web IDE, you can't change this behavior, but you can additionally send your own UDP datagrams to any address and port that you want. See Spark's UDP documentation.

If you build the firmware locally (instructions in the core-firmware README) you can change the IP or port in spark_utilities.cpp or the format of the presence announcement in the core-communication-lib.

Hope that answers all your questions! In the future a better place for questions like this is in the Spark Community! Cheers!