This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC3200:企业网络重新连接问题

Guru**** 2813875 points

Other Parts Discussed in Thread: CC3200, CC3200SDK, CC3100

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1071599/cc3200-enterprise-network-re-connection-issue

部件号:CC3200
在“线程:”( CC3100)中讨论的其它部件

尊敬的团队:

下面是 我正在使用的设置详细信息:  

  1. CC3200 Wi-Fi 芯片。
  2. SDK: CC3200SDK_1.3.0
  3. Service Pack:CC3100_CC3200_ServicePack_1.0.1.15-2.14.0.0

目标:收集 能量计 数据并通过企业网络将其发布到 MQTT 服务器上。

  • RS485协议
  • WPA 企业 安全性

安全详细信息:

  • EAP 方法-> SL_ENT_EAP-METHOD_PEAP0_MSCHAPv2
  • 安全类型 -> SL_SEC_TYPE_WPA_ENT

参考示例代码:

  • 我正在使用 MQTT 客户端代码,并根据要求进行更改
  • 已为企业连接引用 ent_WLAN 示例代码

问题:重新连接到网络。 我们发现  ,WLC 和 AP 在断开连接后未收到设备的任何重新连接请求

  • 企业网络连接 成功
  • 随机间隔1至48小时后断开连接
  • 断开连接后,它不会重新连接。

请在 下面找到 NWP 日志以供参考  

链接: https://shalakacom-my.sharepoint.com/:u:/g/personal/shivaprasad_desai_shalaka_com/EVKDL6wfM-BCkhPZKjivE_0B7VkFlcQLDBD8Uiyb7Yrlig?e=0e7Tn7

请浏览以下网络日志

下面是我使用的 MQTT 客户端代码的代码片段, 我请求您  浏览并告知我是否漏掉了任何内容

//*****************************************************************************
//
//! Task implementing MQTT client communication to other web client through
//!    a broker
//!
//! \param  none
//!
//! This function
//!    1. Initializes network driver and connects to the default AP
//!    2. Initializes the mqtt library and set up MQTT connection configurations
//!    3. set up the button events and their callbacks(for publishing)
//!    4. handles the callback signals
//!
//! \return None
//!
//*****************************************************************************

void MqttClient(void *pvParameters)
{
	long lRetVal = -1;
	int iCount = 0;
	int iNumBroker = 0;
	int iConnBroker = 0;
	unsigned char policyVal;
//	signed short profile_index = 0,i16ssidLen = 0;
//	signed char i16ssid[10] ={0};
//	unsigned long ulEAP_priority;
	SlSecParamsExt_t eapParams;
//	SlGetSecParamsExt_t GetEAPParams;
	SlSecParams_t    g_SecParams;
	//	   long 			lRetVal = -1;
	unsigned char 	pValues = 0;

	//	connect_config *local_con_conf = (connect_config *)app_hndl;
	local_con_conf = (connect_config *)app_hndl;

	//	connect_to_broker:
	// Reset The state of the machine
	Network_IF_ResetMCUStateMachine();

	// Start the driver
	lRetVal = Network_IF_InitDriver(ROLE_STA);
	if(lRetVal < 0)
	{
		LOOP_FOREVER();
	}


	//Write Data to Flash
	//	WriteFileToDevice(&ulToken, &lFileHandle);

	// switch on Yellow LED to indicate Simplelink is properly up
	MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, GPIO_PIN_4);	//Yellow LED ON

	// Start Timer to blink Red LED till AP connection
	LedTimerConfigNStart();

	CLR_STATUS_BIT_ALL(g_ulStatus);

	//Start simplelink
	g_uiSimplelinkRole =  sl_Start(NULL,NULL,NULL);


	//start ent wlan connection
	eapParams.EapMethod = SL_ENT_EAP_METHOD_PEAP0_MSCHAPv2;
	eapParams.User = USER_NAME;
	eapParams.UserLen = strlen((const char *)eapParams.User);
	eapParams.AnonUserLen = 0;

	g_SecParams.Key = PASSWORD;
	g_SecParams.KeyLen = strlen((const char *)g_SecParams.Key);
	g_SecParams.Type = SL_SEC_TYPE_WPA_ENT;

	// 0 - Disable the server authnetication | 1 - Enable (this is the deafult)
	pValues = 0;
	sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, 19, 1 , &pValues);

	lRetVal = sl_WlanConnect(ENT_NAME, strlen(ENT_NAME), NULL, &g_SecParams, &eapParams);
	//	    ASSERT_ON_ERROR(lRetVal);
	if(lRetVal < 0)
	{
		UART_PRINT("Connection to an AP failed\n\r");
		LOOP_FOREVER();
	}

	//End ent wlan connection

	//waiting for the device to Auto Connect
	while ( (!IS_IP_ACQUIRED(g_ulStatus))&&
			g_ucConnectTimeout < AUTO_CONNECTION_TIMEOUT_COUNT)
	{
		//Turn RED LED On
		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, GPIO_PIN_4);	//Yellow LED ON
		osi_Sleep(50);

		//Turn RED LED Off
		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, 0);	//Yellow LED OFF
		osi_Sleep(50);

		g_ucConnectTimeout++;
	}

	lRetVal = sl_WlanProfileAdd(ENT_NAME,strlen(ENT_NAME),0,&g_SecParams,0,1,0);

	//set AUTO policy
	lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
				SL_CONNECTION_POLICY(1,0,0,0,0),
				&policyVal, 1 /*PolicyValLen*/);
//	lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0);

	/*
//	start smart config section if AP is not found
	// Start Timer to blink Yellow LED till AP connection
	LedTimerConfigNStart();
	if (g_ucConnectTimeout >= AUTO_CONNECTION_TIMEOUT_COUNT)
	{
		SetConnectionPolicy();		//set connection policy to smart config and wait for connection
	}
//	end smart config section if AP is not found
	 */

	// Disable the LED blinking Timer as Device is connected to AP
	LedTimerDeinitStop();

	//Read Data from Flash
	ReadFileFromDevice(ulToken, lFileHandle);
	if(ui32_tempGWID == gateway.ui32DeviceId )
		iSamplingRate = gateway.ui8SamplingInterval;

	// Switch ON Yellow LED to indicate that Device acquired an IP
	MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, GPIO_PIN_4);	//Yellow LED ON
	UtilsDelay(20000000);
	MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, 0);	//Yellow LED OFF

	// Register Push Button Handlers
	Button_IF_Init(pushButtonInterruptHandler2,pushButtonInterruptHandler3);
	ReconnectNow:
	if(boolRestart)
	{
		//		sl_ExtLib_MqttClientDisconnect((void*)local_con_conf[iCount].clt_ctx);
		/* Clear all stored profiles and reset the policies */
		lRetVal = sl_WlanProfileDel(0xFF);
		//		ASSERT_ON_ERROR(lRetVal);
		sl_WlanDisconnect();


		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, GPIO_PIN_4);	//Yellow LED ON
		UtilsDelay(100000);
		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, 0);	//Yellow LED OFF
		UtilsDelay(100000);
		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, GPIO_PIN_4);	//Yellow LED ON

		// Start Timer to blink Red LED till AP connection
		LedTimerConfigNStart();
		SetConnectionPolicy();
		// Disable the LED blinking Timer as Device is connected to AP
		LedTimerDeinitStop();

		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, 0);	//Yellow LED OFF
		boolRestart = false;
	}

	connect_to_broker:
	// Initialze MQTT client lib
	lRetVal = sl_ExtLib_MqttClientInit(&Mqtt_Client);
	if(lRetVal != 0)
	{
		// lib initialization failed
		LOOP_FOREVER();
	}

	/******************* connection to the broker ***************************/
	iNumBroker = sizeof(usr_connect_config)/sizeof(connect_config);
	if(iNumBroker > MAX_BROKER_CONN)
	{
		LOOP_FOREVER();
	}

	//	connect_to_broker:
	while(iCount < iNumBroker)
	{
		//create client context
		local_con_conf[iCount].clt_ctx =
				sl_ExtLib_MqttClientCtxCreate(&local_con_conf[iCount].broker_config,
						&local_con_conf[iCount].CallBAcks,
						&(local_con_conf[iCount]));

		// Set Client ID
		sl_ExtLib_MqttClientSet((void*)local_con_conf[iCount].clt_ctx,
				SL_MQTT_PARAM_CLIENT_ID,
				local_con_conf[iCount].client_id,
				strlen((char*)(local_con_conf[iCount].client_id)));

		// Set will Params
		if(local_con_conf[iCount].will_params.will_topic != NULL)
		{
			sl_ExtLib_MqttClientSet((void*)local_con_conf[iCount].clt_ctx,
					SL_MQTT_PARAM_WILL_PARAM,
					&(local_con_conf[iCount].will_params),
					sizeof(SlMqttWill_t));
		}

		// setting username and password
		if(local_con_conf[iCount].usr_name != NULL)
		{
			sl_ExtLib_MqttClientSet((void*)local_con_conf[iCount].clt_ctx,
					SL_MQTT_PARAM_USER_NAME,
					local_con_conf[iCount].usr_name,
					strlen((char*)local_con_conf[iCount].usr_name));

			if(local_con_conf[iCount].usr_pwd != NULL)
			{
				sl_ExtLib_MqttClientSet((void*)local_con_conf[iCount].clt_ctx,
						SL_MQTT_PARAM_PASS_WORD,
						local_con_conf[iCount].usr_pwd,
						strlen((char*)local_con_conf[iCount].usr_pwd));
			}
		}

		// connectin to the broker
		if((sl_ExtLib_MqttClientConnect((void*)local_con_conf[iCount].clt_ctx,
				local_con_conf[iCount].is_clean,
				local_con_conf[iCount].keep_alive_time) & 0xFF) != 0)
		{

			//delete the context for this connection
			sl_ExtLib_MqttClientCtxDelete(local_con_conf[iCount].clt_ctx);

			break;
		}
		else
		{
			local_con_conf[iCount].is_connected = true;
			iConnBroker++;
		}

		// Subscribe to topics
		if(sl_ExtLib_MqttClientSub((void*)local_con_conf[iCount].clt_ctx,
				local_con_conf[iCount].topic,
				local_con_conf[iCount].qos, TOPIC_COUNT) < 0)
		{
			sl_ExtLib_MqttClientDisconnect(local_con_conf[iCount].clt_ctx);
			local_con_conf[iCount].is_connected = false;

			//delete the context for this connection
			sl_ExtLib_MqttClientCtxDelete(local_con_conf[iCount].clt_ctx);
			iConnBroker--;
			break;
		}
		else
		{
			int iSub;
			for(iSub = 0; iSub < local_con_conf[iCount].num_topics; iSub++)
			{
			}
		}
		iCount++;
	}


	if(iConnBroker < 1)
	{
		// no succesful connection to broker
		goto end;
	}

	iCount = 0;

	CPUTimerConfigNStart();		// start the timer

	for(;;)
	{
		if(boolSamplingIntervalSetFlag)
		{
			CollectEMData();
			boolSamplingIntervalSetFlag = false;
		}

		if(boolSmartConfig)             //Conditional entry check for Force Smart Configuration
		{
			boolRestart=true;
			boolSmartConfig = false;
			goto ReconnectNow;
		}

		//Check If AP is disconnected
		if(boolBrokerDisconnected)
		{
			//Jumps to Reconnection Wait state
			goto end;
		}

		//		collect_data:
		if (bool_EMData)	//collecting data after timer interval is over
		{
			CollectEMData();
			bool_EMData = false;
		}
	}

	end:
//	lRetVal = CheckInternetConnection();
	//Wait Untill AP/Internet connection is established
	//	while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus)))
	while ( (!IS_IP_ACQUIRED(g_ulStatus))&&
			(!IS_CONNECTED(g_ulStatus)))
//	while(lRetVal < 0)
	{

//		IS_IP_ACQUIRED(g_ulStatus);
//		IS_CONNECTED(g_ulStatus);
//		lRetVal = CheckInternetConnection();

		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, GPIO_PIN_4);	//Yellow LED ON
		osi_Sleep(12000);
		MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, 0);	//Yellow LED OFF
		osi_Sleep(3000);
		cReconnectCntr++;		//Count no of attempts of reconnection
		if(boolSmartConfig)
		{
			lRetVal = 1;
			lRetVal = sl_WlanProfileDel(0xFF);
			sl_WlanDisconnect();
			boolRestart=true;
			boolSmartConfig = false;
			goto ReconnectNow;
		}

		if( cReconnectCntr > 8 )		// 1 count = 15 secs therefore 4 count = 1 mins
		{
			cReconnectCntr = 0;
//			PowerCycleDevice();	// soft resets the device - data is lost
			goto end;
		}

		/*
//		start of timer interrupt condition when in disconnection state
			if (bool_EMData) //is data to be collected?
			{
				//Jumps to Collect the data from the energy meter
//				goto collect_data;
				CollectEMData(); // collection of EM data.
				bool_EMData = false;
			}
//		End of timer interrupt condition when in disconnection state
		 */
	}

	MAP_GPIOPinWrite(GPIOA3_BASE, GPIO_PIN_4, 0);	//Yellow LED OFF
	local_con_conf->is_connected = true;
	boolBrokerDisconnected = false;
	/*
		//If AP connection is sucessfull jump to reintiate MQTT broker Connection
		PowerCycleDevice();	// soft resets the device - data is lost
	 */
	//		ResetNwp();		//restart the network processor
	goto connect_to_broker;
}

请提前感谢

正在寻找快速响应。

Shivaprasad

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Shivaprasad 您好,

    我将了解您的日志。 同时,您可能希望查看 此已解决的 E2E 线程中有关 CC3100重新连接问题的内容。

    谢谢,

    雅各布

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Shivaprasad 您好,

    对延误表示歉意。 您是否连接到安全 AP? 如果没有  ,请调用 SL_WlanProfileGet()并双击所有参数。 此外,您是否存储了多个配置文件? 如果是,请使用 SL_WlanProfileDel (0xFF)删除所有其他配置文件 ,并仅添加您的配置文件。 然后,您可以尝试重新连接。

    谢谢,
    雅各布