sim800在命令发布数据到服务器 [英] sim800 at command post data to server

查看:214
本文介绍了sim800在命令发布数据到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑将数据发送到远程服务器,我能够发送发布请求,但不确定如何添加数据然后由服务器接收.

I'm stumped with sending data to a remote server , I'm able to send a post request but not sure how to add data which is then received by the server.

我已经浏览了数据表 http://www.jarzebski.pl/datasheets/SIM900_https-121018-1.00.pdf

尝试

# usual at+sapbr=1,1 set up
+HTTPINIT
+HTTPPARA = "CID",1
+HTTPPARA="URL","IP-ADDRESS:PORT"
+httpdata=100,10000
# Where do I add the post data ?
+httpaction=1

发送http发布请求.但是我该如何添加数据-我尝试将其添加到url?key = val但没有乐趣-这里的任何帮助将不胜感激

which sends the http post request. But how do I add data - I've tried adding it to the url ?key=val but no joy - any help here will be appreciated

推荐答案

httpdata = 100,10000表示SIM800应该在10秒内期望100个字节.

httpdata=100,10000 means that SIM800 should expect 100 bytes within 10 seconds.

这是我使用HTTP客户端完成此操作的方式:

This is how I accomplished this using the HTTP client:

AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://url.com/endPoint"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPDATA=40,10000

此时,SIM800应该以"DOWNLOAD"响应.这意味着它正在期待您的数据.发送您的数据;就我而言:

At this point, the SIM800 should respond with "DOWNLOAD". Which means it's expecting your data. Send in your data; in my case:

{"location_id": 238, "fill_percent": 90}

等待10秒发送其余命令.然后:

Wait 10 seconds to send the rest of the commands. Then:

AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM

对我来说就做到了.希望对您有所帮助.

That did it for me. Hope it helps.

这是我从以下位置获得信息的地方: http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands

This is where I got the information from: http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands

在后端,使用Python Flask,这是我使用的代码

In the backend, using Python Flask, this is the code I used

@app.route('/reportTrashLevel', methods=['POST'])
def report_trash_level():
    data = request.get_json()
    database.insert_trash_level(data)

    return Response(status=200)

这篇关于sim800在命令发布数据到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆