Android Question ESP32 bleuttoth connection

fernando.oliboni

Active Member
Licensed User
Longtime User
hello i have an esp32 module with grbl. I can connect this esp32 with another app called grbl controller using bluetooth.
I would like to use B4A to:
1) show available devices
2) choose one and connect.
It is possible ?
Does anyone have an example that works?
Thanks
 

fernando.oliboni

Active Member
Licensed User
Longtime User
[QUOTE = "sfsameer, post: 836237, membro: 43084"]
Olá,

1- pode levar muito tempo porque a biblioteca acima procura qualquer dispositivo próximo, o que obviamente levaria muito tempo, então abaixo está o que você deve fazer:

Um dos requisitos do controlador GRBL é:


Portanto, primeiro emparelhe o dispositivo com seu telefone, dessa forma você forçará a biblioteca a obter os únicos dispositivos emparelhados, o que será muito mais rápido.

2- Em seguida, usando a biblioteca serial:
[CODE lang = "b4x" title = "B4A"]
Sub Process_Globals
Private Serial1 As Serial

End Sub
Sub Globais
Privado conectado como booleano
End Sub
Sub Activity_Create (FirstTime As Boolean)
Serial1.Initialize ("Serial1")
Conectar
End Sub

Sub Connect
Dim PairedDevices As Map
PairedDevices = Serial1.GetPairedDevices
Dim l como lista
l.Inicializar
Para i = 0 Para PairedDevices.Size - 1
l.Add (PairedDevices.GetKeyAt (i))
Serial1.Connect (PairedDevices.Get (l.Get (0))) '----- ele se conectará ao primeiro dispositivo par
Próximo
End Sub

Private Sub Serial1_Connected (sucesso como booleano)
Se tiver sucesso, então
Conectado = Verdadeiro
Serial1.Listen

Senão
Conectado = Falso
Fim se
End Sub

Public Sub IsBluetoothOn As Boolean
Retornar Serial1.IsEnabled
End Sub

Sub DisConnect
Serial1.Disconnect
Conectado = Falso
End Sub

[/CÓDIGO]


E no sub Serial1_Connected basta adicionar AsyncStreams e você poderá se conectar muito rápido e se comunicar em tempo real.

Obrigada,
Saif
[/ CITAR]

Vou tentar muito obrigado
 
Upvote 0

fernando.oliboni

Active Member
Licensed User
Longtime User
What if I sent you an esp32 with grbl installed?
So we can test connecting and sending Gcodes to esp32 and receiving feedback from it.
What do you think?
 
Upvote 0
Top