B4R Question WIFI and BlueTooth strange problem

Gerardo Tenreiro

Active Member
Licensed User
Hello
I have this test application for an ESP32, I tested it on different models and the problem is repeated.
I want to use WIFI and BLUETOOTH simultaneously and when the number of variables defined exceeds a value, the BLUETOOTH stops working, giving strange errors in the console

To test it you can define "Private Onda1(18500) As UInt" to a value greater than 18000 and the problem appears, if it is defined to a value less than 18000 everything works correctly again

Not only for this, if more variables are defined there comes a time when the problem appears, it took me a few hours to find out what was happening since after some modifications the BLUETOOTH stopped responding so I didn't even imagine it would be a problem with the variables that increased.

Does anyone have any idea how to solve the problem?

Thank you very much

#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 2000
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src

Sub Process_Globals
Private Serial1 As Serial
Private WIFI As ESP8266WiFi
Public BC As ByteConverter
' si se aumenta el numero de variables se pierde la conexion bluetooth
Private Onda1(18500) As UInt


End Sub

Private Sub AppStart
Dim Name As String = "Core War 2.4G"
Dim Pass As String = "#39KYcTMDDLp"

Serial1.Initialize(115200)
Log("Inicia Aplicacion")

' Conecta Red WIFI
Log("conectando WIFI")
Conecta_Wifi(Name,Pass)

' iNICIALIZA EL BLUETOOTH
Log("Iniciando BLUETOOTH")
BLUETOOTH.Inicializa_Blue
End Sub
'
' Conecta la Red WIFI
Sub Conecta_Wifi(Name As String,Pass As String)
WIFI.ConnectAsync(Name,Pass,0,Null,"Estado_Wifi")
End Sub
'
' Cambio de Estado de la Conexion WIFI
Public Sub Estado_Wifi(Estado As Boolean)
Dim Ayuda As String
If Estado = True Then ' WIFI Conectada
Log ("Conectado a la Red WIFI !!!") ' Presenta Informacion
Ayuda = JoinStrings(Array As String("Mi IP es : ", WIFI.LocalIp))
Log(Ayuda) '
Else
Log ("Fallo Conexion Red WIFI") ' Presenta Informacion
End If
End Sub


Sub Process_Globals
Private Blue_T As ESP32Bluetooth ' Libreria BlueTooth
Private astream As AsyncStreams ' Comunicaciones Serie del BlueTooth

Private Cnt_BT As Long
End Sub

'
' Inicializa la Conexion BlueTooth
Public Sub Inicializa_Blue
Dim Ayuda As String
Dim Blue_Name As String = "Multi-Generador"
Log("Inicializando BlueTooth en Curso")
Log("Nombre:",Blue_Name)

If Blue_T.Connected = True Then
Blue_T.Close '
Log("Cierra Conexion")
End If
If Blue_T.Initialize(Blue_Name, "Blue_T_CambioEstado") = False Then '
Log("Fallo Iniciando BlueTooth") '
Else
astream.Initialize(Blue_T.Stream, "Blue_T_NewData", "Blue_T_Error")
Log("BlueTooth Iniciando Correctamente")
Ayuda = JoinStrings(Array As String("Nombre BlueTooth = ",Blue_Name))
Log(Ayuda)
End If
End Sub
'
' Cambio del Estado de la Conexion BlueTooth
Sub Blue_T_CambioEstado (Connected As Boolean)
If Connected = False Then
Blue_T.Close
Inicializa_Blue
End If
Log("Cambio Estado BLUETOOTH ",Connected)
End Sub
'
' Errores en la Comunicacion BlueTooth
Sub Blue_T_Error
Log("ERROR BLUETOOTH ... Blue_T_ERROR")
End Sub
'
' Telegramas de Entrada en la Comunicacion BlueTooth
Sub Blue_T_NewData (Buffer() As Byte)
Dim T() As Byte = Buffer
Dim Tt As String

Cnt_BT = Cnt_BT + 1

Tt = Main.BC.StringFromBytes(T)
Log(Cnt_BT,"->",Tt)
Envia_Blue_T(Tt)


End Sub
'
' Envia por BlueTooth
Public Sub Envia_Blue_T(Texto As String)
Dim L(4) As Byte ' Auxiliar de Longuitud
Dim Largo As Int = 0 ' Longuitud del Telegrama Enviado

Largo = Texto.Length ' Largo del Telegrama

L(1) = Largo / 256
L(0) = Largo - (L(1) * 256)
L(2) = 0
L(3) = 0

astream.Write(L) ' Cabecera de Longuitud
astream.Write(Texto.GetBytes) ' Telegrama

End Sub
 

Attachments

  • TEST WIFI Y BLUETOOTH.zip
    2.4 KB · Views: 54
Top