seeedstudio ARCH GPRS Demo. post data to yeelink.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tcp_yeelink_dfs.h Source File

tcp_yeelink_dfs.h

00001 /*
00002   IOT_MbedDfs.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_DFS_H__
00024 #define __TCP_YEELINK_DFS_H__
00025 
00026 #define HTTP_DEFAULT_PORT                   80
00027 
00028 #define HTTP_MAX_HOST_LEN                   20
00029 #define HTTP_MAX_PATH_LEN                   64
00030 #define HTTP_MAX_BUF_LEN                    100
00031 
00032 // some useful AT command
00033 #define STRCSQ          "AT+CSQ"
00034 #define STROPENGPRS     "AT+CGATT=1"
00035 #define STRSETGPRS      "AT+CGDCONT=1,\"IP\",\"CMNET\""
00036 #define STRSETAPN       "AT+CSTT=\"CMNET\",\"\",\"\""
00037 #define STRSETMODE      "AT+CIPMODE=0"
00038 #define STRSTARTTCP     "AT+CIPSTART=\"TCP\",\"42.96.164.52\",\"80\""
00039 #define STRCLOSE        "AT+CIPCLOSE"
00040 #define STRECHOFF       "ATE0"
00041 #define STRSLEEP        "AT+ESLP=1"
00042 #define STRWAKE         "AT+ESLP=0"
00043 
00044 // err code
00045 #define ERRTOUT         0
00046 #define OK              1
00047 
00048 
00049 // post data
00050 #define POST1  "POST /v1.0/device/3091/sensor/4346/datapoints HTTP/1.1"
00051 #define POST2  "Host: api.yeelink.net"
00052 #define POST3  "Connection: close"
00053 #define POST4  "Content-Length: 15"
00054 #define POST5  "Content-Type: text/plain"
00055 #define POST6  "U-ApiKey: 9270322fd7c7683cb9ad198f3464cf0d"
00056 
00057 #define POST7  "{\"value\": 100}"
00058 
00059 #define CONTENT_TYPE    " application/x-www-form-urlencoded"
00060 
00061 
00062 
00063 #endif
00064 
00065 /*********************************************************************************************************
00066   END FILE
00067 *********************************************************************************************************/