|
7 | 7 | ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize and
|
8 | 8 | analyze live data streams in the cloud.
|
9 | 9 |
|
10 |
| - Copyright 2020, The MathWorks, Inc. |
| 10 | + Copyright 2020-2025, The MathWorks, Inc. |
11 | 11 |
|
12 |
| - See the accompaning licence file for licensing information. |
| 12 | + See the accompanying license file for licensing information. |
13 | 13 | */
|
14 | 14 |
|
15 | 15 | // #define PRINT_DEBUG_MESSAGES
|
|
18 | 18 | #ifndef ThingSpeak_h
|
19 | 19 | #define ThingSpeak_h
|
20 | 20 |
|
21 |
| - #define TS_VER "2.0.0" |
| 21 | + #define TS_VER "2.1.0" |
22 | 22 |
|
23 | 23 | #include "Arduino.h"
|
24 | 24 | #include <Client.h>
|
|
43 | 43 | #define TS_USER_AGENT "tslib-arduino/" TS_VER " (arduino samd)"
|
44 | 44 | #elif defined(ARDUINO_ARCH_SAM)
|
45 | 45 | #define TS_USER_AGENT "tslib-arduino/" TS_VER " (arduino sam)"
|
46 |
| - #elif defined(ARDUINO_ARCH_SAMD_BETA) |
47 |
| - #define TS_USER_AGENT "tslib-arduino/" TS_VER " (arduino samd_beta )" |
48 | 46 | #elif defined(ARDUINO_ARCH_ESP32)
|
49 | 47 | #define TS_USER_AGENT "tslib-arduino/" TS_VER " (ESP32)"
|
50 |
| - #elif defined(ARDUINO_ARCH_SAMD_BETA) |
51 |
| - #define TS_USER_AGENT "tslib-arduino/" TS_VER " (arduino vidor)" |
| 48 | + #elif defined(ARDUINO_ARCH_RENESAS_UNO) |
| 49 | + #define TS_USER_AGENT "tslib-arduino/" TS_VER " (arduino r4 uno)" |
| 50 | + #elif defined(ARDUINO_ARCH_RENESAS_PORTENTA) |
| 51 | + #define TS_USER_AGENT "tslib-arduino/" TS_VER " (arduino portenta)" |
| 52 | + #elif defined(ARDUINO_ARCH_RP2040) |
| 53 | + #define TS_USER_AGENT "tslib-arduino/" TS_VER " (raspberry pi rp2040)" |
| 54 | + #elif defined(ARDUINO_ARCH_RP2350) |
| 55 | + #define TS_USER_AGENT "tslib-arduino/" TS_VER " (raspberry pi rp2350)" |
52 | 56 | #else
|
53 | 57 | #define TS_USER_AGENT "tslib-arduino/" TS_VER " (unknown)"
|
54 | 58 | #endif
|
|
446 | 450 |
|
447 | 451 | Notes:
|
448 | 452 | To record a status message on a write, call setStatus() then call writeFields().
|
449 |
| - Use status to provide additonal details when writing a channel update. |
450 |
| - Additonally, status can be used by the ThingTweet App to send a message to Twitter. |
| 453 | + Use status to provide additional details when writing a channel update. |
451 | 454 | */
|
452 | 455 | int setStatus(String status)
|
453 | 456 | {
|
|
462 | 465 | }
|
463 | 466 |
|
464 | 467 |
|
465 |
| - /* |
466 |
| - Function: setTwitterTweet |
467 |
| - |
468 |
| - Summary: |
469 |
| - Set the Twitter account and message to use for an update to be tweeted. |
470 |
| - |
471 |
| - Parameters: |
472 |
| - twitter - Twitter account name as a String. |
473 |
| - tweet - Twitter message as a String (UTF-8) limited to 140 character. |
474 |
| - |
475 |
| - Returns: |
476 |
| - Code of 200 if successful. |
477 |
| - Code of -101 if string is too long (> 255 bytes) |
478 |
| - |
479 |
| - Notes: |
480 |
| - To send a message to twitter call setTwitterTweet() then call writeFields(). |
481 |
| - Prior to using this feature, a twitter account must be linked to your ThingSpeak account. Do this by logging into ThingSpeak and going to Apps, then ThingTweet and clicking Link Twitter Account. |
482 |
| - */ |
483 |
| - int setTwitterTweet(String twitter, String tweet){ |
484 |
| - #ifdef PRINT_DEBUG_MESSAGES |
485 |
| - Serial.print("ts::setTwitterTweet(twitter: "); Serial.print(twitter); Serial.print(", tweet: "); Serial.print(tweet); Serial.println("\")"); |
486 |
| - #endif |
487 |
| - // Max # bytes for ThingSpeak field is 255 (UTF-8) |
488 |
| - if((twitter.length() > FIELDLENGTH_MAX) || (tweet.length() > FIELDLENGTH_MAX)) return TS_ERR_OUT_OF_RANGE; |
489 |
| - |
490 |
| - this->nextWriteTwitter = twitter; |
491 |
| - this->nextWriteTweet = tweet; |
492 |
| - |
493 |
| - return TS_OK_SUCCESS; |
494 |
| - } |
495 |
| - |
496 |
| - |
497 | 468 | /*
|
498 | 469 | Function: setCreatedAt
|
499 | 470 |
|
|
629 | 600 | fFirstItem = false;
|
630 | 601 | }
|
631 | 602 |
|
632 |
| - if(this->nextWriteTwitter.length() > 0){ |
633 |
| - if(!fFirstItem){ |
634 |
| - if(!this->client->print("&")) return abortWriteRaw(); |
635 |
| - } |
636 |
| - if(!this->client->print("twitter=")) return abortWriteRaw(); |
637 |
| - if(!this->client->print(this->nextWriteTwitter)) return abortWriteRaw(); |
638 |
| - fFirstItem = false; |
639 |
| - } |
640 |
| - |
641 |
| - if(this->nextWriteTweet.length() > 0){ |
642 |
| - if(!fFirstItem){ |
643 |
| - if(!this->client->print("&")) return abortWriteRaw(); |
644 |
| - } |
645 |
| - if(!this->client->print("tweet=")) return abortWriteRaw(); |
646 |
| - if(!this->client->print(this->nextWriteTweet)) return abortWriteRaw(); |
647 |
| - fFirstItem = false; |
648 |
| - } |
649 |
| - |
650 | 603 | if(this->nextWriteCreatedAt.length() > 0){
|
651 | 604 | if(!fFirstItem){
|
652 | 605 | if(!this->client->print("&")) return abortWriteRaw();
|
|
1375 | 1328 | contentLen = contentLen + 8 + this->nextWriteStatus.length(); // &status=[value]
|
1376 | 1329 | }
|
1377 | 1330 |
|
1378 |
| - if(this->nextWriteTwitter.length() > 0){ |
1379 |
| - contentLen = contentLen + 9 + this->nextWriteTwitter.length(); // &twitter=[value] |
1380 |
| - } |
1381 |
| - |
1382 |
| - if(this->nextWriteTweet.length() > 0){ |
1383 |
| - contentLen = contentLen + 7 + this->nextWriteTweet.length(); // &tweet=[value] |
1384 |
| - } |
1385 |
| - |
1386 | 1331 | if(this->nextWriteCreatedAt.length() > 0){
|
1387 | 1332 | contentLen = contentLen + 12 + this->nextWriteCreatedAt.length(); // &created_at=[value]
|
1388 | 1333 | }
|
|
1540 | 1485 | float nextWriteElevation;
|
1541 | 1486 | int lastReadStatus;
|
1542 | 1487 | String nextWriteStatus;
|
1543 |
| - String nextWriteTwitter; |
1544 |
| - String nextWriteTweet; |
1545 | 1488 | String nextWriteCreatedAt;
|
1546 | 1489 | #ifndef ARDUINO_AVR_UNO
|
1547 | 1490 | feed lastFeed;
|
|
1597 | 1540 | // make sure all of the HTTP request is pushed out of the buffer before looking for a response
|
1598 | 1541 | this->client->flush();
|
1599 | 1542 |
|
1600 |
| - long timeoutTime = millis() + TIMEOUT_MS_SERVERRESPONSE; |
| 1543 | + unsigned long timeoutTime = millis() + TIMEOUT_MS_SERVERRESPONSE; |
1601 | 1544 |
|
1602 | 1545 | while(this->client-> available() < 17){
|
1603 | 1546 | delay(2);
|
|
1715 | 1658 | this->nextWriteLongitude = NAN;
|
1716 | 1659 | this->nextWriteElevation = NAN;
|
1717 | 1660 | this->nextWriteStatus = "";
|
1718 |
| - this->nextWriteTwitter = ""; |
1719 |
| - this->nextWriteTweet = ""; |
1720 | 1661 | this->nextWriteCreatedAt = "";
|
1721 | 1662 | }
|
1722 | 1663 | };
|
|
0 commit comments