Skip to main content

pamoja_lorawan_session_encode_uplink

Function pamoja_lorawan_session_encode_uplink 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_lorawan_session_encode_uplink( 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, ) -> PamojaStatus
Expand description

Encodes an uplink data frame, encrypting the payload and appending the MIC.

§Arguments

  • session - the activated session to send from.
  • fcnt - the frame counter for this uplink.
  • fport - the port; 0 for 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; fpending is ignored on an uplink.
  • 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.