mcci-catena / arduino-lmic

LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
https://forum.mcci.io/c/device-software/arduino-lmic/
MIT License
629 stars 207 forks source link

Compatibility with RAK811 #59

Closed sabas1080 closed 6 years ago

sabas1080 commented 6 years ago

Hi

I am trying to make this library work with the RAK811 module, but I can not find the correct configuration, I think my problem is in the definition and use of the pins

RADIO_RF_CRX_RX PB_6 //CRF3 (ANT_SWITCH_TX_BOOST) RADIO_RF_CBT_HF PB_7 //CRF2 HF (ANT_SWITCH_TX_RFO) RADIO_RF_CTX_PA PA_4 //CRF1 PA (ANT_SWITCH_RX)

// LORA

define RADIO_RESET_PORT PB13

define RADIO_MOSI_PORT PA7

define RADIO_MISO_PORT PA6

define RADIO_SCLK_PORT PA5

define RADIO_NSS_PORT PB0

define RADIO_DIO_0_PORT PA11

define RADIO_DIO_1_PORT PB1

define RADIO_DIO_2_PORT PA3

define RADIO_DIO_3_PORT PH0

define RADIO_DIO_4_PORT PC13

//#define RADIO_DIO_5_PORT PA4

define RADIO_RF_CRX_RX PB_6 //CRF3 (ANT_SWITCH_TX_BOOST)

define RADIO_RF_CBT_HF PB_7 //CRF2 HF (ANT_SWITCH_TX_RFO)

define RADIO_RF_CTX_PA PA_4 //CRF1 PA (ANT_SWITCH_RX)

define RADIO_XTAL_EN PH_1

My Pin mapping

const lmic_pinmap lmic_pins = { .nss = RADIO_NSS_PORT, .rxtx = RADIO_RF_CRX_RX, .rst = RADIO_RESET_PORT, .dio = {RADIO_DIO_0_PORT, RADIO_DIO_1_PORT, RADIO_DIO_2_PORT}, // the RAK811 module needs D29 high for RX, low for TX. //.rxtx_rx_polarity = 1 .rxtx_rx_active = 0, // the Murata module is direct-wired, we can use 8 MHz for SPI. .spi_freq = 8000000 };

Datasheet: https://github.com/RAKWireless/WisNode-LoRa/blob/master/Doc/RAK811%20SCH.pdf

sx1276-board.c: https://github.com/RAKWireless/RAK811_BreakBoard/blob/master/src/boards/RAK811BreakBoard/sx1276-board.c

Thanks

terrillmoore commented 6 years ago

This is a big and somewhat tough problem. I'm not familiar with the RAK module. I can't tell from the schematic which STM32 is being used. See my comments on #61 about possibility (3) -- you have to be using the right BSP. Our BSP does not define PB13, etc, so I'm pretty sure you're not using ours. I'm afraid that, based on experience with timing problems with the code in stm32duino-based releases, I have no resources to help with other BSPs right now. If you want to try to add support for the RAK to our board support package, we will definitely accept a pull request.

Basic recommendations:

  1. have one or two known-good modules -- MCCI uses Adafruit LoRa M0 Feathers because the BSP is stable and we have lots of good experience. You have to add a wire, either on the board, or using a wing such as the MCCI Catena 4450.
  2. make the raw example work between them
  3. then make sure a known-good module will run the OTAA example
  4. get your new module talking to a known good using the raw example.
  5. try to get your new module to talk to the gateway using the OTAA example

Good luck! --Terry