Android Question B4A +ESP_WIFI connection OK("No internet Connection")+ESP8266 (WIFI_MODE_AP , HttpServer) + Http_Request( Not Response)

ardeshir.omid

New Member
Hi Erel
my tablet sdkversion =29
your solution tested , but problem not solved.
my android connect to esp8266_ wifi that programed "esp_wifi_set_mode(WIFI_MODE_AP));"
connection Ok, with "no internet connection"
my esp_module programed as http_server
by chrome get response----> url:http://192.168.4.1
on android version low and hi,...
and ok by my_app on sdkversion 19 20

but not work these test:
1- .... WebView1.LoadUrl("http://192.168.4.1") ....
2- ... HttpJob1.Download("http://192.168.4.1") ....
3-.... Wait For (PreferWifiRouting) Complete (Success As Boolean) .... 'https://www.b4x.com/android/forum/threads/mqtt-chat-network-error.90892/post-574610
4- .... nativeMe.InitializeContext .... 'https://www.b4x.com/android/forum/threads/connect-to-wifi-without-internet.104311/post-659976

above testsno problem at sdkversion=19 , 20
but not any response at sdkversion>=21
'-----------------------------------------
1-(first)please help me for solve problem by b4a.programing
2-(other) can i simulated "internet connection OK" for android when connect to wifi_esp8266 by esp_module programatically?

excuse me for my bad English text
 

ardeshir.omid

New Member
Please don't limit your questions to a single member.

First step is to test it with airplane mode on and wifi enabled. This way you will be sure that the device doesn't switch to the cellular network.
hi
thanks

@1: First step is to test it with airplane mode on and Wifi enabled
at this test , my CheckWiFi subroutin show: "WiFi is OFF"

wificheck routin:
Private Sub CheckWiFi()
    'State - One of the following values: CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN.
    Dim p As Phone  'Phone Library
    MsgboxAsync ("sdkVer="&p.SdkVersion,"") 'for test
    If p.GetSettings ("wifi_on") <> 1 Then
        MsgboxAsync ("WiFi is OFF","") '!!!!!
    Else  'WiFi is on
        If p.GetDataState = "DISCONNECTED" Then ' Phone carrier's data network is disconnected
            MsgboxAsync ("WiFi is ON and CONNECTED","")
        Else
            MsgboxAsync ("WiFi is ON but NOT connected to a WiFi network","")
        End If
    End If
End Sub

and not response from esp_http server



'-----------------
at starter service my program report wifi changed to connected when airplane=on wifi=on

starter service check connection status:
Sub Process_Globals

Public PhoneEvent1 As PhoneEvents
Public wifi_status , mobile_data_status As String
End Sub

...

Sub Service_Create

PhoneEvent1.Initialize("PhoneEvent")

End Sub

....

Sub PhoneEvent_ConnectivityChanged(NetworkType As String, State As String, Intent As Intent)

If(NetworkType="WIFI")Then
        wifi_status=State
    End If
If(NetworkType="mobile")Then
        mobile_data_status =State
    End If
    ToastMessageShow(NetworkType & " Status Change to "&State,True)
End Sub

my starter service code show:ToastMessageShow -> "wifi Status Change to CONNECTED")

but response (=time out) from http:192.168.4.1 by httpjob
and
WebView1.LoadUrl("http://192.168.4.1")
show:
net:ERR_CLEARTEXT_NOT_PPERMITTED
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

ardeshir.omid

New Member
hi
thanks

@1: First step is to test it with airplane mode on and Wifi enabled
at this test , my CheckWiFi subroutin show: "WiFi is OFF"

wificheck routin:
Private Sub CheckWiFi()
    'State - One of the following values: CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN.
    Dim p As Phone  'Phone Library
    MsgboxAsync ("sdkVer="&p.SdkVersion,"") 'for test
    If p.GetSettings ("wifi_on") <> 1 Then
        MsgboxAsync ("WiFi is OFF","") '!!!!!
    Else  'WiFi is on
        If p.GetDataState = "DISCONNECTED" Then ' Phone carrier's data network is disconnected
            MsgboxAsync ("WiFi is ON and CONNECTED","")
        Else
            MsgboxAsync ("WiFi is ON but NOT connected to a WiFi network","")
        End If
    End If
End Sub

and not response from esp_http server



'-----------------
at starter service my program report wifi changed to connected when airplane=on wifi=on

starter service check connection status:
Sub Process_Globals

Public PhoneEvent1 As PhoneEvents
Public wifi_status , mobile_data_status As String
End Sub

...

Sub Service_Create

PhoneEvent1.Initialize("PhoneEvent")

End Sub

....

Sub PhoneEvent_ConnectivityChanged(NetworkType As String, State As String, Intent As Intent)

If(NetworkType="WIFI")Then
        wifi_status=State
    End If
If(NetworkType="mobile")Then
        mobile_data_status =State
    End If
    ToastMessageShow(NetworkType & " Status Change to "&State,True)
End Sub

my starter service code show:ToastMessageShow -> "wifi Status Change to CONNECTED")

but response (=time out) from http:192.168.4.1 by httpjob
and
WebView1.LoadUrl("http://192.168.4.1")
show:
net:ERR_CLEARTEXT_NOT_PPERMITTED
hi ,thanks
'===========================================================
with add this line to B4A :p Project->Manifest Editor & save ===>> solved my problem on tablet:
SetApplicationAttribute(android:usesCleartextTraffic, "true")

must be test on others...
'============================================================
what is difference between
#1: phone.GetSettings ("wifi_on")
and
#2: PhoneEvent_ConnectivityChanged(NetworkType As String, State As String, Intent As Intent)

when airplan=on wifi=on

#1 return ( "wifi_on"<>1) '???? when airplan=on wifi=on
#2 PhoneEvent is ok ' at all state

thanks (DonManfred & Erel)
 
Upvote 0
Top