I have published a library that will post data to the SparkFun Phant server (http://data.sparkfun.com). You can find it in the libraries as PietteTech_Phant.
Some differences between this library and the existing Phant library -
* Uses TCPClient block write and block reads when possible
* Designed with static internal buffers w/511 bytes of name/value pairs
* Currently only supports Steam Clear and Stream Post
* Waits for the response and checks return codes from the Phant server
* Error codes are returned from the sendData & addData calls
* You have access to human readable Phant messages using getError() method
The included example will show you how to post just about any data type and send it to the server. I have created a demo test stream on data.sparkfun.com so you can build the example and run it without having to create your own stream. You can view the data at http://data.sparkfun.com/streams/G2EroylGG1tmmoX44KKn
Please let me know if you experience any problems with this library. A lot of time has been spent into making it solid and robust with communications to the Phant server.
I just updated the Phant library to change the return value for the addData method.
Previously the addData method returned ‘0’ on failure and ‘1’ on success. Now on success it will return the number of bytes added to the stream and still return ‘0’ on failure.
Since the _params buffer (what gets sent to the Phant server in the POST method) is limited to 512 bytes this allows you to keep track of how much space you have used in the buffer.
Finally I would like to point out that if you get a failure on sending the data to the Phant server the contents of the _params buffer are intact. This way you can retry as many times as you wish. However if you do eventually give up on the send please remember to clear the buffer by calling the begin method before you start adding data again with addData. Otherwise you will have the previous data in the _params buffer when you add new data. This will cause errors with the Phant server as you could have multiple values for the same name in the data stream. (for example: I clear the buffer after I give up on line 145 in phanttest.ino)
I am trying to use @mtnscott Spark Core Data Library (PIETTETECH_PHANT 0.0.3) but all I can get (even with the example running) are connection errors:
Press any key to begin
PHANT test v1.0
Local IP Address = 192.168.178.42
Starting client.connect(data.sparkfun.com:80)
Failed to connectStarting client.connect(data.sparkfun.com:80)
Failed to connectStarting client.connect(data.sparkfun.com:80)
Failed to connectStarting client.connect(data.sparkfun.com:80)
Failed to connectStarting client.connect(data.sparkfun.com:80)
Failed to connectStream could not be cleared Retries = 5 - time = 7.0s
I also tried to connect via IP but with the same result.
I hope one of you may be has an idea.
Thank you a lot.
thank you for your fast response.
It is exactly like you said:
My Core seems to have these DNS Problem as it alway gets the IP 76.83.0.0 for DNS.
Is there anything I can do, to fix this?
@tooold, I’m glad we confirmed the problem. Unfortunately I have not discovered a reliable way to recover the core once it gets into this state. There are some workarounds based on your skill level. Since this is a different topic lets not discuss it here. PM me and we can discuss options.