diff --git a/include/net/mqtt.h b/include/net/mqtt.h index feae487bcce..e1ada204faf 100644 --- a/include/net/mqtt.h +++ b/include/net/mqtt.h @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -404,7 +405,7 @@ struct mqtt_transport { /** @brief MQTT internal state. */ struct mqtt_internal { /** Internal. Mutex to protect access to the client instance. */ - struct k_mutex mutex; + struct sys_mutex mutex; /** Internal. Wall clock value (in milliseconds) of the last activity * that occurred. Needed for periodic PING. diff --git a/subsys/net/lib/mqtt/mqtt_os.h b/subsys/net/lib/mqtt/mqtt_os.h index 708a9a4967d..31c84f10fc0 100644 --- a/subsys/net/lib/mqtt/mqtt_os.h +++ b/subsys/net/lib/mqtt/mqtt_os.h @@ -20,6 +20,7 @@ #include #include +#include #include @@ -41,7 +42,7 @@ extern "C" { */ static inline void mqtt_mutex_init(struct mqtt_client *client) { - k_mutex_init(&client->internal.mutex); + sys_mutex_init(&client->internal.mutex); } /**@brief Acquire lock on the module specific mutex, if any. @@ -51,14 +52,20 @@ static inline void mqtt_mutex_init(struct mqtt_client *client) */ static inline void mqtt_mutex_lock(struct mqtt_client *client) { - (void)k_mutex_lock(&client->internal.mutex, K_FOREVER); + int ret = sys_mutex_lock(&client->internal.mutex, K_FOREVER); + + __ASSERT(ret == 0, "sys_mutex_lock failed with %d", ret); + (void)ret; } /**@brief Release the lock on the module specific mutex, if any. */ static inline void mqtt_mutex_unlock(struct mqtt_client *client) { - k_mutex_unlock(&client->internal.mutex); + int ret = sys_mutex_unlock(&client->internal.mutex); + + __ASSERT(ret == 0, "sys_mutex_unlock failed with %d", ret); + (void)ret; } /**@brief Method to get the sys tick or a wall clock in millisecond resolution.