Hello everybody,
it seems it is not possible to use a type variable in another type variable.
Like this:
I can compile the code, but the ESP8266 crashes immediately. If i set the variable Settings1.WLAN.IP = "192.168.x.x".
The code is simplified here, it should be nested even more often. So that I can then write the complete settings block with the B4R serializer as a byte array into the eeprom.
and i woud like to do somthing like that:
Settings.Room.Floor.Sensor_ID = 1
I used this method instead:
It works, but i´m not happy with that.
Am I doing something wrong?
Does anyone have a better idea?
Thanks and regards
Chris
it seems it is not possible to use a type variable in another type variable.
Like this:
B4X:
Type WLAN_Type (IP As String, SSID As String, Password As String, Chanel As Byte, BSSID As String)
Type Settings(Resets As UInt, Summertime As Boolean, WLAN As WLAN_Type)
Public Settings1 As Settings
Settings1.WLAN.IP = "192.168.x.x"
The code is simplified here, it should be nested even more often. So that I can then write the complete settings block with the B4R serializer as a byte array into the eeprom.
and i woud like to do somthing like that:
Settings.Room.Floor.Sensor_ID = 1
I used this method instead:
B4X:
Sub Process_Globals
Type WLAN_Type (IP As String, SSID As String, Password As String, Chanel As Byte, BSSID As String)
Type Einstellungen (Resets As UInt, Sommerzeit As Boolean, WLAN() As Byte)
Public Settings As Einstellungen
Private WLAN1 As WLAN_Type
Settings.Resets = 0
Settings.Sommerzeit = True
WLAN1.IP = "192.168.0.170"
WLAN1.Chanel = 1
Private ser As B4RSerializator
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim obj As Object = WLAN1
Settings.WLAN = ser.ConvertArrayToBytes(obj)
Dim be(30) As Object 'Count of Objects (not Bytes) for the serializator
Dim objects() As Object = ser.ConvertBytesToArray(Settings.WLAN, be) 'Wandeln des Byte Arrays in Objecte Array
WLAN1.IP = objects(0)
End Sub
Am I doing something wrong?
Does anyone have a better idea?
Thanks and regards
Chris