#[unsafe(no_mangle)]pub unsafe extern "C" fn pamoja_lorawan_session_encode_downlink(
session: *const PamojaLorawanSession,
fcnt: u32,
fport: u8,
payload: *const u8,
payload_len: usize,
fopts: *const u8,
fopts_len: usize,
flags: PamojaLorawanFlags,
out_frame: *mut *mut PamojaBuffer,
) -> PamojaStatusExpand description
Encodes a downlink data frame, encrypting the payload and appending the MIC.
§Arguments
session- the session the frame is addressed to.fcnt- the frame counter for this downlink.fport- the port;0for MAC commands, otherwise an application port.payload- the application payload to carry.payload_len- its length.fopts- the frame options to carry in the header, at most 15 bytes.fopts_len- their length.flags- the header flags to set.out_frame- receives the encoded frame.
§Returns
PamojaStatus::Ok on success, with *out_frame set to a buffer the caller
must release with pamoja_buffer_free, or
PamojaStatus::InvalidArgument if the payload and options do not fit one
frame.
§Safety
payload and fopts must each point to at least their stated lengths in
readable bytes when those lengths are non-zero, and out_frame must point to a
writable *mut PamojaBuffer.