rabin 7 years ago
parent
commit
060e5be67a
2 changed files with 28 additions and 3 deletions
  1. 1 1
      doc/apidoc.json
  2. 27 2
      pub.py

+ 1 - 1
doc/apidoc.json

@@ -3,7 +3,7 @@
   "version": "1.0.0",
   "description": "农小盒接口文档",
   "title": "农小盒接口文档",
-  "url" : "https://api.nongxiaohe.com/v1.0.0",
+  "url" : "https://api.nongxiaohe.com",
   "template": {
   	"withCompare": true,
   	"withGenerator": true

+ 27 - 2
pub.py

@@ -9,6 +9,7 @@ from demeter.mqtt import *
 from demeter.tcp import *
 import random
 import time
+import base64
 
 def sensor():
 	# 模拟设备数据
@@ -66,6 +67,30 @@ def tcp_sensor():
 			key = hard+'/'+v+'/'+gateway+'/'+device()
 			value = val()
 			print 'key:' + key + ' value:' + value
-			client.send(key+':'+value)
+			client.send(key+'|:|'+value)
 		time.sleep(1)
-tcp_sensor()
+
+def tcp_pic():
+	gateway = '10086'
+	client = Client('0.0.0.0', 8000)
+	key = 'pic/'
+	key = 'pic/pic_'
+	gateway = '/' + gateway + '/200001'
+	with open('admin/static/images/banner.png', 'rb') as f:
+		data = f.readlines()
+		total = len(data)
+		key = key + str(total) + '_'
+		i = 0
+		#print key
+		for value in data:
+			k = key + str(i) + gateway
+			#print value
+			#print value
+			print k
+			client.send(k + '|:|' +value)
+			#print k
+			i = i+1
+	client.close()
+
+tcp_sensor()
+#tcp_pic()