本帖最后由 聿怀嘿嘿 于 2015-1-12 21:29 编辑 $ {5 M1 q$ c+ I; M, W/ g* X
% [/ O; y. s6 Q _: g) |yeelink云平台是一个开放的通用物联网平台,主要提供传感器数据的接入、存储和展现服务,最重要的是对所有的软硬件爱好者是免费使用的!但yeelink SDK主要只做Arduino平台,之前自己用stm32库写了yeelink的上传程序、期间也因为不熟悉yeelink走了弯路、最后还是实现了功能,现在和大家一起共享!
0 ^; |7 f! q" g6 s5 R t3 h0 T
下面是上传gps类型的程序、输入参数是纬度、经度、速度5 C: y+ O4 P4 q' ~$ j* d2 {
标红字体分别是你的设备id、传感器id和你的ApiKey,以下不再做解释哈;% z8 a- w& `/ L" U" |
7 U ?6 o4 E+ P$ z3 ` d$ ~
- int postgps (u32 lat,u32 lon,u16 speed)//! |6 W. a# S$ M! B6 F, a* d4 i
- {float lattp,lontp,speedtp,tp;
6 {. Q/ S' Z* G; X: V- T - lattp=lat;lontp=lon;speedtp=speed;) @1 Y& E1 K7 W/ z, b
- int count=0;tp=speedtp/1000;- s4 H' E7 A4 |, j5 \0 m
- if(tp<100&tp>=10) : D+ N* f8 D! p' k
- {count=72;}
1 I& `( m: a. R, e' D- V1 [ - else
9 s0 `( K" _9 ]" t, }& y - {if(tp<10) count=71;' E2 i4 q9 L( T% N. \) a) f7 X4 a
- else count=73;$ }5 E: e+ e0 T& G8 O2 b
- }
; @: w; m5 z: {2 e) i% F! a0 u4 P" ^+ c - sprintf((char *)postGPS,"POST /v1.0/device/<font color="#ff0000">ddddd</font>/sensor/<font color="#ff0000">xxxxx</font>/datapoints HTTP/1.1\r\n"
$ J, X/ l- W0 C3 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" 9 h& q; F; T0 J
- "Host: api.yeelink.net\r\n"
3 B1 A: t9 {9 Z9 t9 v - "Accept: */*\r\n". Q4 S& A s( d
- "U-ApiKey: <font color="#ff0000">xxx</font>\r\n"
9 v( _6 b" U4 E1 c. w - "Content-Length: %02d\r\n"- d& {5 T+ k# e3 @4 _% I' R. R
- "Content-Type: application/x-www-form-urlencoded\r\n"+ {) ^3 H# S: D9 e9 e
- "\r\n"3 X# }; r" @/ g7 k8 i Q/ X
- "{"value":{"lat":%.5f,"lng":%.5f,"speed":%.3f,"offset":"yes"}}\r\n",count,lattp/=100000,lontp/=100000,speedtp/=1000);
]* H% T9 K9 s. J& D. r - / i8 B$ Q: M+ i; c7 E2 z
- return strlen(postGPS);
复制代码 下面是数据点类型的程序
! }- @) ] R+ ^2 ]7 y+ R5 G
9 S/ G- H9 f. ]( Y/ v: U输入参数是 你的数据。
* G; U9 u, [4 Q# a2 R7 W U- int posthigh (int altitude)
& m1 h+ [6 Y% r& g3 \- W - {float alttp,tp;3 h$ G# y6 e9 c* M. e+ D( \
- alttp=altitude;/ w4 I$ E1 i3 u- x$ U1 c( a
- int count=0;tp=alttp/10;
, m8 t9 n2 a3 c c - if(tp<100&tp>=10) $ m7 ?1 C* L% }
- {count=15;}
' X6 R- [3 l3 d - else " ?# _: X9 g6 U( T* y' O7 q6 ]' h
- {if(tp<10) count=14;
, A( [2 j' \) w6 X, i - else count=16;
. C1 L8 c. X0 w - }
, y' u" `( t! ^ - sprintf((char *)postHIGH,"POST /v1.0/device/<font color="#ff0000">ddddd</font>/sensor/<font color="#ff0000">xxxxx</font>/datapoints HTTP/1.1\r\n"
& Z2 s/ C% i* J# g6 v' U - "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\n"
* W* J! P) s3 I. J) T - "Host: api.yeelink.net\r\n"2 _+ C+ e+ H* C j
- "Accept: */*\r\n"
8 R% w) \, u9 O, ] - "U-ApiKey:<font color="#ff0000">xxx</font>\r\n"
/ L( f6 `& L k8 h, Y: X, E* r! b. h - "Content-Length: %02d\r\n"2 l8 s- B' V# I% I$ i
- "Content-Type: application/x-www-form-urlencoded\r\n"( S. F7 D3 p! D1 r; G: O$ I
- "\r\n"
* n3 E0 W8 |7 m1 V$ ^ - "{"value":%.2f}\r\n",count,alttp/=10);7 S( g$ c h% s: N
* c* g o3 B0 u9 L- return strlen(postHIGH);
% w( o. r( P' ]% Z - }
复制代码 下面是开关类型的数据
7 L) U2 G5 Q$ U( T8 z2 l, G- int postswitch(int switch0)2 S; A% Y$ k% [ z$ N, K
- {+ K. v; T: p" W& F4 B
- sprintf((char *)postSWITCH0,"POST /v1.0/device/<font color="#ff0000">ddddd</font>/sensor/<font color="#ff0000">xxxxx</font>/datapoints HTTP/1.1\r\n"9 c- y' r2 X# q+ B. p
- "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\n"
7 V9 Y% @0 q! H9 N, G7 o - "Host: api.yeelink.net\r\n"
/ }- {3 _# d% M1 s7 h+ \% F! E) N - "Accept: */*\r\n"3 i8 c% B/ U4 v- e2 E: c- `
- "U-ApiKey: <font color="#ff0000">xxx</font>\r\n"+ ]% V. H3 |* A+ P; x. W
- "Content-Length: 11\r\n"& S0 S" R8 M3 A1 Z7 g" |& t
- "Content-Type: application/x-www-form-urlencoded\r\n"1 q; k. |8 y4 i1 I1 [4 d0 m
- "\r\n": I, `( m- o9 j c6 }
- "{"value":%01d}\r\n",switch0);! i0 B9 T& U( {3 d1 o
) b U( e( b6 y- M0 e7 l- return strlen(postSWITCH0);# b: Q; N0 N! ^+ G3 ~
- }
复制代码 很小白,大神轻喷哈!! \# g! o' h; y M x: v7 e7 x) D* f9 {
yeelink.zip
(1.36 KB, 下载次数: 209)
|
yeelink官方已经开发了app、支持安卓和ios系统的
谢谢哈哈
我不需要他的,我希望用我自己的APP,可以的吗?
理论上可以、他的api接口是开放的、
免费使用?
嗯、对于个人是