self.timer_id = 0
self.start_voice_flag = 0
self.IOT_sock = None
+ self.login_statu = 0#登陆状态
self.sock_lock = _thread.allocate_lock() # 初始化锁
#对话状态,一秒检查一次
self.last_data = None # 保存上一次的数据状态
def send_unbind_dev_to_iot(self,event,msg):
self._5S_timer.start(30000,1,self._1M_timer_cb)
self._1S_timer.start(1000,1,self._1S_timer_cb)
- # self._10Stimer.start(60000,1,self._10S_timer_cb)
+ # self._10Stimer.start(50000,1,self._10S_timer_cb)
def _1M_timer_cb(self,*argc):
EventMesh.publish("heart_IOT")#开启IOT心跳包
EventMesh.publish("send_device_information")#发送设备信息
if self.IOT_sock is not None:
if self.IOT_sock.getsocketsta() != 4:
print("iot断线重连")
+ self.login_statu = 0
self.iot_close_therad()
EventMesh.publish("publish_AI_btnInfo",{"func":self.connect_iot_socket})
EventMesh.publish("login_IOT")#登录IOT
else:
- EventMesh.publish("login_IOT")#登录IOT
+ if self.login_statu == 0:
+ EventMesh.publish("login_IOT")#登录IOT
self._1scnt = 0
data = self.IOT_sock.recv(256)
if isinstance(data, bytes) and len(data)>10:
playload_data(data)
-
+ #fffe00010001xxxx
+ if isinstance(data, bytes) and len(data) == 8:#登录成功
+ target_bytes = b'\xff\xfe\x00\x01\x00\x01'
+ if data[:6] == target_bytes:
+ self.login_statu = 1#登录成功标志位修改
socket_log.info("IOT_recv = {} ,len = {}".format(self.bytes_to_hex(data),len(data)))
#检查socket是否已关闭
if self.IOT_sock == None: