Closed chris-gunawardena closed 5 years ago
Found a better working example here: https://github.com/mcci-catena/Catena-Arduino-Platform/blob/master/examples/catena_hello_lora/catena_hello_lora.ino
Hi @chris-gunawardena -- sorry that things were not clear. If you can suggest how to improve docs, I'm open to suggestions.
Maybe add an another example, this is what I got so far but it's still not joining. Also would be nice to add the Rx event handler here.
#include <Arduino.h>
#include <SPI.h>
#include <Arduino_LoRaWAN_ttn.h>
Arduino_LoRaWAN::SendBufferCbFn uplinkDone;
uint8_t uplinkBuffer[] = {/* port */ 0x10, 0xCA, 0xFE, 0xBA, 0xBE}; //?? not sure how to get this
class cMyLoRaWAN : public Arduino_LoRaWAN_ttn
{
public:
cMyLoRaWAN(){};
protected:
virtual bool GetOtaaProvisioningInfo(Arduino_LoRaWAN::OtaaProvisioningInfo *) override;
};
cMyLoRaWAN myLoRaWAN{};
const cMyLoRaWAN::lmic_pinmap myPinMap = {
.nss = 18,
.rxtx = cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN,
.rst = 14,
.dio = {26, 33, 32},
// .rxtx_rx_active = 0,
// .rssi_cal = 0,
// .spi_freq = 8000000,
};
void setup()
{
Serial.begin(9600);
delay(2000);
myLoRaWAN.begin(myPinMap);
if (!myLoRaWAN.IsProvisioned())
Serial.println("LoRaWAN not provisioned yet. Use the commands to set it up.\n");
else
{
// send a confirmed uplink
if (myLoRaWAN.SendBuffer(uplinkBuffer, sizeof(uplinkBuffer), uplinkDone, nullptr, true))
Serial.println("gfTxStarted!\n");
else
Serial.println("SendBuffer failed!\n");
}
}
void loop()
{
myLoRaWAN.loop();
}
// this method is called when the LMIC needs OTAA info.
// return false to indicate "no provisioning", otherwise
// fill in the data and return true.
bool cMyLoRaWAN::GetOtaaProvisioningInfo(
OtaaProvisioningInfo *pInfo)
{
if(!pInfo){
Serial.println("null pointer, create data");
OtaaProvisioningInfo info;
pInfo = &info;
static const uint8_t APPKEY[16] = {0xXX, 0xXX, 0xA5, 0x68, 0xE2, 0x9B, 0x53, 0x1A, 0x0F, 0x7B, 0x51, 0x12, 0xDC, 0x12, 0xXX, 0xXX};
static const uint8_t DEVEUI[8] = {0xXX, 0xXX, 0x6E, 0x35, 0xAF, 0xD3, 0xXX, 0xXX};
static const uint8_t APPEUI[8] = {0xXX, 0xXX, 0x00, 0xD0, 0x7E, 0xD5, 0xXX, 0xXX};
memcpy(pInfo->AppKey, APPKEY, sizeof(APPKEY));
memcpy(pInfo->DevEUI, DEVEUI, sizeof(DEVEUI));
memcpy(pInfo->AppEUI, APPEUI, sizeof(APPEUI));
}else
Serial.println("not null");
return true;
}
void uplinkDone(void *pCtx, bool fSuccess)
{
Serial.println("uplinkDone.
}
Hi Thanks for the library, this is much easier to maintain than lmic code.
I have a TTGO ESP32 lora connecting to TTN with the limc code but the same settings don't work with this lib. It compile but only prints
RXMODE_RSSI
and nothing more. The code in question below:Have I implemented all the needed methods for OTAA?