@@ -935,10 +935,28 @@ int publish_complete_decode(const struct mqtt_client *client, struct buf_ctx *bu
935935 }
936936#endif
937937
938- return common_ack_decode (buf , & param -> message_id , reason_code , prop );
938+ return common_pub_ack_decode (buf , & param -> message_id , reason_code , prop );
939939}
940940
941- int subscribe_ack_decode (struct buf_ctx * buf , struct mqtt_suback_param * param )
941+ #if defined(CONFIG_MQTT_VERSION_5_0 )
942+ static int suback_properties_decode (struct buf_ctx * buf ,
943+ struct mqtt_suback_param * param )
944+ {
945+ return common_ack_properties_decode (buf , & param -> prop );
946+ }
947+ #else
948+ static int suback_properties_decode (struct buf_ctx * buf ,
949+ struct mqtt_suback_param * param )
950+ {
951+ ARG_UNUSED (param );
952+ ARG_UNUSED (buf );
953+
954+ return - ENOTSUP ;
955+ }
956+ #endif /* CONFIG_MQTT_VERSION_5_0 */
957+
958+ int subscribe_ack_decode (const struct mqtt_client * client , struct buf_ctx * buf ,
959+ struct mqtt_suback_param * param )
942960{
943961 int err_code ;
944962
@@ -947,11 +965,53 @@ int subscribe_ack_decode(struct buf_ctx *buf, struct mqtt_suback_param *param)
947965 return err_code ;
948966 }
949967
968+ if (mqtt_is_version_5_0 (client )) {
969+ err_code = suback_properties_decode (buf , param );
970+ if (err_code < 0 ) {
971+ return err_code ;
972+ }
973+ }
974+
950975 return unpack_raw_data (buf -> end - buf -> cur , buf , & param -> return_codes );
951976}
952977
953- int unsubscribe_ack_decode (struct buf_ctx * buf ,
978+ #if defined(CONFIG_MQTT_VERSION_5_0 )
979+ static int unsuback_5_0_decode (struct buf_ctx * buf ,
980+ struct mqtt_unsuback_param * param )
981+ {
982+ int err ;
983+
984+ err = common_ack_properties_decode (buf , & param -> prop );
985+ if (err < 0 ) {
986+ return err ;
987+ }
988+
989+ return unpack_raw_data (buf -> end - buf -> cur , buf , & param -> reason_codes );
990+ }
991+ #else
992+ static int unsuback_5_0_decode (struct buf_ctx * buf ,
993+ struct mqtt_unsuback_param * param )
994+ {
995+ ARG_UNUSED (param );
996+ ARG_UNUSED (buf );
997+
998+ return - ENOTSUP ;
999+ }
1000+ #endif /* CONFIG_MQTT_VERSION_5_0 */
1001+
1002+ int unsubscribe_ack_decode (const struct mqtt_client * client , struct buf_ctx * buf ,
9541003 struct mqtt_unsuback_param * param )
9551004{
956- return unpack_uint16 (buf , & param -> message_id );
1005+ int err ;
1006+
1007+ err = unpack_uint16 (buf , & param -> message_id );
1008+ if (err < 0 ) {
1009+ return 0 ;
1010+ }
1011+
1012+ if (mqtt_is_version_5_0 (client )) {
1013+ return unsuback_5_0_decode (buf , param );
1014+ }
1015+
1016+ return 0 ;
9571017}
0 commit comments