Hello everyone,
After buying and setting up (by the way, dvo1, if you read this, thanks for your tip :)) the ENC Ethernet chip for my Arduino the next task is to make Arduino communicate with some internet services, microblogs, for instance. I've already made a small weather station, in the end it gets two integers, let name them temp and humid.
Of course, there must be loads of tutorials how to get your Arduino send Twitter posts, but, the problem is, I'm now in Beijing, China, I think some of you know the situation with Twitter here (it's blocked). Of course, VPN can be used, but i think it's too hard or even impossible to make Arduino and ENC serve as VPN client. So, I've thought about using not Twitter, but China-based Sina Weibo microblog service instead. After searching. I've found a code made by one of Chinese websites to make Arduino communicating with Weibo. It uses a? intermediate platform set by its creators, but I think that to understand my problem it's not neccessary to understand how this platform works.
Okay, the code just for posting (doesn't include the get ints part, written by the 3-rd party) is
#include <EtherCard.h>
static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
char website[] PROGMEM = "nupttemp.duapp.com";
int j;
const char *T;
byte Ethernet::buffer[700];
static uint32_t timer;
int i=0;
//////There must be the Weibo access token instead of 333..., I have my own
char q[200]="api.php?access_token=333333333333333333333333&status=The status goes here";
static void response_callback (byte status, word off, word len) {
Serial.print((const char*) Ethernet::buffer + off);
}
void setup () {
Serial.begin(9600);
Serial.println("Client Demo");
Serial.println();
if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
Serial.println( "Failed to access Ethernet controller");
else
Serial.println("Ethernet controller initialized");
Serial.println();
if (!ether.dhcpSetup())
Serial.println("Failed to get configuration from DHCP");
else
Serial.println("DHCP configuration done");
ether.printIp("IP Address:\t", ether.myip);
ether.printIp("Netmask:\t", ether.mymask);
ether.printIp("Gateway:\t", ether.gwip);
Serial.println();
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
else
Serial.println("DNS resolution done");
ether.printIp("SRV IP:\t", ether.hisip);
Serial.println();
}
void loop() {
ether.packetLoop(ether.packetReceive());
if (millis() > timer) {
timer = millis() + 20000;
ether.browseUrl(PSTR("/"), q, website, response_callback);
Serial.println(q);
}
}
The problem is, if I understand correctly, this code was initially made to send a fixed message. But is it possible to use the two ints got in a previous parts of the program as the message text? If possible, how should be the code modified (I feel that's all about the "char q[200]="api.php?access_token=333..." string) (for example, i tried just using the "+" operation in different ways, but it didn't help)? Can anybody understand how this code works? I'm a newbie in programming, so there are lot of things I can't understand by myself. The communication with the author of the script is too slow, the first email to him got the answer only after some 5 days, so in this way it will take too long to understand how the thing works.
Thanks for any help,
Paul.