lpcmanager

96018843360a
Parents 5ceee8f3e4d4
Children 13b78ced7601
MQTT: do not subscribe SmartehCloud topic when using other Authentication method.
  • +8 -6
    LPCMQTT.py
  • --- a/LPCMQTT.py Tue Jan 21 09:25:40 2025 +0100
    +++ b/LPCMQTT.py Wed Jan 22 11:42:33 2025 +0100
    @@ -5,6 +5,12 @@
    orig_CTNGenerate_C = MQTTClient.CTNGenerate_C
    def CTNGenerate_C(self, buildpath, locations):
    + res = orig_CTNGenerate_C(self, buildpath, locations)
    +
    + is_SmartehCloud = self.GetParamsAttributes(u"MQTTClient.Authtype") == u"SmartehCloud"
    + if not is_SmartehCloud:
    + return res
    +
    location_str = "_".join(map(str, self.GetCurrentLocation()))
    name_str = self.BaseParams.getName()
    @@ -22,18 +28,15 @@
    LPCTopic = "/smarteh/"+common_functions.getLPCSerialFromMAC()+"/command"
    def _{location}_topic_callback(topic, payload):
    - print("got data:", payload)
    proc = Popen([os.path.join(os.path.dirname(common_functions.__file__), 'mqtt_command.sh')], stdin=PIPE)
    proc.stdin.write(payload)
    proc.stdin.close()
    def _runtime_{location}_mqtt_start():
    MQTT_subscribe("{name}", LPCTopic, _{location}_topic_callback)
    - print("mqtt register", LPCTopic)
    return
    def _runtime_{location}_mqtt_stop():
    - print("mqtt stop")
    return
    """.format(location = location_str,
    @@ -41,8 +44,7 @@
    runtimefile.close()
    - return orig_CTNGenerate_C(self, buildpath, locations) + (
    - ("runtime_%s_mqtt.py" % location_str, open(runtimefile_path, "rb")),)
    + return res + (("runtime_%s_mqtt.py" % location_str, open(runtimefile_path, "rb")),)
    MQTTClient.CTNGenerate_C = CTNGenerate_C
    @@ -58,7 +60,6 @@
    xsd_frags.insert(-1, """
    <xsd:element name="SmartehCloud"/>
    """)
    -print(xsd_frags)
    MQTTClient.XSD = "".join(xsd_frags)
    orig_GetConfig = MQTTClient.GetConfig
    @@ -72,3 +73,4 @@
    "TrustStore": "/media/data/keystore/cloud/TrustStore.pem"})
    return res
    MQTTClient.GetConfig = GetConfig
    +