Sub PhoneEvent_ConnectivityChanged(NetworkType As String, State As String, Intent As Intent)
'NetworkType - WIFI or MOBILE.
'State - One of the following values: CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN.
If State = "CONNECTED" Then
If gmap.IsInitialized Then
Tracker.GPS.Start(gmap.MyLocation.Latitude,gmap.MyLocation.Longitude)
End If
internetConnectionStatus(False,"")
Starter.internet_connected=True
Try
'Starter.mqtt.Initialize("mqtt", Starter.serverURI, Rnd(0, 999999999) & DateTime.Now)
Dim mo As MqttConnectOptions
mo.Initialize("xxx", "xxx")
Starter.mqtt.Connect2(mo)
Log("mqtt_init")
Starter.mqttConnected=True
Catch
Log("MQTT / " & LastException)
End Try
Else
internetConnectionStatus(True,"No Internet. Connect Wi-Fi or Mobile Network")
Tracker.GPS.Stop
Starter.internet_connected=False
Starter.mqttConnected=False
End If
End Sub