one question please,
after download the BOOTLOADER RAK3272-SiP_latest_final.hex
and execute the following sequence
AT+LINKCHECK=2
AT+DEVEUI=00xxe115051xxee4
AT+APPEUI=0000000000000099
AT+APPKEY=2aed51b839de8d830756b97d2c03e82d
AT+APPSKEY=00000000000000000000000000000012
AT+NWKSKEY=00000000000000000000000000000011
AT+DEVADDR=00000000
AT+BAND=6
AT+MASK=0002
AT+CLASS=A
AT+CFM=0
AT+TXP=14
AT+ADR=1
AT+PNM=1
AT+JOIN=1:0:10:8
I always got sucess on JOIN
but why, executing
/*
AT+LINKCHECK=2
AT+DEVEUI=0080e115051fc14c
AT+APPEUI=0000000000000099
AT+APPKEY=2b7e151628aed2a6abf7158809cf4f3c
AT+APPSKEY=00000000000000000000000000000012
AT+NWKSKEY=00000000000000000000000000000011
AT+DEVADDR=00000000
AT+BAND=6
AT+MASK=0002
AT+CLASS=A
AT+CFM=0
AT+TXP=14
AT+ADR=1
AT+PNM=1
AT+JOIN=1:0:10:8
*/
uint16_t maskBuff = 0x0002;
#define OTAA_PERIOD (10000)
/*************************************
LoRaWAN band setting:
RAK_REGION_EU433
RAK_REGION_CN470
RAK_REGION_RU864
RAK_REGION_IN865
RAK_REGION_EU868
RAK_REGION_US915
RAK_REGION_AU915
RAK_REGION_KR920
RAK_REGION_AS923
*************************************/
#define OTAA_BAND RAK_REGION_AU915
#define OTAA_DEVEUI {0x00,0xxx,0xxx,0x15,0xx,0x1f,0xc1,0x4c}
#define OTAA_APPEUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99}
#define OTAA_APPKEY {0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c}
/** Packet buffer for sending */
uint8_t collected_data[64] = { 0 };
void recvCallback(SERVICE_LORA_RECEIVE_T * data)
{
if (data->BufferSize > 0) {
Serial.println("Something received!");
for (int i = 0; i < data->BufferSize; i++) {
Serial.printf("%x", data->Buffer[i]);
}
Serial.print("\r\n");
}
}
void joinCallback(int32_t status)
{
Serial.printf("Join status: %d\r\n", status);
}
void sendCallback(int32_t status)
{
if (status == 0) {
Serial.println("Successfully sent");
} else {
Serial.println("Sending failed");
}
}
void setup()
{
Serial.begin(115200);
Serial.println("RAKwireless LoRaWan OTAA Example");
Serial.println("------------------------------------------------------");
// OTAA Device EUI MSB first
uint8_t node_device_eui[8] = OTAA_DEVEUI;
// OTAA Application EUI MSB first
uint8_t node_app_eui[8] = OTAA_APPEUI;
// OTAA Application Key MSB first
uint8_t node_app_key[16] = OTAA_APPKEY;
if (!api.lorawan.deui.set(node_device_eui, 8)) {
Serial.printf("LoRaWan OTAA - set device EUI is incorrect! \r\n");
return;
}
if (!api.lorawan.appeui.set(node_app_eui, 8)) {
Serial.printf("LoRaWan OTAA - set application EUI is incorrect! \r\n");
return;
}
if (!api.lorawan.appkey.set(node_app_key, 16)) {
Serial.printf("LoRaWan OTAA - set application key is incorrect! \r\n");
return;
}
if (!api.lorawan.band.set(OTAA_BAND)) {
Serial.printf("LoRaWan OTAA - set band is incorrect! \r\n");
return;
}
if(!api.lorawan.mask.set(&maskBuff)){
Serial.
printf("LoRaWan OTAA - set Mask channel incorrect! \r\n");
return;
}
if (!api.lorawan.deviceClass.set(RAK_LORA_CLASS_A)) {
Serial.printf("LoRaWan OTAA - set device class is incorrect! \r\n");
return;
}
if (!api.lorawan.cfm.set(0)) {
Serial.printf("LoRaWan OTAA - set confirm mode is incorrect! \r\n");
return;
}
if (!api.lorawan.txp.set(14)) {
Serial.printf("LoRaWan OTAA - set TX POWER is incorrect! \r\n");
return;
}
if (!api.lorawan.adr.set(true)) {
Serial.printf
("LoRaWan OTAA - set adaptive data rate is incorrect! \r\n");
return;
}
if (!api.lorawan.rety.set(1)) {
Serial.printf("LoRaWan OTAA - set retry times is incorrect! \r\n");
return;
}
if (!api.lorawan.pnm.set(0)) {
Serial.
printf("LoRaWan OTAA - set network join mode is incorrect! \r\n");
return;
}
if (!api.lorawan.njm.set(RAK_LORA_OTAA)) { // Set the network join mode to OTAA
Serial.
printf("LoRaWan OTAA - set network join mode is incorrect! \r\n");
return;
}
if (!api.lorawan.join()) // Join to Gateway
{
Serial.printf("LoRaWan OTAA - join fail! \r\n");
return;
}
/** Wait for Join success */
while (api.lorawan.njs.get() == 0) {
Serial.print("Wait for LoRaWAN join...");
api.lorawan.join();
delay(10000);
}
/** Check LoRaWan Status*/
Serial.printf("Duty cycle is %s\r\n", api.lorawan.dcs.get()? "ON" : "OFF"); // Check Duty Cycle status
Serial.printf("Packet is %s\r\n", api.lorawan.cfm.get()? "CONFIRMED" : "UNCONFIRMED"); // Check Confirm status
uint8_t assigned_dev_addr[4] = { 0 };
api.lorawan.daddr.get(assigned_dev_addr, 4);
Serial.printf("Device Address is %02X%02X%02X%02X\r\n", assigned_dev_addr[0], assigned_dev_addr[1], assigned_dev_addr[2], assigned_dev_addr[3]); // Check Device Address
Serial.printf("Uplink period is %ums\r\n", OTAA_PERIOD);
Serial.println("");
api.lorawan.registerRecvCallback(recvCallback);
api.lorawan.registerJoinCallback(joinCallback);
api.lorawan.registerSendCallback(sendCallback);
}
void uplink_routine()
{
/** Payload of Uplink */
uint8_t data_len = 0;
collected_data[data_len++] = (uint8_t) 't';
collected_data[data_len++] = (uint8_t) 'e';
collected_data[data_len++] = (uint8_t) 's';
collected_data[data_len++] = (uint8_t) 't';
Serial.println("Data Packet:");
for (int i = 0; i < data_len; i++) {
Serial.printf("0x%02X ", collected_data[i]);
}
Serial.println("");
if(!api.lorawan.mask.set(&maskBuff)){
Serial.
printf("LoRaWan OTAA - set Mask channel incorrect! \r\n");
return;
}
/** Send the data package */
if (api.lorawan.send(data_len, (uint8_t *) & collected_data, 2, true, 1)) {
Serial.println("Sending is requested");
} else {
Serial.println("Sending failed");
}
}
void loop()
{
static uint64_t last = 0;
static uint64_t elapsed;
if ((elapsed = millis() - last) > OTAA_PERIOD) {
uplink_routine();
last = millis();
}
//Serial.printf("Try sleep %ums..", OTAA_PERIOD);
api.system.sleep.all(OTAA_PERIOD);
//Serial.println("Wakeup..");
}
with the same parameters, i never got JOIN ?
Does the ARDUINO calls the AT commandos from BOOTLOADER, right ? That would run cool…but fails…