Академический Документы
Профессиональный Документы
Культура Документы
This project is integrating several technologies, found during the investigation of my new FlyPort : Web server Wifi connection Dynamic variables substitutions (in xml files) Ajax callbacks jQuery use case Dynamic Memory allocation (malloc/free) (see heap.s) Web service calls : for tweeter, thingspeak and nimbits
I created accounts for Nimbits, Thingspeak and declare some channels inside to be able to publish. I used for the test my own twitter, but it is advised to change by a dedicated account for the sensors you want to monitor. For twitter, you will get a key to let your sensor write into the stream. For Thingspeak & Nimbits, idem, you will need a key for sending your data to the right channel.
You see in the index.htm page 3 mydynvar areas that will be set by the function called readData() This readData() is making a get of the data.xml file of the Flyport server. While processing the data.xml content below, you see that 2 variables t & rh will be substituted by the result of the server call of the HTTPPrint_xxx() functions.
Here ~t~ and ~rh~ will be replaced by the values returned by the HTTPPrint_t &nd HTTPPrint_rh in the server.
Then 2 libraries are integrated to the project Nimbits.c/.h Thingspeak.c/.h (included tweet and thingspeak, as well as query not demonstrated in that case)
I updated the nimbits(simplified, as it was crashing) void wfNIMBITS(char* hostappspot, char* email, char* secret, char* namevalue, float* value); I also integrated some dynamic memory allocation to avoid the static alloc of hundreds of bytes in each function that will not be released. Use of malloc / free. For that I integrated a heap.s file in the project directory
If you do want to remove some, just remove the call to the function in the main task code. 2. 3. 4. 5. 6. Then in the OpenPicus IDE, open the existing project file temperatura.conf Click on the Wizard for the connection setup, and the Web Pages button to generate the intermediate code. Launch the compilation of the project. Download to the Flyport
Then connect your browser to the IP address of your http Flyport defined in the configuration wizard (like 192.168.0.27) You should see the main page as above. Then you will check that your actions to send message is fine by connecting to each of the sites (twitter, thingspeak or nimbits) to verify that the messages are well received and recorded. I have noticed that the processing of one message is lasting >10 seconds, so you have to wait between clicks It could be improved by putting some real time programming like critical areas and semaphores, but for this project it is fine with me.