in src/adapters/pnp/PnpUtils.c [52:130]
static void IotHubConnectionStatusCallback(IOTHUB_CLIENT_CONNECTION_STATUS result, IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason, void* userContextCallback)
{
bool authenticated = false;
const char* connectionAuthentication = NULL;
switch (result)
{
case IOTHUB_CLIENT_CONNECTION_AUTHENTICATED:
connectionAuthentication = g_connectionAuthenticated;
authenticated = true;
break;
case IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED:
connectionAuthentication = g_connectionUnauthenticated;
break;
default:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: unknown %d result received", (int)result);
}
switch (reason)
{
case IOTHUB_CLIENT_CONNECTION_EXPIRED_SAS_TOKEN:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_EXPIRED_SAS_TOKEN", connectionAuthentication ? connectionAuthentication : "-");
ScheduleRefreshConnection();
break;
case IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED", connectionAuthentication ? connectionAuthentication : "-");
ScheduleRefreshConnection();
break;
case IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR", connectionAuthentication ? connectionAuthentication : "-");
ScheduleRefreshConnection();
break;
case IOTHUB_CLIENT_CONNECTION_NO_PING_RESPONSE:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_NO_PING_RESPONSE", connectionAuthentication ? connectionAuthentication : "-");
if (!authenticated)
{
g_lostNetworkConnection = true;
OsConfigLogError(GetLog(), "Lost network connection");
}
break;
case IOTHUB_CLIENT_CONNECTION_NO_NETWORK:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_NO_NETWORK", connectionAuthentication ? connectionAuthentication : "-");
if (!authenticated)
{
g_lostNetworkConnection = true;
OsConfigLogError(GetLog(), "Lost network connection");
}
break;
case IOTHUB_CLIENT_CONNECTION_DEVICE_DISABLED:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_DEVICE_DISABLED", connectionAuthentication ? connectionAuthentication : "-");
break;
case IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL", connectionAuthentication ? connectionAuthentication : "-");
break;
case IOTHUB_CLIENT_CONNECTION_OK:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, reason: IOTHUB_CLIENT_CONNECTION_OK", connectionAuthentication ? connectionAuthentication : "-");
if (g_lostNetworkConnection && authenticated)
{
g_lostNetworkConnection = false;
OsConfigLogInfo(GetLog(), "Got network connection");
ScheduleRefreshConnection();
}
break;
default:
OsConfigLogInfo(GetLog(), "IotHubConnectionStatusCallback: %s, unknown reason %d received", connectionAuthentication ? connectionAuthentication : "-", (int)reason);
}
UNUSED(userContextCallback);
}