B4R Question Save and read EEPROM in Esp8266

Humberto

Active Member
Licensed User
Longtime User
I´m testing receiving some commands as a server to save configuration in the eeprom

The sertver is at address 192.168.4.1 and I setup four command
'192.168.4.1/set/mac '-> get the MAC adress
'192.168.4.1/set/redes/ssid,password '-> save the ssid and password
'192.168.4.1/set/telefones/xxxxxxxxx '-> save the celphone number
'192.168.4.1/set/eeprom '-> read the phone number and ssid and password

I set "redes" and "telefones" and call "eeprom" to read back

The first time it reads OK, but the second call it reads wrong.
If I reset the module and read again the first read is ok and the other worng.

I don´t know why.

B4X:
Sub Le_Eeprom ( pStart As UInt, pMax As UInt ) As Byte()
    Dim i, xCnt, ate As UInt
    Dim xTemp As String
    i = pStart
    xCnt = 0
    ate = i + pMax
    Do While i < ate
        xTemp =  bc.HexFromBytes (eeprom.ReadBytes ( i,1) )
Log ( xTemp)
        If xTemp <> "00" Then
            xCnt = xCnt + 1
        Else
            i = ate + 1   
        End If
        i = i + 1
    Loop
    Dim xResp() As Byte = eeprom.ReadBytes(pStart,xCnt+1)
    Log ( xCnt )
    Return xResp
End Sub
 

Attachments

  • ESPConfigureWifi.zip
    3.6 KB · Views: 353
Top