def register(self, topicName):
   register = MQTTSN.Registers()
   register.TopicName = topicName
   if self.__receiver:
     self.__receiver.lookfor(MQTTSN.REGACK)
   self.sock.send(register.pack())
   msg = self.waitfor(MQTTSN.REGACK, register.MsgId)
   return msg.TopicId
Example #2
0
    def register(self, topicName):
        register = MQTTSN.Registers()
        register.TopicName = topicName

        if self.__receiver:  #this uses callbacks
            self.__receiver.lookfor(MQTTSN.REGACK)
            #print("\n\nsending register ",register.pack(),"\n\n")
        self.sock.send(register.pack().encode())
        self.lookfor(MQTTSN.REGACK)
        msg = self.waitfor(MQTTSN.REGACK, register.MsgId)
        if msg:
            return msg.TopicId
        else:
            return None