source/MQTTRegistration.c
/**
 * @brief This will validate the WLAN network connectivity
 *
 * If there is no connectivity then it will scan for the given network and try to reconnect
 *
 * @return  RETCODE_OK on success, or an error code otherwise.
 */
@brief This will validate the WLAN network connectivity
If there is no connectivity then it will scan for the given network and try to reconnect

@return  RETCODE_OK on success, or an error code otherwise.
@brief This will validate the WLAN network connectivity If there is no connectivity then it will scan for the given network and try to reconnect @return RETCODE_OK on success or an error code otherwise .
static Retcode_T MQTTRegistration_ValidateWLANConnectivity(void) {
	Retcode_T retcode = RETCODE_OK;
	WlanNetworkConnect_IpStatus_T nwStatus;
	nwStatus = WlanNetworkConnect_GetIpStatus();
	if (WLANNWCT_IPSTATUS_CT_AQRD != nwStatus) {
		AppController_SetAppStatus(APP_STATUS_ERROR);
		if (MqttSetupInfo.IsSecure == true) {
			static bool isSntpDisabled = false;
			if (false == isSntpDisabled) {
				retcode = SNTP_Disable();
			}
			if (RETCODE_OK == retcode) {
				isSntpDisabled = true;
				retcode = WLAN_Reconnect();
			} else {
				retcode = RETCODE_OK;
			}
			if (RETCODE_OK == retcode) {
				retcode = SNTP_Enable();
			}
		} else {
			retcode = WLAN_Reconnect();
		}
	}
	retcode = MQTT_IsConnected_Z();
	if (RETCODE_OK != retcode) {
		AppController_SetAppStatus(APP_STATUS_ERROR);
		connectAttemps = connectAttemps + 1;
		retcode = MQTT_ConnectToBroker_Z(&MqttConnectInfo,
		MQTT_CONNECT_TIMEOUT_IN_MS, &MqttCredentials);
		if (RETCODE_OK == retcode) {
			retcode = MQTT_SubsribeToTopic_Z(&MqttSubscribeInfo,
			MQTT_SUBSCRIBE_TIMEOUT_IN_MS);
		}
		if (RETCODE_OK != retcode) {
			LOG_AT_ERROR(
					("%s: MQTT connection to the broker failed, try again : [%hu] ... \r\n", MQTTREGISTRATION_LOGPREFIX, connectAttemps ));
			vTaskDelay(pdMS_TO_TICKS(3000));
		} else {
			connectAttemps = 0L;
		}
	}
	if (connectAttemps > 10) {
		LOG_AT_WARNING(
				("%s: Now calling SoftReset to recover\r\n", MQTTREGISTRATION_LOGPREFIX));
		vTaskDelay(pdMS_TO_TICKS(30000));
		BSP_Board_SoftReset();
	}
	return retcode;
}
static Retcode_T MQTTRegistration_ValidateWLANConnectivity ( void ) { Retcode_T retcode = RETCODE_OK ; WlanNetworkConnect_IpStatus_T nwStatus ; nwStatus = WlanNetworkConnect_GetIpStatus ( ) ; if ( WLANNWCT_IPSTATUS_CT_AQRD != nwStatus ) { AppController_SetAppStatus ( APP_STATUS_ERROR ) ; if ( MqttSetupInfo . IsSecure == true ) { static bool isSntpDisabled = false ; if ( false == isSntpDisabled ) { retcode = SNTP_Disable ( ) ; } if ( RETCODE_OK == retcode ) { isSntpDisabled = true ; retcode = WLAN_Reconnect ( ) ; } else { retcode = RETCODE_OK ; } if ( RETCODE_OK == retcode ) { retcode = SNTP_Enable ( ) ; } } else { retcode = WLAN_Reconnect ( ) ; } } retcode = MQTT_IsConnected_Z ( ) ; if ( RETCODE_OK != retcode ) { AppController_SetAppStatus ( APP_STATUS_ERROR ) ; connectAttemps = connectAttemps + 1 ; retcode = MQTT_ConnectToBroker_Z ( & MqttConnectInfo , MQTT_CONNECT_TIMEOUT_IN_MS , & MqttCredentials ) ; if ( RETCODE_OK == retcode ) { retcode = MQTT_SubsribeToTopic_Z ( & MqttSubscribeInfo , MQTT_SUBSCRIBE_TIMEOUT_IN_MS ) ; } if ( RETCODE_OK != retcode ) { LOG_AT_ERROR ( ( " \r \n " , MQTTREGISTRATION_LOGPREFIX , connectAttemps ) ) ; vTaskDelay ( pdMS_TO_TICKS ( 3000 ) ) ; } else { connectAttemps = 0L ; } } if ( connectAttemps > 10 ) { LOG_AT_WARNING ( ( " \r \n " , MQTTREGISTRATION_LOGPREFIX ) ) ; vTaskDelay ( pdMS_TO_TICKS ( 30000 ) ) ; BSP_Board_SoftReset ( ) ; } return retcode ; }
@brief This will validate the WLAN network connectivity
 If there is no connectivity then it will scan for the given network and try to reconnect
@brief This will validate the WLAN network connectivity If there is no connectivity then it will scan for the given network and try to reconnect
// reset WLAN and connect to MQTT broker // reconnecting might have failed since the connection is still active try to continue anyway /* Check for MQTT broker connection */ // increase connect attemps //reset connection counter // test if we have to reboot // wait one minute before reboot