Closed
Description
Hi
I'm trying to get the Lora module working inside the board RAK811,
With the LMIC library, which apparently works with STM32 Murata CMWX1ZZABZ-078
https://github.com/mcci-catena/arduino-lmic
I had to comment the line
https://github.com/mcci-catena/arduino-lmic/blob/master/src/hal/hal.cpp#L247
But now I have an error in the line
https://github.com/mcci-catena/arduino-lmic/blob/master/src/lmic/oslmic.c#L43
it seems not to start the radio
My sketch is
#include <SPI.h>
#include <lmic.h>
#include <hal/hal.h>
// LoRaWAN NwkSKey, network session key
// This is the default Semtech key, which is used by the prototype TTN
// network initially.
static const PROGMEM u1_t NWKSKEY[16] = {0x34,0x56,0x78,0x90,0x98,0x76,0x54,0x34,0x56,0x78,0x90,0x98,0x76,0x54,0x32,0x34};
// LoRaWAN AppSKey, application session key
// This is the default Semtech key, which is used by the prototype TTN
// network initially.
static const u1_t PROGMEM APPSKEY[16] = {0x56,0x78,0x90,0x98,0x76,0xFF,0xFF,0xF4,0x56,0x78,0x90,0x98,0x76,0x54,0x45,0x67};
// LoRaWAN end-device address (DevAddr)
// See http://thethingsnetwork.org/wiki/AddressSpace
static const u4_t DEVADDR = 0x23456789 ; // <-- Change this address for every node!
// These callbacks are only used in over-the-air activation, so they are
// left empty here (we cannot leave them out completely unless
// DISABLE_JOIN is set in config.h, otherwise the linker will complain).
void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }
static uint8_t mydata[] = "Hello, world!";
static osjob_t sendjob;
// Schedule TX every this many seconds (might become longer due to duty
// cycle limitations).
const unsigned TX_INTERVAL = 20;
// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = RADIO_NSS,
.rxtx = RADIO_RF_CRX_RX,
.rst = RADIO_RESET,
.dio = {RADIO_DIO_0, RADIO_DIO_1, RADIO_DIO_2},
.rxtx_rx_active = 1,
.rssi_cal = LMIC_UNUSED_PIN,
// the Murata module is direct-wired, we can use 8 MHz for SPI.
.spi_freq = 8000000
};
void onEvent (ev_t ev) {
Serial.print(os_getTime());
Serial.print(": ");
switch(ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F("EV_SCAN_TIMEOUT"));
break;
case EV_BEACON_FOUND:
Serial.println(F("EV_BEACON_FOUND"));
break;
case EV_BEACON_MISSED:
Serial.println(F("EV_BEACON_MISSED"));
break;
case EV_BEACON_TRACKED:
Serial.println(F("EV_BEACON_TRACKED"));
break;
case EV_JOINING:
Serial.println(F("EV_JOINING"));
break;
case EV_JOINED:
Serial.println(F("EV_JOINED"));
break;
case EV_RFU1:
Serial.println(F("EV_RFU1"));
break;
case EV_JOIN_FAILED:
Serial.println(F("EV_JOIN_FAILED"));
break;
case EV_REJOIN_FAILED:
Serial.println(F("EV_REJOIN_FAILED"));
break;
break;
case EV_TXCOMPLETE:
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
if(LMIC.dataLen) {
// data received in rx slot after tx
Serial.print(F("Data Received: "));
Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
Serial.println();
}
// Schedule next transmission
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
break;
case EV_LOST_TSYNC:
Serial.println(F("EV_LOST_TSYNC"));
break;
case EV_RESET:
Serial.println(F("EV_RESET"));
break;
case EV_RXCOMPLETE:
// data received in ping slot
Serial.println(F("EV_RXCOMPLETE"));
break;
case EV_LINK_DEAD:
Serial.println(F("EV_LINK_DEAD"));
break;
case EV_LINK_ALIVE:
Serial.println(F("EV_LINK_ALIVE"));
break;
default:
Serial.println(F("Unknown event"));
break;
}
}
void do_send(osjob_t* j){
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F("OP_TXRXPEND, not sending"));
} else {
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
Serial.println(F("Packet queued"));
}
// Next TX is scheduled after TX_COMPLETE event.
}
void setup() {
pinMode(LED_BUILTIN,OUTPUT);//PB_6 //CRF3
delay(200);
Serial.begin(115200);
while(!Serial);
Serial.println(F("Starting"));
digitalWrite(LED_BUILTIN,LOW);
delay(500);
digitalWrite(LED_BUILTIN,HIGH);
delay(500);
SPI.setMISO(RADIO_MISO);
SPI.setMOSI(RADIO_MOSI);
SPI.setSCLK(RADIO_SCLK);
SPI.setSSEL(RADIO_NSS);
//pinMode(RADIO_XTAL_EN,OUTPUT);
//pinMode(RADIO_RF_CBT_HF,OUTPUT); //PB_7 //CRF2 HF
//pinMode(RADIO_RF_CTX_PA,OUTPUT);//PA_4 //CRF1 PA
//digitalWrite(RADIO_XTAL_EN,HIGH);
//digitalWrite(RADIO_RF_CBT_HF,HIGH);
//digitalWrite(RADIO_RF_CTX_PA,HIGH);
// LMIC init
os_init();
Serial.println("Init");
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();
// Set static session parameters. Instead of dynamically establishing a session
// by joining the network, precomputed session parameters are be provided.
#ifdef PROGMEM
// On AVR, these values are stored in flash and only copied to RAM
// once. Copy them to a temporary buffer here, LMIC_setSession will
// copy them into a buffer of its own again.
uint8_t appskey[sizeof(APPSKEY)];
uint8_t nwkskey[sizeof(NWKSKEY)];
memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
#else
// If not running an AVR with PROGMEM, just use the arrays directly
LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
#endif
for (int channel=0; channel<72; ++channel) {
LMIC_disableChannel(channel);
}
//SF TTN
/*
LMIC_enableChannel(0);
LMIC_enableChannel(1);
LMIC_enableChannel(2); //904.3Mhz
LMIC_enableChannel(3);
LMIC_enableChannel(4);
LMIC_enableChannel(5);
LMIC_enableChannel(6);
LMIC_enableChannel(7);
LMIC_enableChannel(8);
*/
//Home
/*
LMIC_enableChannel(48);
LMIC_enableChannel(49);
LMIC_enableChannel(50);
LMIC_enableChannel(51);
LMIC_enableChannel(52);
LMIC_enableChannel(53);
LMIC_enableChannel(54);
LMIC_enableChannel(55);
LMIC_enableChannel(70);
*/
// TTN defines an additional channel at 869.525Mhz using SF9 for class B
// devices' ping slots. LMIC does not have an easy way to define set this
// frequency and support for class B is spotty and untested, so this
// frequency is not configured here.
// Disable link check validation
LMIC_setLinkCheckMode(0);
LMIC_setAdrMode(false);
// Set data rate and transmit power (note: txpow seems to be ignored by the library)
//LMIC_setDrTxpow(DR_SF7,14);
Serial.println("OK");
// Start job
do_send(&sendjob);
}
void loop() {
os_runloop_once();
}
Metadata
Metadata
Assignees
Labels
No labels