File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -134,19 +134,19 @@ LoRaMacSerializerStatus_t LoRaMacSerializerData( LoRaMacMessageData_t* macMsg )
134134 + LORAMAC_FHDR_F_CTRL_FIELD_SIZE
135135 + LORAMAC_FHDR_F_CNT_FIELD_SIZE ;
136136
137- if ( macMsg -> FRMPayloadSize == 0 )
137+ computedBufSize += macMsg -> FHDR .FCtrl .Bits .FOptsLen ;
138+
139+ if ( macMsg -> FRMPayloadSize > 0 )
138140 {
139- if ( macMsg -> BufSize < computedBufSize )
140- {
141- return LORAMAC_SERIALIZER_ERROR_BUF_SIZE ;
142- }
141+ computedBufSize += LORAMAC_F_PORT_FIELD_SIZE ;
143142 }
144- else
145- { //If FRMPayload >0, FPort field is present.
146- if ( macMsg -> BufSize < computedBufSize + macMsg -> FHDR .FCtrl .Bits .FOptsLen + macMsg -> FRMPayloadSize + LORAMAC_F_PORT_FIELD_SIZE )
147- {
148- return LORAMAC_SERIALIZER_ERROR_BUF_SIZE ;
149- }
143+
144+ computedBufSize += macMsg -> FRMPayloadSize ;
145+ computedBufSize += LORAMAC_MIC_FIELD_SIZE ;
146+
147+ if ( macMsg -> BufSize < computedBufSize )
148+ {
149+ return LORAMAC_SERIALIZER_ERROR_BUF_SIZE ;
150150 }
151151
152152 macMsg -> Buffer [bufItr ++ ] = macMsg -> MHDR .Value ;
You can’t perform that action at this time.
0 commit comments