以下修改意见仅供参考,请作者根据实际意图进行修改。

packages\umqtt\src\umqtt.c(247):

error:

167: argument of type “struct umqtt_client *” is incompatible with parameter of type “int”

suggestion:

umqtt_trans_disconnect(client);
改为
umqtt_trans_disconnect((int)client);


packages\umqtt\src\umqtt.c(679):

error:

167: argument of type “struct umqtt_client *” is incompatible with parameter of type “int”

suggestion:

umqtt_trans_disconnect(client);
改为
umqtt_trans_disconnect((int)client);


packages\umqtt\src\pkgs\umqtt_pkgs_decode.c(205):

error:

513: a value of type “char” cannot be assigned to an entity of type “rt_uint8_t *”

suggestion:

报错代码为
suback_msg->ret_qos[(suback_msg->topic_count)++] = umqtt_readChar(&curdata);
umqtt_readChar返回值为char

  1. struct umqtt_pkgs_suback /* subscribe ack */
  2. {
  3. /* variable header */
  4. rt_uint16_t packet_id; /* packet id */
  5. /* payload */
  6. rt_uint8_t *ret_qos[PKG_UMQTT_SUBRECV_DEF_LENGTH]; /* return code - enum Qos - 0/1/2 */
  7. /* not payload datas */
  8. rt_uint8_t topic_count; /* topic name count */
  9. };

根据作者意图,可能需要将umqtt_pkgs_suback中
rt_uint8_t *ret_qos[PKG_UMQTT_SUBRECV_DEF_LENGTH];
改为
rt_uint8_t ret_qos[PKG_UMQTT_SUBRECV_DEF_LENGTH];

packages\umqtt\tests\umqtt_test_table.h(3):

error:

144: a value of type “char [30300]” cannot be used to initialize an entity of type “const char [3000]”

suggestion

UMQTT_BIG_MSG_NUM为3000,定义了3000个字节的数组,但是里面存放了30300个字节,导致报错。

  1. #define UMQTT_BIG_MSG_NUM 3000
  2. static const char user_big_msg[UMQTT_BIG_MSG_NUM] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \
  3. 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \
  4. ...
  5. 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \
  6. 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";

互斥量在中断中操作

error:

  1. msh />Function[rt_mutex_take] shall not be used in ISR
  2. (0) assertion failed at function:rt_mutex_take, line number:660

追踪

使用软件定时器来管理keepalive和reconnect,定时时间到执行umqtt_uplink_timer_callback,而回调中keepalive和reconnect发送时加锁调用了rt_mutex_take。即在systick中断中执行了rt_mutex_take。
栈状态如下:
image.png
或许可以改变定时的方式比如开辟一个线程?或者改变加锁方式?或者借鉴ali及ucloud采用yield的方式?

packages\umqtt\src\umqtt.c(多行):

error:

packages\umqtt\src\umqtt.c(1065): error: #29: expected an expression

追踪

报错位置调用了rt_list_for_each_entry

  1. /**
  2. * rt_list_for_each_entry - iterate over list of given type
  3. * @pos: the type * to use as a loop cursor.
  4. * @head: the head for your list.
  5. * @member: the name of the list_struct within the struct.
  6. */
  7. #define rt_list_for_each_entry(pos, head, member) \
  8. for (pos = rt_list_entry((head)->next, typeof(*pos), member); \
  9. &pos->member != (head); \
  10. pos = rt_list_entry(pos->member.next, typeof(*pos), member))

typeof() 是GUN C提供的一种特性,mdk和IAR(待确认) 并不支持typeof,至少v5是这样的。我通过在编译命令(Options for Target —> C/C++ —> Misc Controls)中添加加 —GNU 解决了这个问题。
但是需要在更大范围内解决这个问题。

需增显示转换

error:

image.png
如上几处在GNU C中是不会报错的,但是在MDK中需要显示转换(强制转换)
此外还有诸多警告信息,作者自行查看

未完待续。。。