我能够发送消息和报告属性从物联网枢纽到一个模拟设备通过蔚蓝-物联网-sdk-python。现在我想得到来自(success,expired,rejected,purjed,DeliveryCountexceeded)集线器发送到设备/模块的消息的确认IoT
ServiceClient.GetFeedbackReceiver方法可用于.Net,但我无法找到用于获取消息传递反馈的python 。
下面是用于发送c2d消息的代码
from azure.iot.hub import IoTHubRegistryManager
CONNECTION_STRING = ""
DEVICE_ID = ""
registry_manager = IoTHubRegistryManager(CONNECTION_STRING)
data = "Hello.. message from cloud"
props={}
registry_manager.send_c2d_message(DEVICE_ID, data, properties=props)当消息发送失败时,我想得到反馈。请给我一个解决办法。
提前谢谢..。:)
发布于 2022-03-08 07:10:32
ServiceClient.GetFeedbackReceiver方法可用于.Net,但我无法找到用于获取消息传递反馈的python 。
您可以尝试在receive_feedback_notification()上使用operations.py
def receive_feedback_notification(self, custom_headers=None, raw=False, **operation_config):获取云对设备消息的反馈。有关详细信息,请参阅https://learn.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging。此功能仅在标准层IoT集线器中可用。有关更多信息,请参见选择正确的IoT哈布里埃。
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation
configuration overrides<msrest:optionsforoperations>`.
:return: None
or ClientRawResponse if raw=true
:rtype: None or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`#构造URL
url = self.receive_feedback_notification.metadata"url“
如果您想测试反馈通知,请参考manager.py
https://stackoverflow.com/questions/71379244
复制相似问题