本帖最后由 聿怀嘿嘿 于 2015-1-12 21:29 编辑 2 v" J1 g- e/ s7 A% R( u
3 A9 [; ]7 o# D+ S$ syeelink云平台是一个开放的通用物联网平台,主要提供传感器数据的接入、存储和展现服务,最重要的是对所有的软硬件爱好者是免费使用的!但yeelink SDK主要只做Arduino平台,之前自己用stm32库写了yeelink的上传程序、期间也因为不熟悉yeelink走了弯路、最后还是实现了功能,现在和大家一起共享!
) J9 U2 A! W& y; u; N% H
下面是上传gps类型的程序、输入参数是纬度、经度、速度
3 n) C8 p0 ?8 T! q5 _标红字体分别是你的设备id、传感器id和你的ApiKey,以下不再做解释哈;# g8 B# e$ E- o) }
5 T0 M0 ?: ~0 s" L8 W- int postgps (u32 lat,u32 lon,u16 speed)//7 D$ Y# P3 V, R& t/ ?
- {float lattp,lontp,speedtp,tp;- D5 c7 Y( ]0 y9 z# k; h2 |
- lattp=lat;lontp=lon;speedtp=speed;
) L7 e \: [6 x% m3 A% Y - int count=0;tp=speedtp/1000;
# g4 I7 q* d1 ?% ?% n4 T - if(tp<100&tp>=10)
# _% l% W( W% f3 Z, M - {count=72;}
; H0 Y; o2 p1 [$ W; D, S - else
' k8 [3 Z0 D) j2 k* m6 i - {if(tp<10) count=71;$ M9 a3 H, k+ I" d, A- i8 |+ k
- else count=73;
- ^5 |" S% P& w3 t3 N - }
2 z; W1 s5 v# t/ B5 h( U - sprintf((char *)postGPS,"POST /v1.0/device/<font color="#ff0000">ddddd</font>/sensor/<font color="#ff0000">xxxxx</font>/datapoints HTTP/1.1\r\n"
$ o" {2 `0 }1 U5 \2 q - "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\n"
/ C0 ?6 {3 C3 A/ u8 m3 D' m - "Host: api.yeelink.net\r\n"
# n) M" F }0 u7 Q0 K- e6 ~. I/ K/ W - "Accept: */*\r\n"
+ T' C9 J" K) s6 `) D) Q8 d% i! i - "U-ApiKey: <font color="#ff0000">xxx</font>\r\n"% p1 P3 i: q( n/ n& z8 Y4 E
- "Content-Length: %02d\r\n"
% {$ b- L3 V0 N+ h: i$ o' s b - "Content-Type: application/x-www-form-urlencoded\r\n"
9 j4 U" c/ o* m+ K - "\r\n"$ ~$ Y- b/ B$ i: h9 W g3 P
- "{"value":{"lat":%.5f,"lng":%.5f,"speed":%.3f,"offset":"yes"}}\r\n",count,lattp/=100000,lontp/=100000,speedtp/=1000);
$ U1 d& m+ r" u! i4 [: w, d - 5 K- g% c# t5 Z* n) I, v% y1 R0 J( ?
- return strlen(postGPS);
复制代码 下面是数据点类型的程序. H1 g! T( _8 A
3 f4 `) A* x+ v8 n9 e$ a w
输入参数是 你的数据。7 ^. \6 @) T, C8 ~' c ^; r( |
- int posthigh (int altitude)2 b( i7 l& L/ g. O6 L6 L% O
- {float alttp,tp;
2 Q2 b0 n. r( i! s$ d3 w - alttp=altitude;
& g0 T+ f0 m( }# c* k - int count=0;tp=alttp/10;
! Y G) K9 i7 d' g - if(tp<100&tp>=10)
3 H: F! Z' T# H( n- C+ S - {count=15;}
: p: t+ P+ M3 M! o - else
' U8 g* A8 ?) X M* i/ s - {if(tp<10) count=14;2 t- N4 ~) f, G$ V" q; S- x8 ~# \- t
- else count=16;
! t9 V4 w" @0 f: }+ v - }
: \6 @8 N6 h" h( g( |: M% b% x - sprintf((char *)postHIGH,"POST /v1.0/device/<font color="#ff0000">ddddd</font>/sensor/<font color="#ff0000">xxxxx</font>/datapoints HTTP/1.1\r\n": ]3 O8 {5 ?! ^, [2 J
- "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\n" 2 k' V/ K$ W3 \0 C
- "Host: api.yeelink.net\r\n"
' q+ x0 C3 y9 R4 x" }& p9 b - "Accept: */*\r\n"
7 }! r- d. B2 s4 n5 f8 ^" e1 [ - "U-ApiKey:<font color="#ff0000">xxx</font>\r\n"$ h% ]/ A6 ], P( @0 Z! q
- "Content-Length: %02d\r\n"5 ?5 e @0 F& o0 }1 f# t8 t
- "Content-Type: application/x-www-form-urlencoded\r\n"0 K5 O% s4 [& Q1 l9 u' ]% P
- "\r\n"6 G9 b) o- X5 z7 j! K# ^# z
- "{"value":%.2f}\r\n",count,alttp/=10);8 o0 f. K6 u/ C# b2 O' K! }; |
: q0 c) Q! M6 ?: ~- return strlen(postHIGH);
4 o* h* M+ X1 C0 W! ] - }
复制代码 下面是开关类型的数据& F: I8 G e3 q
- int postswitch(int switch0)
n; B% A" Y2 x7 [% ^3 i* X2 C - {* H! n! J) x* f9 L5 ^0 Z$ {; r
- sprintf((char *)postSWITCH0,"POST /v1.0/device/<font color="#ff0000">ddddd</font>/sensor/<font color="#ff0000">xxxxx</font>/datapoints HTTP/1.1\r\n": L& |9 u" r6 Y& e
- "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\n"
6 n# K: U9 o$ g. Y' M% t- L - "Host: api.yeelink.net\r\n"
/ y' }% B. G' t: J: G6 } - "Accept: */*\r\n"3 @: Q2 h3 t# C/ ^$ X M7 |
- "U-ApiKey: <font color="#ff0000">xxx</font>\r\n"
" W; A% W" r+ C6 T6 \: I - "Content-Length: 11\r\n"" ^: V8 b A) w
- "Content-Type: application/x-www-form-urlencoded\r\n"
- U* G; S. I- n - "\r\n"
* ^; p* T; @1 s: V W6 g! j/ p - "{"value":%01d}\r\n",switch0);1 ~" h5 A; V y
, {( G* c" P7 I6 }* L- return strlen(postSWITCH0);
- M* h7 H! _5 ~9 x, h( | - }
复制代码 很小白,大神轻喷哈!9 W( C9 ~0 d9 U7 j/ J( X/ i6 _8 S
yeelink.zip
(1.36 KB, 下载次数: 209)
|
yeelink官方已经开发了app、支持安卓和ios系统的
谢谢哈哈
我不需要他的,我希望用我自己的APP,可以的吗?
理论上可以、他的api接口是开放的、
免费使用?
嗯、对于个人是