|
@@ -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()
|