本文整理汇总了C++中DataStream::gotLine方法的典型用法代码示例。如果您正苦于以下问题:C++ DataStream::gotLine方法的具体用法?C++ DataStream::gotLine怎么用?C++ DataStream::gotLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStream
的用法示例。
在下文中一共展示了DataStream::gotLine方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
void loop() {
static int disconnected;
if (millis() - lastCheck > 3000) {
if (networkStatus()) {
digitalWrite(RED_LED,LED_OFF);
disconnected=0;
} else {
digitalWrite(RED_LED,LED_ON);
if (++disconnected > 10) {
char tempssid[40];
strcpy(tempssid,networkSSID);
digitalWrite(RED_LED,networkJoin(tempssid)?LED_OFF:LED_ON);
}
}
digitalWrite(GRN_LED,SerialUSB.isConnected()?HIGH:LOW);
lastCheck=millis();
}
while (device.gotLine()) {
handleDeviceInput();
}
while (console.gotLine()) {
digitalWrite(GRN_LED,LOW);
handleConsoleInput();
digitalWrite(GRN_LED,HIGH);
}
Watchdog_Reset();
}
示例2: networkStatus
int networkStatus() {
int retval=0;
if (!hasWifiModule) return retval;
radio.discard();
radio.printf("\r\n");
radio.discard();
radio.printf("\r\nAT+WSTATUS\r\n");
while (!radio.gotLine()); // and some timeout.
while (!(retval=isErrorOrOK(radio.line()))){
if ((radio.line()[0]=='N') && (radio.line()[1] == 'O') && (radio.line()[2] == 'T')) {
//if (strncmp("NOT ASSOCIATED",radio.line(),10) ==0){ //wtf????
//console.debug("NOT ASSOCIATED\r\n");
return(0);
} else {
// console.debug("%s",radio.line());
}
while (!radio.gotLine()) {
// and some timeout!!!
;
}
}
//console.puts(radio.line());
return(retval>=1);
}
示例3: networkJoin
int networkJoin(char *ssid) {
int retval=0;
if (!hasWifiModule) return retval;
strcpy(networkSSID, ssid);
console.debug("joining: %s\r\n",networkSSID);
Watchdog_Reset();
radio.discard();
radio.printf("\r\nATE0\r\nAT+WA=%s\r\n",ssid);
while (!radio.gotLine()); // and some timeout.
while (!(retval=isErrorOrOK(radio.line()))){
//console.puts(radio.line());
while (!radio.gotLine()) { // timeout?
;
}
}
Watchdog_Reset();
radio.printf("\r\nAT+ndhcp=1\r\n");
delay(1000); // this should be an idle.
while (!radio.gotLine()); // and some timeout.
while (!(isErrorOrOK(radio.line()))){
console.debug("%s",radio.line());
while (!radio.gotLine()) {
;
}
}
//console.debug("join %s (%d)\r\n",networkSSID,retval=networkStatus());
return(networkStatus());
}
示例4: networkJoin
int networkJoin(char *ssid) {
int retval=0;
strcpy(networkSSID, ssid);
radio.discard();
radio.printf("\r\nATE0\r\nAT+WA=%s\r\n",ssid);
while (!radio.gotLine()); // and some timeout.
while (!(retval=isErrorOrOK(radio.line()))){
//console.puts(radio.line());
while (!radio.gotLine()) { // timeout?
;
}
}
radio.printf("\r\nAT+ndhcp=1\r\n");
delay(1000); // this should be an idle.
while (!radio.gotLine()); // and some timeout.
while (!(isErrorOrOK(radio.line()))){
console.printf("DBG: %s",radio.line());
while (!radio.gotLine()) {
;
}
}
//console.printf("\r\nDBG: join %s (%d)\r\n",networkSSID,retval=networkStatus());
return(networkStatus());
}
示例5: loop
void loop() {
static int disconnected;
console.printf("HELLO?\r\n");
if (millis() - lastCheck > 3000) {
digitalWrite(RED_LED,LED_OFF);
if ((! hasWifiModule) || networkStatus()) {
digitalWrite(RED_LED,LED_OFF);
disconnected=0;
} else {
digitalWrite(RED_LED,LED_ON);
if (++disconnected > 10) {
char tempssid[40];
strcpy(tempssid,networkSSID);
digitalWrite(RED_LED,networkJoin(tempssid)?LED_OFF:LED_ON);
}
}
digitalWrite(GRN_LED,SerialUSB.isConnected()?HIGH:LOW);
lastCheck=millis();
}
while (console.gotLine()) {
digitalWrite(GRN_LED,LOW);
handleConsoleInput();
digitalWrite(GRN_LED,HIGH);
}
clearStowedValues();
Watchdog_Reset();
}
示例6: setupRadioModule
/*------------------------------------------------------------setupRadioModule()
*
*----------------------------------------------------------------------------*/
void setupRadioModule(void) {
long int mark=millis();
console.printf("DBG: >>SetupRadioModule()\r\n");
radio.printf("\r\n");
radio.discard();
//radio.printf("ATE0\r\nAT&K0\r\nAT&R0\r\nAT+WD\r\nAT+NCLOSEALL\r\n");
radio.printf("ATE0\r\nATH\r\n");
while (!radio.gotLine());
while ((millis()-mark<1000)&&(!(hasWifiModule=isErrorOrOK(radio.line())))){
//console.debug("%s\r\n",radio.line());
while ((millis()-mark<1000)&&!radio.gotLine()) {
;
}
}
radio.discard();
console.printf("DBG: >>SetupRadioModule()\r\n");
}
示例7: networkSetPassword
int networkSetPassword(char *pwd) {
int retval=0;
// strncpy(networkPassword, pwd, MAX_NETWORK_PASSWORD_LENGTH-1);
strcpy(networkPassword, pwd);
radio.discard();
radio.printf("\r\nAT+WWPA=%s\r\n",pwd);
while (!radio.gotLine()); // and some timeout.
while (!(retval=isErrorOrOK(radio.line()))){
//console.puts(radio.line());
while (!radio.gotLine()) {
;
}
}
//console.debug("Password should be: %s (%d)\r\n",networkPassword,retval);
return(retval>=1);
}
示例8: setupRadioModule
/*------------------------------------------------------------setupRadioModule()
*
*----------------------------------------------------------------------------*/
void setupRadioModule(void) {
long int mark=millis();
radio.printf("\r\n");
radio.discard();
//radio.printf("ATE0\r\nAT&K0\r\nAT&R0\r\nAT+WD\r\nAT+NCLOSEALL\r\n");
radio.printf("ATE0\r\nATH\r\n");
while (!radio.gotLine());
while ((millis()-mark<1000)&&(!(hasWifiModule=isErrorOrOK(radio.line())))){
console.printf("DBG: %s\r\n",radio.line());
while (!radio.gotLine()) {
;
}
}
radio.discard();
networkSetPassword(networkPassword);
Watchdog_Reset();
networkJoin(networkSSID);
}
示例9: radioDate
time_t radioDate() {
time_t retTime=0L;
if (!hasWifiModule) return retTime;
radio.discard();
radio.printf("\r\nAT+GETTIME=?\r\n");
while (!radio.gotLine());
while (!(isErrorOrOK(radio.line()))){
//012345678901234567890q123456789012
if (!strncmp("Current Time in msec since epoch=",radio.line(),32)) {
console.printf("DBG: epoch as a string=%s\r\n",radio.line()+33);
retTime=(time_t)(atoll(radio.line()+33)/1000L);
console.printf("DBG: Epoch=%lu \r\n",retTime);
}
while (!radio.gotLine());
}
radio.discard();
return(retTime);
}
示例10: setRadioDate
bool setRadioDate(char * datebuffer) {
bool retval;
radio.printf("AT+SETTIME=%s\r\n",datebuffer);
while (!(retval=isErrorOrOK(radio.line()))){
while (!radio.gotLine()) {
;
}
}
delay(100);
radioDate();
}
示例11: pachubeDate
/*-----------------------------------------------------------------pachubeDate()
* pull date from pachube server
*----------------------------------------------------------------------------*/
int pachubeDate() {
uint8_t n,index=0;
int retval=0;
char databuffer[36];
char cid[4]="0";
bool gotResponse=false;
enum {CONNECT, ERROR, DISASSOCIATED} status=ERROR;//statii;
uint8_t ch='0';
if (!hasWifiModule) return retval;
radio.discard();
radio.printf("\r\n");
radio.discard();
radio.printf("\r\nAT+NCTCP=216.52.233.122,80\r\n");
while (!radio.available()); // and some timeout.
// ERROR
// CONNECT <CID>
// DISASSOCIATED
digitalWrite(ORN_LED,LOW);
while (!gotResponse){ // this needs to catch errors.
while (radio.available()) {
databuffer[index]=ch=(char) radio.read();
if (index<36) index++;
//console.putChar(ch);
if ((ch=='\n')||(ch=='\r')) {
databuffer[index]='\0';
if (strncmp("CONNECT", databuffer,6)==0) {
if (index>7) {
for (index=0, n=8; index<3 && databuffer[n];) {
cid[index++]=databuffer[n++]; // if isdigit????
}
cid[index]='\0';
}
status=CONNECT;
gotResponse=true;
console.debug("Connect CID=%s\r\n",cid);
} else if (strncmp("ERROR", databuffer,5)==0) {
gotResponse=true;
status=ERROR;
} else if (strncmp("DISASSOCIATED",databuffer,index)==0) {
gotResponse=true;
status=DISASSOCIATED;
}
index=0;
}
}
}
digitalWrite(ORN_LED,HIGH);
if (status!=CONNECT) {
console.debug("toPachube NOT CONNECTED! (%d) Exiting\r\n", status);
radio.discard();
return(0);
}
//snprintf(databuffer, 36, "%d,%s",key,value);
radio.printf("\033S%dHEAD / HTTP/1.1\r\n",atoi(cid),pachubeFeed);
radio.printf("User-Agent: SuspectDevices/Baco-matic5000 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15\r\n");
radio.printf("Host: api.pachube.com\r\nAccept: */*\r\nConnection: close\r\n");
radio.printf("X-PachubeApiKey: %s\r\n",pachubeKey);
radio.printf("Content-Length: 0\r\n\r\n\r\n\033E",strlen(databuffer),databuffer);
//console.debug("Sending Head / request\r\n");
//
// sent data then wait for an OK
//
while (!radio.gotLine());
while (!(retval=isErrorOrOK(radio.line()))){
//console.debug("%s\r\n",radio.line());
while (!radio.gotLine()) {
;
}
}
if (retval<1) {
console.debug("NOT OK! %s\r\n",radio.line());
radio.discard();
return(0);
}
//
// should get an escaped stream followed by a disconnect
//
index=0;
gotResponse=false;
digitalWrite(ORN_LED,LOW);
while (!radio.gotLine());
sprintf(databuffer,"%c%c%c%c%cS%dHTTP",0x1b,0x4f,0x1b,0x4f,0x1b,atoi(cid));
if(!strncmp(databuffer, radio.line(),strlen(databuffer)) ) {
databuffer[0]=radio.line()[16];
databuffer[1]=radio.line()[17];
databuffer[2]=radio.line()[18];
//.........这里部分代码省略.........
示例12: toTheEthers
int toTheEthers(int key, char * value) {
uint8_t n,index=0;
int retval=0;
char databuffer[36];
char cid[4]="0";
bool gotResponse=false;
enum {CONNECT, ERROR, DISASSOCIATED} status=ERROR;//statii;
uint8_t ch='0';
if (!hasWifiModule) return retval;
radio.discard();
radio.printf("\r\n");
radio.discard();
radio.printf("\r\nAT+NCTCP=198.202.31.182,80\r\n");
while (!radio.available()); // and some timeout.
// ERROR
// CONNECT <CID>
// DISASSOCIATED
digitalWrite(ORN_LED,LOW);
while (!gotResponse){ // this needs to catch errors.
while (radio.available()) {
databuffer[index]=ch=(char) radio.read();
if (index<36) index++;
//console.putChar(ch);
if ((ch=='\n')||(ch=='\r')) {
databuffer[index]='\0';
if (strncmp("CONNECT", databuffer,6)==0) {
if (index>7) {
for (index=0, n=8; index<3 && databuffer[n];) {
cid[index++]=databuffer[n++]; // if isdigit????
}
cid[index]='\0';
}
status=CONNECT;
gotResponse=true;
//console.printf("DBG: Connect CID=%s\r\n",cid);
} else if (strncmp("ERROR", databuffer,5)==0) {
gotResponse=true;
status=ERROR;
} else if (strncmp("NOT ASSOCIATED",databuffer,13)==0) {
gotResponse=true;
status=DISASSOCIATED;
} else if (strncmp("DISASSOCIATED",databuffer,13)==0) {
gotResponse=true;
status=DISASSOCIATED;
}
index=0;
}
}
}
digitalWrite(ORN_LED,HIGH);
if (status!=CONNECT) {
console.printf("DBG: toPachube() NOT CONNECTED! (%d) Exiting\r\n", status);
radio.discard();
return(0);
}
//snprintf(databuffer, 36, "%d,%s",key,value);
radio.printf("\033S%dGET /art2013/swls/&state=%s HTTP/1.1\r\n",atoi(cid),value?"ON" : "OFF");
//radio.printf("\033S%dPUT /art2013/swls/%s.csv HTTP/1.1\r\n",atoi(cid));
radio.printf("User-Agent: SuspectDevices/Baco-matic5000 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15\r\n");
radio.printf("Host: suspectdevices.com\r\nAccept: */*\r\nConnection: close\r\n");
radio.printf("X-PachubeApiKey: %s\r\n\r\n",pachubeKey);
//radio.printf("Content-Length: %d\r\n\r\n%s\r\n\033E",strlen(databuffer),databuffer);
//console.printf("DBG: Sending to feed %s: (%d)%s \r\n",pachubeFeed,strlen(databuffer),databuffer);
//
// sent data, wait for an OK
//
while (!radio.gotLine());
while (!(retval=isErrorOrOK(radio.line()))){
//console.printf("DBG: %s\r\n",radio.line());
while (!radio.gotLine()) {
;
}
}
if (retval<1) {
console.printf("DBG: NOT OK! %s\r\n",radio.line());
radio.discard();
return(0);
}
//
// should get an escaped stream followed by a disconnect
//
index=0;
gotResponse=false;
digitalWrite(ORN_LED,LOW);
while (!radio.gotLine());
sprintf(databuffer,"%c%c%c%c%cS%dHTTP",0x1b,0x4f,0x1b,0x4f,0x1b,atoi(cid)); // the double escapeing I dont get.
if(!strncmp(databuffer, radio.line(),strlen(databuffer)) ) {
databuffer[0]=radio.line()[16];
databuffer[1]=radio.line()[17];
//.........这里部分代码省略.........