OTA流程
1--连接
2--问
3--拉
1地址是:http://ibinhub.com
uint8_t server_ip[4]={120,24,96,192}; //设云平台服务器的IP地址
uint8_t server_port=80; //设云平台服务器的端口号
2-问题 现在bin的名字和版本
#define HTTP_POST "POST /data.php HTTP1.1\r\n"\
"Host:ibinhub.com\r\n"\
"Accept:image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,*/*\r\n"\
"User-Agent: Mozilla/4.0 (compatible;MSTE 5.5;Windows 98)\r\n"\
"Content-Length:48\r\n"\
"Content-Type:application/x-www-form-urlencoded\r\n"\
"Cache-Control:no-Cache\r\n"\
"Connection:close\r\n"\
"\r\n"\
"key=e784031a6b64f0bfb48e527b6463a5b8&format=json"
把这个发给平台
/*
GET /api1/v1/image/STM32F412REapp.bin HTTP/1.1
Host: 192.168.24.158:8445
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
*/
POST /data.php HTTP1.1
Host:ibinhub.com
Accept:image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,*/*
User-Agent: Mozilla/4.0 (compatible;MSTE 5.5;Windows 98)
Content-Length:48
Content-Type:application/x-www-form-urlencoded
Cache-Control:no-Cache
Connection:close
key=e784031a6b64f0bfb48e527b6463a5b8&format=json
可以收到回答:
HTTP/1.1 200 OK
Date: Tue, 03 Sep 2019 08:48:25 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.24
X-Powered-By: PHP/5.6.24
Cache-Control: max-age=0
Expires: Tue, 03 Sep 2019 08:48:25 GMT
Content-Length: 171
Connection: close
Content-Type: text/html; charset=UTF-8
{"ver":"9.3","url":"http://www.ibinhub.com/upload/95401402.bin","len":"12020","hash":"md5","hashvalue":"5df33644ef0a8a138204bb3017c787d5","info":"楹掗簾搴ф祴璇?}
2-我已经知道路径了 去下载吧
#define HTTP_GET(bin_name) {sprintf(get_msg,"GET /upload/%s HTTP/1.1\r\n"\
"Host:ibinhub.com\r\nConnection:keep-alive\r\nUpgrade-Insecure-Requests: 1\r\n"\
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 \
(KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36\r\n"\
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8\r\n"\
"Accept-Encoding: gzip, deflate\r\n\r\n",bin_name);}
也就是发送:
GET /upload/95401402.bin HTTP/1.1
Host:ibinhub.com
Connection:keep-alive
收到
HTTP/1.1 200 OK
Date: Tue, 03 Sep 2019 08:53:05 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.24
Last-Modified: Tue, 03 Sep 2019 08:33:02 GMT
ETag: "2ef4-591a1efc67315"
Accept-Ranges: bytes
Content-Length: 12020
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/octet-stream
?鱏?F鱌?F9FF鱇?F鱄?F?麳E贠餉A??鱫??\ヱ
这样就是全部的BIN
蓝加做的 是局部的:
GET /upload/95401402.bin HTTP/1.1
Host:ibinhub.com
Connection:keep-alive
Range: bytes=0-3
做一个麒麟座的BIN