seeedstudio ARCH GPRS Demo. post data to yeelink.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tcp_yeelink.h Source File

tcp_yeelink.h

00001 /*
00002   IOT_Mbed.h
00003   2013 Copyright (c) Seeed Technology Inc.  All right reserved.
00004 
00005   Author:Loovee
00006   2013-7-21
00007 
00008   This library is free software; you can redistribute it and/or
00009   modify it under the terms of the GNU Lesser General Public
00010   License as published by the Free Software Foundation; either
00011   version 2.1 of the License, or (at your option) any later version.
00012 
00013   This library is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016   Lesser General Public License for more details.
00017 
00018   You should have received a copy of the GNU Lesser General Public
00019   License along with this library; if not, write to the Free Software
00020   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021 */
00022 
00023 #ifndef __TCP_YEELINK_H__
00024 #define __TCP_YEELINK_H__
00025 
00026 #include "mbed.h"
00027 
00028 class IOT_Mbed{
00029 
00030     private:
00031 
00032     //Serial serial1(P0_19, P0_18);        // tx, rx
00033     private:
00034     char yeelinkPostURL[100];
00035     char yeelinkPostHeads[100];
00036 
00037     char yeelinkDns[20];
00038     char yeelinkPort[10];
00039 
00040     private:
00041 
00042     void callTest();
00043 
00044     int sendCmdAndWaitForRest(char *dta, const char *resq, int timeout);
00045     void sendCmd(char *dta);
00046     int parseURL(const char *url, char *host, int max_host_len, unsigned int *port, char *path, int max_path_len);
00047 
00048     public:
00049     int waitString(const char *str, int timeout);
00050     void init(char *postURL, char *APIKey);
00051     int checkAT(int timeout);
00052     int connectTCP();
00053     int connectTCP(char *ip, char *port);
00054     void postDtaToYeelink();
00055     int postDtaToYeelink(char *url, char *apikey, int sensorDta);
00056     int postDtaToYeelink(char *url, char *apikey, float sensorDta, int dec);
00057 
00058     int sendDtaTcp(char *dta, int timeout);
00059     bool sendToYeelink_t();
00060 
00061 
00062 };
00063 
00064 
00065 extern IOT_Mbed IOT;
00066 
00067 
00068 #endif
00069 
00070 /*********************************************************************************************************
00071   END FILE
00072 *********************************************************************************************************/