From abf1966b95a9007db710525ed8953063f47a5c43 Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Fri, 14 Mar 2025 19:15:13 +0700 Subject: [PATCH] update --- src/communication.jl | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/communication.jl b/src/communication.jl index e6e5c59..1160915 100644 --- a/src/communication.jl +++ b/src/communication.jl @@ -533,8 +533,10 @@ end an outgoing message # Keyword Arguments - - `timeout::Integer` - time to wait for a response before error + - `timeout::Integer=60` + time in seconds to wait for a response before error + - `maxattempt::Integer=1` + maximum number of attempts to send and receive message # Return - `result::NamedTuple` @@ -562,9 +564,6 @@ julia> outgoingMsg = Dict( julia> success, error, response = GeneralUtils.sendReceiveMqttMsg(outgoingMsg) ``` -# TODO - - [] update docs - # Signature """ function sendReceiveMqttMsg(outgoingMsg::Dict{Symbol, T}; @@ -595,7 +594,6 @@ function sendReceiveMqttMsg(outgoingMsg::Dict{Symbol, T}; return response end - function sendReceiveMqttMsg(mqttInstance::mqttClientInstance_v2, receivechannel::Symbol, outgoingMsg::Dict{Symbol, T}; timeout::Integer=60, maxattempt::Integer=1 )::NamedTuple where {T<:Any} @@ -645,12 +643,20 @@ end """ Send a message to specified MQTT topic then wait for reply. # Arguments - - `outgoingMsg::Dict` - an outgoing message + - `workDict::Dict` + A dictionary containing workspace data + - `incomingMsg::Dict` + The incoming message to process + +# Keyword Arguments + - `data` + Optional data to be transferred. Default is nothing. # Return - - `result::NamedTuple` - ( success= true, error= nothing ) + - `result::Dict` + A dictionary containing either: + - Metadata about the data transfer session if initiating a new transfer + - The requested data part if responding to a data part request # Example ```jldoctest @@ -670,9 +676,7 @@ end julia> success, error = GeneralUtils.sendMqttMsg(outgoingMsg) ``` # TODO - - [x] implement crude version of this function - - [] update docs - - [] transfer multiple msg with the same mqtt connection. The transfer loop should be + - [x] transfer multiple msg with the same mqtt connection. The transfer loop should be implemented by passing mqttInstance into sendReceiveMqttMsg() so that 1-connection is used to send all data - [] partsize should be calculate from the fact that MQTT max size is 4MB (256MB theorectically) @@ -789,7 +793,6 @@ function dataTransferOverMQTT_sender(workDict::Dict, incomingMsg::Dict; data=not return d end - end """ Send a message to specified MQTT topic then wait for reply.