sh123 / esp32_loraprs

LoRa ESP32 KISS Bluetooth modem (for APRSDroid or aprs.fi iOS) + APRS-IS RX/TX iGate over WiFi + Digipeater + DV (with Codec2 Walkie-Talkie)
https://github.com/sh123/esp32_loraprs
GNU General Public License v3.0
186 stars 37 forks source link

Bluetooth Passthrough Option #29

Closed karfam closed 2 years ago

karfam commented 2 years ago

Would it be possible to add bluetooth passthrough ?

For example use a bluetooth terminal application and sent a text message between android phones.

sh123 commented 2 years ago

Do you mean to exclude KISS protocol?

There is already such option cfg.EnableTextPackets/CFG_TEXT_PACKETS, https://github.com/sh123/esp32_loraprs/wiki/Protocol-and-compatibility, https://github.com/sh123/esp32_loraprs/wiki/Configuration-parameters

When enabled it will accept new line separated text messages without using KISS.

karfam commented 2 years ago

Thanks for the quick reply Sir

I have read carefully your wiki and indeed use that option but thought it was only for use with aprsdroid.

So maybe there is a slight change in the wiki like "Bluetooth Terminal Message Text : Enable this option"

I can grab some screen shots if I may be of any help.

sh123 commented 2 years ago

Added note about Bluetooth terminal applications to wiki.

karfam commented 2 years ago

Is there any debug logging?

I haven't made it work.

18:46:30.083 -> [INFO] printConfig : Current mode: NORMAL 18:46:30.083 -> [INFO] printConfig : Built with RadioLib library 18:46:30.083 -> [INFO] printConfig : Using TNC2 text mode 18:46:30.083 -> [INFO] printConfig : UsbSerialEnable: no 18:46:30.083 -> [INFO] setup : KISS extensions are disabled in TNC2 mode 18:46:30.083 -> [INFO] setupLora : Initializing LoRa 18:46:30.083 -> [INFO] setupLora : Frequency: 433775000 Hz 18:46:30.083 -> [INFO] setupLora : Bandwidth: 125000 Hz 18:46:30.083 -> [INFO] setupLora : Spreading: 12 18:46:30.083 -> [INFO] setupLora : Coding rate: 7 18:46:30.083 -> [INFO] setupLora : Power: 20 dBm 18:46:30.083 -> [INFO] setupLora : Sync: 0x34 18:46:30.083 -> [INFO] setupLora : CRC: enabled 18:46:30.083 -> [INFO] setupLora : LoRa initialized 18:46:30.083 -> [INFO] setupBt : BT init lora2 18:46:30.606 -> [INFO] setupBt : BT initialized

I connect with the module through Bluetooth terminal App, but text message doesn't seem to pass to other module. Should I see something in the serial terminal when I pass a text message through Bluetooth terminal?

sh123 commented 2 years ago

There is no logging for data transfers, do you see that modem emits on sdr? Also, terminal app must send '\n' on string completion when you hit enter.

karfam commented 2 years ago

I think there is no emit because it doesn't work even with aprsdroid kiss tnc. I will check with sdr shortly.

I tried the modules tbeam with lily go github examples (with radiolib library) and transmit/receive is working.

ISR should be enabled?

My modules are 1278.

sh123 commented 2 years ago

Strange, I tested this module with APRSDroid TNC2 mode and everything worked fine, packets were received and forwarded to APRS-IS.

karfam commented 2 years ago

20:36:56.831 -> ets Jul 29 2019 12:21:46 20:36:56.831 -> 20:36:56.831 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) 20:36:56.831 -> configsip: 0, SPIWP:0xee 20:36:56.831 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 20:36:56.878 -> mode:DIO, clock div:1 20:36:56.878 -> load:0x3fff0030,len:1100 20:36:56.878 -> ho 0 tail 12 room 4 20:36:56.878 -> load:0x40078000,len:12308 20:36:56.878 -> load:0x40080400,len:3076 20:36:56.878 -> entry 0x400805ec 20:36:57.390 -> [INFO] printConfig : Current mode: NORMAL 20:36:57.390 -> [INFO] printConfig : Built with RadioLib library 20:36:57.390 -> [INFO] printConfig : Using TNC KISS and AX.25 mode 20:36:57.390 -> [INFO] printConfig : UsbSerialEnable: no 20:36:57.390 -> [INFO] setupLora : Initializing LoRa 20:36:57.390 -> [INFO] setupLora : Frequency: 433775000 Hz 20:36:57.390 -> [INFO] setupLora : Bandwidth: 125000 Hz 20:36:57.390 -> [INFO] setupLora : Spreading: 12 20:36:57.390 -> [INFO] setupLora : Coding rate: 7 20:36:57.390 -> [INFO] setupLora : Power: 20 dBm 20:36:57.436 -> [INFO] setupLora : Sync: 0x34 20:36:57.436 -> [INFO] setupLora : CRC: enabled 20:36:57.436 -> [INFO] setupLora : LoRa initialized 20:36:57.436 -> [INFO] setupBt : BT init lora1 20:36:57.902 -> [INFO] setupBt : BT initialized

It transmits just fine with kiss tnc

Transmit

It transmits fine with bluetooth terminal and text msg enabled

When I use kiss tnc the red led on the left side of the pcb blinks when a msg is send. When I use text msg enable there is red led below gps module that blinks with 1hz. is this normal?

Also second module transmit just fine without notable drift.

BUT there is no decoding of the message from the other side. either way I send the message. I have the modules in different rooms.

karfam commented 2 years ago

I have used your git in the past with the Lora library and the same modules worked just fined with kiss tnc and aprsdroid.

I am trying now to compile with Lora library (//#define USE_RADIOLIB) but it doesn't compile.

The modules are ttgo t-beam 1.1v 1278 (433mhz)

sh123 commented 2 years ago

Not sure, try to use taskread branch with radiolib, which uses separate task to read data instead of interrupt based one, if it works then i'll merge it to master. CFG_LORA_PIN_A should be set to your IRQ pin number and this pin number should not be defined anywhere else, otherwise interrupt won't be triggered and no incoming data will be read. I never had problems with reading data. For loralib usage there was a bug just do git pull.

karfam commented 2 years ago

According to official ttgo-tbeam IRQ pin seems to be 26? Or am I missing something?

Also you mean "this pin number shouldNT be defined anywhere else" ?

irq

@update Not working with this settings

pragma message("LoRa pin definitions are not found, redefining...")

define LORA_RST 23

define LORA_IRQ 26

endif

sh123 commented 2 years ago

Which module type do you select in Arduino IDE?

karfam commented 2 years ago

Which module type do you select in Arduino IDE?

Screenshot_3

sh123 commented 2 years ago

Are you sure it uses SX1278? Comments in pins_arduio.h are saying that it is SX1276, otherwise pinouts definition seems to be correct.

karfam commented 2 years ago

I am not sure if it uses sx1278.

I am using the following Ino from lily-go(with the same module type) and receive - transmit functions work fine.

https://github.com/Xinyuan-LilyGO/LilyGo-LoRa-Series/tree/master/examples/RadioLibExamples/SX1278/SX1278_Receive

Should I change the pins from config.h lines 8-9 or thorugh pins_arduino.h inside modules folders?

sh123 commented 2 years ago

Maybe try to set CFG_LORA_PIN_B to RADIO_BUSY_PIN, which is pin 32, so it will look like that

#define CFG_LORA_PIN_SS       SS // 18
#define CFG_LORA_PIN_RST      LORA_RST // 23
#define CFG_LORA_PIN_A        LORA_IRQ  // 26
#define CFG_LORA_PIN_B        32

also use master version of RadioLib if not already using and if nothing works then try to set MODULE_NAME in module_name.h to SX1276, if does not work try to use taskread branch from this project, I'll add some additional logging so it will log packets.

karfam commented 2 years ago

define CFG_LORA_PIN_SS SS // 18

define CFG_LORA_PIN_RST LORA_RST // 23

define CFG_LORA_PIN_A LORA_IRQ // 26

define CFG_LORA_PIN_B 32

Should I put the definitions in esp32_loraprs.ino ? Is this output correct?

Screenshot_4

Still doesn't work

sh123 commented 2 years ago

All config parameters are set in config.h file, you can just replace RADIOLIB_NC with 32, I've also pushed some changes which will trace log incoming and outgoing data and config option to set log level, you need to set it to LVL_TRACE to see raw bytes transmitted and received.

I cannot help further, because I do not have this board and cannot reproduce this problem with my setup, sorry.

karfam commented 2 years ago

You are really helping very much in this problem and would like to thank you in advance.

So to sum it up

  1. I should be using taskread branch for the tests
  2. I define all the pins combinations in config.h
  3. I set log level to LVL_TRACE for raw bytes

I will try all combinations/names so it may be help in the future for guys that have tbeam 1.1v and want to use radiolib

This is the pin definition according the seller.

Screenshot_5

sh123 commented 2 years ago

Added changes so you can use master branch and set CFG_LORA_USE_ISR to false when using RadioLib, it will not read in ISR, but read on separate task in this case.

karfam commented 2 years ago

What I have tried until now without success

The pins I use are this

define CFG_LORA_PIN_SS 18

define CFG_LORA_PIN_RST 23

define CFG_LORA_PIN_A 26 // (sx127x - dio0, sx126x/sx128x - dio1)

define CFG_LORA_PIN_B 32 // (sx127x - dio1, sx126x/sx128x - busy)

LVL_TRACE should add up anything to serial when sending?

I recommend to open a different issue or change title of this one and add T-BEAM TTGO so maybe other users can report?

sh123 commented 2 years ago

I think this pull request broke it https://github.com/sh123/esp32_loraprs/pull/28, I made a fix, please pull from master

karfam commented 2 years ago

I think this pull request broke it #28, I made a fix, please pull from master

You are right. latest master fixed the issue. Decoding works fine along with Bluetooth passthrough.

Thanks for the support

// lora pinouts, CAD and ISR usage

define CFG_LORA_PIN_SS 18

define CFG_LORA_PIN_RST 23

define CFG_LORA_PIN_A 26 // (sx127x - dio0, sx126x/sx128x - dio1)

ifdef USE_RADIOLIB

define CFG_LORA_PIN_B 32 // (sx127x - dio1, sx126x/sx128x - busy)

endif

define CFG_LORA_USE_ISR true // true - read incoming data in ISR, false - do not read in ISR

define CFG_LORA_USE_CAD false // set to true to utilize carrier detection

sh123 commented 2 years ago

You are welcome.