net/mqtt: Use the right data type

Use the appropriate data type for some variables:

- const input arguments
- int32_t instead of uint32_t for timeout
- uint8_t instead of int for variables that take just a few
  possitive values.

Change-Id: Id7d762b400fa17e6751829ac401cd7c13aabb7b2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This commit is contained in:
Flavio Santes 2016-12-15 22:30:56 -06:00 committed by Tomasz Bursztyka
commit edfaeba73d
2 changed files with 10 additions and 10 deletions

View file

@ -64,7 +64,7 @@ struct mqtt_ctx {
/** IP stack context structure */ /** IP stack context structure */
struct net_context *net_ctx; struct net_context *net_ctx;
/** Network timeout for tx and rx routines */ /** Network timeout for tx and rx routines */
uint32_t net_timeout; int32_t net_timeout;
/** Callback executed when a MQTT CONNACK msg is received and validated. /** Callback executed when a MQTT CONNACK msg is received and validated.
* If this function pointer is not used, must be set to NULL. * If this function pointer is not used, must be set to NULL.
@ -183,6 +183,9 @@ struct mqtt_ctx {
/** Data passed to the #unsubscribe callback */ /** Data passed to the #unsubscribe callback */
void *unsubscribe_data; void *unsubscribe_data;
/** Application type */
uint8_t app_type;
/* Clean session is also part of the MQTT CONNECT msg, however app /* Clean session is also part of the MQTT CONNECT msg, however app
* behavior is influenced by this parameter, so we keep a copy here * behavior is influenced by this parameter, so we keep a copy here
*/ */
@ -191,9 +194,6 @@ struct mqtt_ctx {
/** 1 if the MQTT application is connected and 0 otherwise */ /** 1 if the MQTT application is connected and 0 otherwise */
uint8_t connected:1; uint8_t connected:1;
/** Application type */
enum mqtt_app app_type;
}; };
/** /**
@ -314,8 +314,8 @@ int mqtt_tx_pingreq(struct mqtt_ctx *ctx);
* @return -ENOMEM if a tx buffer is not available * @return -ENOMEM if a tx buffer is not available
* @return -EIO on network error * @return -EIO on network error
*/ */
int mqtt_tx_subscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, int items, int mqtt_tx_subscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, uint8_t items,
const char *topics[], enum mqtt_qos qos[]); const char *topics[], const enum mqtt_qos qos[]);
/** /**
* @brief mqtt_tx_unsubscribe Sends the MQTT UNSUBSCRIBE message * @brief mqtt_tx_unsubscribe Sends the MQTT UNSUBSCRIBE message
@ -325,7 +325,7 @@ int mqtt_tx_subscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, int items,
* @param [in] topics Array of 'items' elements containing C strings * @param [in] topics Array of 'items' elements containing C strings
* @return * @return
*/ */
int mqtt_tx_unsubscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, int items, int mqtt_tx_unsubscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, uint8_t items,
const char *topics[]); const char *topics[]);
int mqtt_rx_connack(struct mqtt_ctx *ctx, struct net_buf *rx, int mqtt_rx_connack(struct mqtt_ctx *ctx, struct net_buf *rx,

View file

@ -283,8 +283,8 @@ exit_pingreq:
return rc; return rc;
} }
int mqtt_tx_subscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, int items, int mqtt_tx_subscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, uint8_t items,
const char *topics[], enum mqtt_qos qos[]) const char *topics[], const enum mqtt_qos qos[])
{ {
struct net_buf *data; struct net_buf *data;
struct net_buf *tx; struct net_buf *tx;
@ -324,7 +324,7 @@ exit_subs:
return rc; return rc;
} }
int mqtt_tx_unsubscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, int items, int mqtt_tx_unsubscribe(struct mqtt_ctx *ctx, uint16_t pkt_id, uint8_t items,
const char *topics[]) const char *topics[])
{ {
struct net_buf *data; struct net_buf *data;