iOS Question COnnect IOS to Esp8266

Humberto

Active Member
Licensed User
Longtime User
I´m tryng to connect an IOS app to an ESP8266 server throuth a local IP 192.168.1.4.

I set the directives as

B4X:
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><false/>
#PlistExtra: <key>NSExceptionDomains</key><dict>
'list the excluded domains (example.com and b4x.com)
#PlistExtra: <key>192.168.4.1</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>

'end of excluded domains
#PlistExtra: </dict>
#PlistExtra: </dict>

And also I tryed

B4X:
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><false/>
#PlistExtra: <key>NSExceptionDomains</key><dict>
'list the excluded domains (example.com and b4x.com)
#PlistExtra: <key>http://192.168.4.1</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>

'end of excluded domains
#PlistExtra: </dict>
#PlistExtra: </dict>

But I still get the the error

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

How to connect ?
In Android everthing goes right
 

Humberto

Active Member
Licensed User
Longtime User
I´m geting a strange behavior.
I send a command to get the configurations from the same ESP8266 in server mode.

Sending from Android phone I get the rigth answer ( se the log )
Sending from IOS one 4S ( IOS 9.3) and Ipad ( IOS 10 ) the ESP return the first command informations without one line and second command crash

The ESP8266 log sending from Android

The ESP8266 Log sending from IOS



From IOS doesn´t return "REDE 1" information and "Comando:eeprom2"

The code that read the information in ESP8266 is bellow

B4X:
         Select cmd
             Case "eeprom1"
                    Dim xtel() As Byte = Le_Eeprom ( Main.Pos_Telefone, 20)
                    Dim xtel() As Byte = Le_Eeprom ( Main.Pos_Telefone, 20)
                    Log ( "Tefefonex: ",  xtel)
                    Dim xSenha() As Byte = Le_Eeprom ( Main.Pos_Senha, 20)
                    Log ( "Senha: ",  bc.StringFromBytes (xSenha))
                    Dim xResp1() As Byte  = Le_Eeprom ( Main.Pos_Rede1, 40)
                    Log ( "Redes 1: ",  bc.StringFromBytes (xResp1 ))
                    Dim xResp2() As Byte  = Le_Eeprom ( Main.Pos_Rede2, 40)
                    Log ( "Redes 2: ",  bc.StringFromBytes (xResp2 ))
                    Astream.Write("HTTP/1.0 200").Write(CRLF).Write(CRLF)
                    Astream.Write( "Telefone; ").Write ( xtel ).Write (CRLF)
                    Astream.Write( "Senha: ").Write ( "****" ).Write (CRLF)
                    Astream.Write ("Rede 1: ").Write( xResp1).Write (CRLF)
                    Astream.Write ("Rede 2: ").Write( xResp2).Write (CRLF)
                    Astream.Write (CRLF)
                Case "eeprom2"
                    Dim xResp3() As Byte  = Le_Eeprom ( Main.Pos_Rede3, 40)
                    Log ( "Redes 3: ",  bc.StringFromBytes (xResp3 ))
                    Dim xResp4() As Byte  = Le_Eeprom ( Main.Pos_Rede4, 40)
                    Log ( "Redes 4: ",  bc.StringFromBytes (xResp4 ))
                    Dim xResp5() As Byte  = Le_Eeprom ( Main.Pos_Rede5, 40)
                    Log ( "Redes 5: ",  bc.StringFromBytes (xResp5 ))
                    Astream.Write("HTTP/1.0 200").Write(CRLF).Write(CRLF)
                    Astream.Write ("Rede 3: ").Write( xResp3).Write (CRLF)
                    Astream.Write ("Rede 4: ").Write( xResp4).Write (CRLF)
                    Astream.Write ("Rede 5: ").Write( xResp5).Write (CRLF)
                    Astream.Write (CRLF)
            End Select
        CallSubPlus("CloseConnection", 500, 0)
    End If
End Sub

Private Sub CloseConnection(u As Byte)
    Log("close connection")
    If server.Socket.Connected Then
        Log ( "Flush enviado")
        server.Socket.Stream.Flush
        server.Socket.Close
    End If
    server.Listen
End Sub
 
Upvote 0

Humberto

Active Member
Licensed User
Longtime User
I solved changing the "#StackBufferSize".

But There stil a difference between Android and IOS request in both I send

B4X:
        Job.Initialize ( "", Me )
        xUrl = "http://192.168.4.1/set/eeprom1"
        Job.Download ( xUrl)
        Job.GetRequest.SetHeader("Content-Type", "text/html")
        Job.GetRequest.SetHeader("Connection", "close")
        Job.GetRequest.Timeout = 10000

        Wait For (Job) JobDone(Job As HttpJob)

In Android I receive

"Connection: close"

In IOS

"Connection: keep-alive"

Thanks
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…