I have an app that send commands to an ESP8266 and the same program ( target targetSdkVersion 27 ) works in android 4.12 and 7.11 but fails to send in android 8
The ESP8266 is configurated as a server, I can connect to it and get an address 192.168.4.2 ( the server is at 192.168.4.1 )
When I tryed to connect I get this error
What is strange is that the address "From/179.165.88.27" is an internet address and not I internal net address.
Just happen with android 8, the old version works in android 8
The manifest is
and I ask for the permissions
The ESP8266 is configurated as a server, I can connect to it and get an address 192.168.4.2 ( the server is at 192.168.4.1 )
When I tryed to connect I get this error
Erro Conexão socket Token 192.168.4.2 - (SocketTimeoutException) java.net.SocketTimeoutException: failed to connect to /192.168.4.1 (port 80) from /179.165.88.27 (port 47238) after 5000ms
What is strange is that the address "From/179.165.88.27" is an internet address and not I internal net address.
Just happen with android 8, the old version works in android 8
B4X:
sock.Initialize("sock")
sock.Connect("192.168.4.1", 80, 5000)
' sock.Connect(EdtSend.Text, 80, 10000)
Wait For sock_Connected (Successful As Boolean)
If Successful Then
astream.InitializePrefix(sock.InputStream, False, sock.OutputStream, "astream")
' astream.Write(ser.ConvertArrayToBytes(RecordToObjects(rec)))
' astream.Write(ser.ConvertArrayToBytes( Array ("teste de envio") ))
Buffer_Rec = ""
astream.Write( bc.StringToBytes ( pMensagem, "UTF8" ) )' ( "xxGET /set/clear/998557019/9012", "UTF8") )
xFlag = True
Do While xFlag
Wait For astream_NewData (Buffer() As Byte)
xResp = bc.StringFromBytes ( Buffer, "UTF8")
If xResp = "EOL" Then
xFlag = False
Log ( "Recebidos: " & Buffer_Rec )
Else
Buffer_Rec = Buffer_Rec & xResp
End If
Loop
Set_Sv_Mensagens ( Buffer_Rec , Altura_Mensagem)
Else
Log ( "Erro Conexão socket Token " & wifi.WifiIpAddress & " - " & LastException )
Set_Sv_Mensagens ( trans.translate( "Problemas conexão SOS Token " ) , 30dip)
End If
The manifest is
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
AddPermission(android.permission.CAPTURE_AUDIO_OUTPUT)
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)
AddPermission(android.permission.RECORD_AUDIO)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
CreateResourceFromFile(Macro, Themes.LightTheme)
'#### NEW MANIFEST FIREBASE FOR B4A V8
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
'CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
'CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
CreateResourceFromFile("google-services", "google-services.json")
SetActivityAttribute(main, android:windowSoftInputMode, adjustPan|stateHidden)
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission (android.permission.ACCESS_COARSE_LOCATION)
AddPermission (android.permission.ACCESS_NETWORK_STATE)
AddPermission (android.permission.ACCESS_WIFI_STATE)
AddPermission (android.permission.CHANGE_WIFI_STATE)
AddPermission (android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddManifestText( <permission
android:name="$PACKAGE$.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
AddApplicationText(<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDectesLvKHN3wCGpKl3r-XUlXVTSgfwFE"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
)
and I ask for the permissions
B4X:
Log ( "Check permission - PERMISSION_WRITE_EXTERNAL_STORAGE")
rp.CheckAndRequest (rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow ("Fechando aplicação",True)
Activity.Finish
End If
Log ( "Check permission - PERMISSION_READ_EXTERNAL_STORAGE")
rp.CheckAndRequest (rp.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow ("Fechando aplicação",True)
Activity.Finish
End If
Log ( "Check permission - PERMISSION_RECORD_AUDIO")
rp.CheckAndRequest (rp.PERMISSION_RECORD_AUDIO)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow ("Fechando aplicação",True)
Activity.Finish
End If
Log ( "Check permission - PERMISSION_ACCESS_COARSE_LOCATION")
rp.CheckAndRequest (rp.PERMISSION_ACCESS_COARSE_LOCATION)
wait for Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow ("Fechando aplicação",True)
Activity.Finish
End If
Log ( "Check permission - PERMISSION_ACCESS_FINE_LOCATION")
rp.CheckAndRequest (rp.PERMISSION_ACCESS_FINE_LOCATION)
wait for Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow ("Fechando aplicação",True)
Activity.Finish
Else
Starter.f_Permissions = False
End If