Hello, I’m trying to connect my RAK3172 to my ChirpStack server with this code :
/**
* This is a very basic example that demonstrates how to configure the
* library, join the network, send regular packets and print any
* downlink packets received.
* This example is using the RTC in MIX (binary and BCD) mode
*
* Revised BSD License - https://spdx.org/licenses/BSD-3-Clause.html
*/
#include <STM32LoRaWAN.h>
STM32LoRaWAN modem;
/* Get the rtc object */
STM32RTC& rtc = STM32RTC::getInstance();
bool connected = false;
void setup() {
Serial.begin(115200);
Serial.println("Start");
modem.begin(AS923);
// Configure join method by (un)commenting the right method
// call, and fill in credentials in that method call.
//bool connected = modem.joinOTAA(/* AppEui */ "0000000000000000", /* AppKey */ "00000000000000000000000000000000", /* DevEui */ "0000000000000000");
connected = modem.joinABP(/* DevAddr */ "XXXXX", /* NwkSKey */ "XXXXXXX", /* AppSKey */ "XXXXXXXX");
if (connected) {
Serial.println("Joined");
} else {
Serial.println("Join failed");
while (true) /* infinite loop */
;
}
/* set the calendar */
rtc.setTime(15, 30, 58);
rtc.setDate(04, 07, 23);
}
void send_packet() {
char payload[27] = { 0 }; /* packet to be sent */
/* prepare the Tx packet : get date and format string */
sprintf(payload, "%02d/%02d/%04d - %02d:%02d:%02d",
rtc.getMonth(), rtc.getDay(), 2000 + rtc.getYear(),
rtc.getHours(), rtc.getMinutes(), rtc.getSeconds());
modem.setPort(10);
modem.beginPacket();
modem.write(payload, strlen(payload));
if (modem.endPacket() == (int)strlen(payload)) {
Serial.println("Sent packet");
} else {
Serial.println("Failed to send packet");
}
if (modem.available()) {
Serial.print("Received packet on port ");
Serial.print(modem.getDownlinkPort());
Serial.print(":");
while (modem.available()) {
uint8_t b = modem.read();
Serial.print(" ");
Serial.print(b >> 4, HEX);
Serial.print(b & 0xF, HEX);
}
Serial.println();
} else {
Serial.print("Modem is not available for downlink\n");
}
}
void loop() {
if(connected){
Serial.print("Connected, the package will be sent... ");
send_packet();
delay(3000);
} else {
Serial.print("You are not connected\n");
}
}
My output says that the packet is sent correctly but i can’t retrieve my data on my chirpstack server, do you have any ideas why ?