- Conexion funcando pendite de prueba total

parent 754f3408
Showing with 11 additions and 19 deletions
......@@ -83,8 +83,8 @@ class Conexion:
print("Desconectado")
def desubscribir(self,topic):
self.client.unsubscribe(topic)
#print(f"Desubscrito topic : {topic}")
#self.client.unsubscribe(topic)
print("Desubscrito topic : ",topic)
def checkMensages(self):
self.client.check_msg()
......
......@@ -6,31 +6,22 @@ from umqtt.robust import MQTTClient
import conexion as cn
"""
def sub_cp(topic, msg):
print("Recibido topic", topic.decode(), " mensage ", msg.decode())
subs = ["A3-467/GrupoL/Robot","A3-467/GrupoL/SincRobot"]
send = ["A3-467/GrupoL/Interfaz","A3-467/GrupoL/SincInterfaz"]
#cx = cn.Conexion(subs,on_msg=sub_cp)
#cx.publicar(send[0],"BBBBBBBBBB")
cx = cn.Conexion(subs,sub_cp)
print("Creado")
while True:
cx.checkMensages()
"""
import mensajeRobot as m
mR = m.MensajeRobot()
print("Creado")
print("creada conexion")
mapa = mR.getMapa()
print(mapa)
pos = (4,4)
mR.sendPosicion(pos)
"""
"""
robot = Robot()
......@@ -43,4 +34,3 @@ robot.recorreRuta(mov,cas)
robot.recogePaquete()
"""
\ No newline at end of file
......@@ -11,12 +11,12 @@ class MensajeRobot:
print("Inicizlizando")
def sub_cp(topic,msg):
print("Recibido topic", topic, " mensage ", msg)
if(topic == self.topicSubs[-2]):
def sub_cp(topic, msg):
print("Recibido topic", topic.decode(), " mensage ", msg.decode())
if(topic.decode() == self.topicSubs[-1]):
self.sinc = True
else:
self.mensaje = str(msg.decode('utf-8'))
self.mensaje = str(msg.decode())
def on_message_default(client,userdata,message):
......@@ -66,6 +66,7 @@ class MensajeRobot:
def __sincronizacion(self):
while(not self.sinc):
self.conex.checkMensages()
self.conex.publicar(self.topicSend[-1],self.prefMsg['sinc'])
time.sleep(2)
print("SINCRONIZADO")
......@@ -78,6 +79,7 @@ class MensajeRobot:
while(self.mensaje.split(self.sepMsg)[0] != self.prefMsg['mapa']):
self.conex.checkMensages()
time.sleep(2)
return self.mensaje.split(self.sepMsg)[1]
......@@ -87,6 +89,7 @@ class MensajeRobot:
self.conex.publicar(self.topicSend[0],self.prefMsg['pedido'] + self.sepMsg)
while(self.mensaje.split(self.sepMsg)[0] != self.prefMsg['pedido']):
self.conex.checkMensages()
#print(f"Esperando Pedido - {self.mensaje.split(self.sepMsg)[0],self.prefMsg['pedido']}")
time.sleep(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment