void SerialPutString(const char *address) /******************************************************************************* * ABSTRACT: This function sends a null-terminated string to the serial port. * * INPUT: *address Pointer to string to send (ASCIIZ) * OUTPUT: None * RETURN: None */ { while (*address != 0) // While not to the string end yet { SerialPutByte(*(address++)); // Send the byte and increment index } } // End SerialPutString(char *address)
void SerialPutString_p(const char *progmem_address) /******************************************************************************* * ABSTRACT: This function sends a null-terminated string from PROGMEM * (= flash memory) to the serial port. * * INPUT: *address Pointer to string to send (ASCIIZ) * OUTPUT: None * RETURN: None */ { register char c; while ( (c = pgm_read_byte(progmem_address++)) ) // While not to the string end yet SerialPutByte(c); } // End SerialPutString(char *address)
/*********************************************** * GPRS采集数据 ************************************************/ void ConnectGPRS(float dust,float t,float h) { // char temp[40]; /* SerialPutString("AT+CGCLASS=\"B\"\r\n"); delay(2000); SerialPutString("AT+CGDCONT=1,\"IP\",\"CMNET\"\r\n"); delay(2000); SerialPutString("AT+CGATT=1\r\n"); delay(2000); SerialPutString("AT+CIPCSGP=1,\"CMNET\"\r\n"); delay(2000); SerialPutString("AT+CIPCSGP=0\r\n"); delay(2000); SerialPutString("AT+CDNSCFG=\"211.91.216.129\"\r\n"); delay(2000); */ SerialPutString("AT+CLPORT=\"UDP\",\"3033\"\r\n");//set a port delay(2000); SerialPutString("AT+CIPSTART=\"UDP\",\"125.221.182.95\",\"8080\"\r\n");//set destination IP delay(2000); SerialPutString("AT+CIPSEND\r\n");//dial the number delay(2000); //mySerial.print("PM2.5 value:"); sprintf(sensor,"%.2f",dust);// SerialPutString(sensor); sprintf(sensor,",%.2f",t);// SerialPutString(sensor); sprintf(sensor,",%.2f",h);// SerialPutString(sensor); SerialPutByte(s4); delay(2000); SerialPutString("AT+CIPCLOSE\r\n");//dial the number delay(2000); SerialPutString("AT+CIPSHUT\r\n"); delay(2000); }