1、背景
展锐8910dm 模组固件只有MQTT功能的AT指令集,需要开发MQTTS的功能。但是在开发过程中遇到程序crash和reset问题,需要排查并解决。
2、定位分析
代码在这里开启ssl。
if (g_mqtt_ssl_enable_flag == true) {
sprintf(cUrl, "ssl://%s:%s", g_stMqttOpts.m_pcHost, g_stMqttOpts.m_pcPort);
}
else {
sprintf(cUrl, "%s:%s", g_stMqttOpts.m_pcHost, g_stMqttOpts.m_pcPort);
}
if (g_mqtt_ssl_enable_flag == true) {
MQTTAsync_SSLOptions ssl_opts = MQTTAsync_SSLOptions_initializer;
bool ret = 0;
ret = mqtts_setCrt(CG_MQTTS_CA_CRT, &mqtts_ca_cert);
if (ret == true && mqtts_ca_cert) {
mqtts_setCrt(CG_MQTTS_CLIENT_CRT, &mqtts_client_cert);
mqtts_setCrt(CG_MQTTS_CLIENT_PRIVATE_KEY, &mqtts_client_key);
}
else {
OSI_LOGI(0, "[MQTT