ehsan gilassi
Member
Hi.
I used LoRa library inline C. https://github.com/sandeepmistry/arduino-LoRa .
I used reading method stream from https://www.b4x.com/android/forum/threads/hardware-serial-on-esp32.97318/post-613593.
But I do not get any data.
Please help me.
Thankful.
I used LoRa library inline C. https://github.com/sandeepmistry/arduino-LoRa .
I used reading method stream from https://www.b4x.com/android/forum/threads/hardware-serial-on-esp32.97318/post-613593.
But I do not get any data.
B4X:
Sub Process_Globals
Public Serial1 As Serial
Dim LoraReader As Timer
Dim bytcon As ByteConverter
Dim Lora_Stream As Stream
End Sub
Private Sub AppStart
Serial1.Initialize(9600)
Log("AppStart")
Delay(1000)
RunNative("Lora_Stream",Null)
Delay(1000)
LoraReader.Initialize("Lora_Reader_Tick",500)
LoraReader.Enabled=True
End Sub
Sub Lora_Reader_Tick
Dim x As Int = Lora_Stream.BytesAvailable
Log(x)
If x> 0 Then
Log("size ", x)
Dim buffer(x) As Byte
Lora_Stream.ReadBytes(buffer,0,x)
Log(bytcon.StringFromBytes(buffer))
End If
End Sub
#if C
#include <SPI.h>
#include <LoRa.h>
void Lora_Stream (B4R::Object* unused) {
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
LoRa.setPins(15, 16, 4);
// if (!LoRa.begin(433E6)) {
// Serial.println("Starting LoRa failed!");
// while (1);
// }
::LoRa.begin(433E6);
b4r_main::_lora_stream->wrappedStream = &::LoRa;
LoRa.setTxPower(20);
LoRa.setSignalBandwidth(62.5E3);//41.7E3
LoRa.setSpreadingFactor(12);
LoRa.setCodingRate4(8);
Serial.println("LoRa init succeeded.");
}
#End If
Thankful.