I am using a twitter library to send out tweets, I think though twitter flips out now if its the same message, so I figured I could create a message with a millis stamp to make it unique and then send that out. though something is not working out. this is my code:
char msg[] = "Garage Door is OPEN";
int millisRollover() {
// get the current millis() value for how long the microcontroller has been running
//
// To avoid any possiblity of missing the rollover, we use a boolean toggle that gets flipped
// off any time during the first half of the total millis period and
// then on during the second half of the total millis period.
// This would work even if the function were only run once every 4.5 hours, though typically,
// the function should be called as frequently as possible to capture the actual moment of rollover.
// The rollover counter is good for over 35 years of runtime. --Rob Faludi http://rob.faludi.com
//
static int numRollovers=0; // variable that permanently holds the number of rollovers since startup
static boolean readyToRoll = false; // tracks whether we've made it halfway to rollover
unsigned long now = millis(); // the time right now
unsigned long halfwayMillis = 17179868; // this is halfway to the max millis value (17179868)
if (now > halfwayMillis) { // as long as the value is greater than halfway to the max
readyToRoll = true; // you are ready to roll over
}
if (readyToRoll == true && now < halfwayMillis) {
// if we've previously made it to halfway
// and the current millis() value is now _less_ than the halfway mark
// then we have rolled over
numRollovers = numRollovers++; // add one to the count the number of rollovers
readyToRoll = false; // we're no longer past halfway
}
return numRollovers;
}
int ts = millisRollover();
call with sendTweet(ts);
void sendtweet(int ts)
{
String theMsg = msg;
theMsg.concat("time:" + ts);
char msg2[theMsg.length()];
theMsg.toCharArray(msg2, theMsg.length());
if (twitter.post(msg2)) {
...
}
}
So the messages that get sent out have no stamp to them just the msg, am I misusing toCharArray?