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
Comando: eeprom1
280
Bytes Lidos:13
Bytes Lidos:13
Tefefonex: 5511998557019
Bytes Lidos:4
Senha: 1234
Bytes Lidos:19
Redes 1: HSP_2,tsp1138144566
Bytes Lidos:13
Redes 2: beto,cookie01
close connection
Flush enviado
Disconnected
Comando: eeprom2
280
Bytes Lidos:0
Redes 3:
Bytes Lidos:0
Redes 4:
Bytes Lidos:0
Redes 5:
close connection
Flush enviado
Disconnected

The ESP8266 Log sending from IOS

Comando: eeprom1
336
Bytes Lidos:13
Bytes Lidos:13
Tefefonex: 5511998557019
Bytes Lidos:4
Senha: 1234
Bytes Lidos:13
Redes 2: beto,cookie01
close connection
Flush enviado
Disconnected
Exception (9):
epc1=0x40238069 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000002d depc=0x00000000
ctx: sys
sp: 3ffffd30 end: 3fffffb0 offset: 01a0
>>>stack>>>
3ffffed0: 3fff3408 3fff42c4 3fff362c 40237e4f
3ffffee0: 00000001 0104a8c0 00000002 00000000
3ffffef0: 00000000 00000000 3ffee188 4023305d
3fffff00: 40210000 00000000 00000064 3fff3628
3fffff10: 3ffec97c 3fff362c 3fff42c4 40236b59
3fffff20: 3fff3304 3fff4024 3fff4024 402112ea
3fffff30: 402117de 3ffee188 3ffec95c 3fff4024
3fffff40: 3ffec96e 00000000 3fff42c4 40235f55
3fffff50: 0304a8c0 3ffec96e 3fff4024 3ffec950
3fffff60: 00000000 00000024 4020c71e 3ffee188
3fffff70: 3ffec950 3fffdcc0 3ffea838 3fff4c94
3fffff80: 4020c6ae 3ffee188 00000000 3fff40ac
3fffff90: 3fffdc90 00000000 3fff42c4 402207a3
3fffffa0: 40000f49 3fffdab0 3fffdab0 40000f49
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v10e0c112
~ld


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
Top