@@ -213,7 +213,7 @@ def _handle_device_twin_update(self, msg: str, topic: str) -> None:
213
213
for property_name , value in desired .items ():
214
214
self ._callback .device_twin_desired_updated (property_name , value , desired_version )
215
215
216
- def _handle_direct_method (self , msg : str , topic : str ) -> None :
216
+ def _handle_direct_method (self , client , topic : str , msg : str ) -> None :
217
217
index = topic .find ("$rid=" )
218
218
method_id = 1
219
219
method_name = "None"
@@ -278,7 +278,8 @@ def _on_message(self, client, msg_topic, payload) -> None:
278
278
if topic .startswith ("$iothub/twin/PATCH/properties/desired/" ) or topic .startswith ("$iothub/twin/res/200/?$rid=" ):
279
279
self ._handle_device_twin_update (str (msg ), topic )
280
280
elif topic .startswith ("$iothub/methods" ):
281
- self ._handle_direct_method (str (msg ), topic )
281
+ pass
282
+ # self._handle_direct_method(str(msg), topic)
282
283
else :
283
284
if not topic .startswith ("$iothub/twin/res/" ): # not twin response
284
285
self ._logger .error ("ERROR: unknown twin! - {}" .format (msg ))
@@ -365,7 +366,9 @@ def __init__(
365
366
def _subscribe_to_core_topics (self ):
366
367
self ._mqtts .subscribe ("devices/{}/messages/events/#" .format (self ._device_id ))
367
368
self ._mqtts .subscribe ("devices/{}/messages/devicebound/#" .format (self ._device_id ))
368
- self ._mqtts .subscribe ("$iothub/methods/#" )
369
+
370
+ self ._mqtts .add_topic_callback ("$iothub/methods/#" , self ._handle_direct_method )
371
+ # self._mqtts.subscribe("$iothub/methods/#")
369
372
370
373
def _subscribe_to_twin_topics (self ):
371
374
self ._mqtts .subscribe ("$iothub/twin/PATCH/properties/desired/#" ) # twin desired property changes
0 commit comments