Buenos días,
Me han surgido unos problemas con la placa multiprotocol y su conectividad y me gustaría que me ayudaran. A continuación detallo mi problema:
El principal problema es que no consigo configurar el módulo de LoRaWAN con el código de ejemplo ligeramente modificado (simplemente hay Serial.print para debug), adjunto.
Code:
/*
* ------ LoRaWAN Code Example --------
*
* Explanation: This example shows how to configure the module
* and all general settings related to back-end registration
* process.
*
* Copyright (C) 2015 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 1.3
* Design: David Gascon
* Implementation: Luismi Marti
* Ported to Arduino: Ruben Martin
*/
#include <Wire.h>
// Cooking API libraries
#include <arduinoUART.h>
#include <arduinoUtils.h>
// LoRaWAN library
#include <arduinoLoRaWAN.h>
//////////////////////////////////////////////
uint8_t socket = SOCKET1;
//////////////////////////////////////////////
// Device parameters for Back-End registration
////////////////////////////////////////////////////////////
char DEVICE_EUI[] = "0102030405060708";
char DEVICE_ADDR[] = "05060708";
char NWK_SESSION_KEY[] = "01020304050607080910111213141516";
char APP_SESSION_KEY[] = "000102030405060708090A0B0C0D0E0F";
char APP_KEY[] = "000102030405060708090A0B0C0D0E0F";
////////////////////////////////////////////////////////////
// variable
uint8_t error;
void setup()
{
Serial.begin(57600);
// 1. switch on
error = LoRaWAN.ON(socket);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 2. Reset to factory default values
error = LoRaWAN.factoryReset();
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 3. Set/Get Device EUI
error = LoRaWAN.setDeviceEUI(DEVICE_EUI);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
error = LoRaWAN.getDeviceEUI();
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 4. Set/Get Device Address
error = LoRaWAN.setDeviceAddr(DEVICE_ADDR);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
error = LoRaWAN.getDeviceAddr();
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 5. Set Network Session Key
error = LoRaWAN.setNwkSessionKey(NWK_SESSION_KEY);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 6. Set Application Session Key
error = LoRaWAN.setAppSessionKey(APP_SESSION_KEY);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 7. Set retransmissions for uplink confirmed packet
error = LoRaWAN.setRetries((uint8_t)7);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
error = LoRaWAN.getRetries();
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 8. Set application key
error = LoRaWAN.setAppKey(APP_KEY);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 9. Channel configuration. (Recomemnded)
// Consult your Network Operator and Backend Provider
// Set channel 3 -> 867.1 MHz
// Set channel 4 -> 867.3 MHz
// Set channel 5 -> 867.5 MHz
// Set channel 6 -> 867.7 MHz
// Set channel 7 -> 867.9 MHz
uint32_t freq = 867100000;
for (uint8_t ch = 3; ch <= 7; ch++)
{
error |= LoRaWAN.setChannelFreq(ch, freq);
freq += 200000;
}
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 10. Set Duty Cycle for specific channel. (Recomemnded)
// Consult your Network Operator and Backend Provider
for (uint8_t ch = 0; ch <= 2; ch++)
{
error |= LoRaWAN.setChannelDutyCycle(ch, 33333);
}
for (int ch = 3; ch <= 7; ch++)
{
error |= LoRaWAN.setChannelDutyCycle(ch, 40000);
}
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 11. Set Data Range for specific channel. (Recomemnded)
// Consult your Network Operator and Backend Provider
for (uint8_t ch = 0; ch <= 7; ch++)
error |= LoRaWAN.setChannelDRRange(ch, 0, 5);
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 12. Set Data rate range for specific channel. (Recomemnded)
// Consult your Network Operator and Backend Provider
for (uint8_t ch = 0; ch <= 7; ch++)
error |= LoRaWAN.setChannelStatus(ch, (char *)"on");
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
// 13. Save configuration
error = LoRaWAN.saveConfig();
if (error != 0)
{
Serial.print(F("Error: "));
Serial.println(error);
}
//------------------------------------
//Now the LoRaWAN module is ready for
//joining networks and send messages.
//Please check the next examples...
//------------------------------------
Serial.end();
}
void loop()
{
// do nothing
}
Estoy empleando el IDE Visual Studio Code, para subir el código al arduino empleo el plugin/IDE PlatformIO. Consigue subirlo y me muestra la siguiente salida, adjunto:
Code:
sys get ver
sys factoryRESET
mac set deveui 0102030405060708
mac get deveui
Error: 1
mac set devaddr 05060708
Error: 1
mac get devaddr
Error: 1
mac set nwkskey 01020304050607080910111213141516
Error: 1
mac set appskey 000102030405060708090A0B0C0D0E0F
Error: 1
mac set retx 7
Error: 2
mac get retx
mac set appkey 000102030405060708090A0B0C0D0E0F
mac set ch freq 3 867100000
mac set ch freq 4 867300000
mac set ch freq 5 867500000
mac set ch freq 6 867700000
mac set ch freq 7 867900000
mac set ch dcycle 0 33333
mac set ch dcycle 1 33333
mac set ch dcycle 2 33333
mac set ch dcycle 3 40000
mac set ch dcycle 4 40000
mac set ch dcycle 5 40000
mac set ch dcycle 6 40000
mac set ch dcycle 7 40000
mac set ch drrange 0 0 5
mac set ch drrange 1 0 5
mac set ch drrange 2 0 5
mac set ch drrange 3 0 5
mac set ch drrange 4 0 5
mac set ch drrange 5 0 5
mac set ch drrange 6 0 5
mac set ch drrange 7 0 5
mac set ch status 0 on
mac set ch status 1 on
mac set ch status 2 on
mac set ch status 3 on
mac set ch status 4 on
mac set ch status 5 on
mac set ch status 6 on
mac set ch status 7 on
mac save
El socket empleado es el 1, adjunto link a imagen:
https://imageshack.com/a/img924/9213/nqpQ5D.jpgSi necesitan cualquier otra información la subiré sin problemas.
Muchas gracias,
Aaron.