0
fred huang

Dear All,

麻烦帮我看看附件里面的问题,程序跑到这里就一直提示连接不上WIFI。

ROM Version: 0.3

Build ToolChain Version: gcc version 4.8.3 (Realtek ASDK-4.8.3p1 Build 2003)

=========================================================
Check boot type form eFuse
SPI Initial
Image1 length: 0x3a88, Image Addr: 0x10000bc8
Image1 Validate OK, Going jump to Image1
BOOT from Flash:YES
===== Enter Image 1 ====
SDR Controller Init

load NEW fw 0
Flash Image2:Addr 0xb000, Len 282452, Load to SRAM 0x10006000
Image3 length: 0x3618c, Image3 Addr: 0x30000000
Img2 Sign: RTKWin, InfaStart @ 0x10006061
===== Enter Image 2 ====
#interface 0 is initialized
interface 1 is initialized

Initializing WIFI ...
Start LOG SERVICE MODE

#
WIFI initialized

init_thread(53), Available heap 0x548a8
fro7]m77]mqttqtt::e fReturom rn MQTTcode===
#m M QTT=============================== subscribe is 1
[308]mqtt:Wi-Fi disconnected.

[1317]mqtt:Wi-Fi disconnected.

[2325]mqtt:Wi-Fi disconnected.

[3333]mqtt:Wi-Fi disconnected.

[4341]mqtt:Wi-Fi disconnected.

[5349]mqtt:Wi-Fi disconnected.

.........

//下面是软件

static void example_amazon_awsiot_thread(void *pvParameters)
{
/* connect to MQTT_BROKER_SERVER, subscribe to a topic, send and receive messages regularly every 5 sec */
MQTTClient client;
Network network;
int rc = 0, count = 0, i;

p_wlan_init_done_callback = NULL;

MQTTPacket_connectData connectData = MQTTPacket_connectData_initializer;
char* address = MQTT_BROKER_SERVER;
char* pub_topic = publishTopic;

NetworkInit(&network);
network.rootCA = rootCABuff;
network.clientCA = certificateBuff;
network.private_key = privateKeyBuff;
network.use_ssl = 1;
MQTTClientInit(&client, &network, 30000, mqtt_sendbuf, sizeof(mqtt_sendbuf), mqtt_readbuf, sizeof(mqtt_readbuf));

connectData.MQTTVersion = 3;
connectData.clientID.cstring = MQTT_CLIENT_ID;
connectData.keepAliveInterval = 15 * 60;
mqtt_printf(MQTT_INFO, "Return code from MQTT=============================== subscribe is %d\n", 1);
reconnect(&client, address, 8883, &connectData);//出错点 备注

.

.

.

}

//下面的函数

int reconnect(MQTTClient* client, char *address, int port, MQTTPacket_connectData* connectData) {
int rc = 0;

while (1) {
do {
if (wifi_is_ready_to_transceive(RTW_STA_INTERFACE) != RTW_SUCCESS) {
mqtt_printf(MQTT_INFO, "Wi-Fi disconnected."); //一直在这里跑
break;
}
mqtt_printf(MQTT_INFO, "Wi-Fi connected.");

if (client->isconnected == 0) {

if (NetworkConnect(client->ipstack, address, port) != 0) {
break;
}
mqtt_printf(MQTT_INFO, "\"%s\" Connected", address);

if (MQTTConnect(client, connectData) != 0) {
break;
}
mqtt_printf(MQTT_INFO, "MQTT Connected");
}
} while (0);

if (client->isconnected) {
break;
}

vTaskDelay(1000);
}

return rc;

//====================

谢谢

sean 回答了