For clarity for you & other readers, this is Device Address
**EDIT: no it’s not, I got it wrong, “The DEVKEY is LMiC’s antiquated name for the APPKEY”
DEVKEY? Perhaps App Key?
Not consistent or not ever working?
For clarity for you & other readers, this is Device Address
**EDIT: no it’s not, I got it wrong, “The DEVKEY is LMiC’s antiquated name for the APPKEY”
DEVKEY? Perhaps App Key?
Not consistent or not ever working?
rather, it takes a long time to make the first transmission in ABP knowing that you already have the defined access keys and therefore you do not have to do a union management with the TTN server
Let me guess, you first received transmission dies not start at counter 0. Do you reset the frame counter when restarting the node?
I have disabled the counter
The problem most of all is in making the first transmission after loading the code or a reset
Hello,
is there also a conversion for the LorABoard B-L072Z-LRWAN1 with the CMWX1ZZABZ-091 open module by Murata? (STM32Cube)
Greetings
E_T
Hello
Thank you all very much for the help you gave me with the comments because thanks to those I managed to do the data transmission through ABP
Now I have another problem
I want to make the microcontroller go to Sleep mode after doing a transmission every X time
I have knowledge of the sleep, standby and Stop modes of operation
my question is
In which area of the Main file can I integrate some of the sleep modes?
Can you point us at the code base - sooooo many implementations, so little time.
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "lmic.h"
#include "debug.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
// application router ID (LSBF) < ------- IMPORTANT
//static const u1_t APPEUI[8] = { 0xCA, 0x93, 0x03, 0xD0, 0x7E, 0xD5, 0xB3, 0x70 };
// unique device ID (LSBF) < ------- IMPORTANT
//static const u1_t DEVEUI[8] = { 0x38, 0x9B, 0xB1, 0x17, 0x60, 0xF2, 0x43, 0x00 };
// device-specific AES key (derived from device EUI)
//static const u1_t DEVKEY[16] = { 0x08, 0x2C, 0xB4, 0x55, 0xEA, 0xDB, 0xA8, 0xFF, 0x0F, 0x34, 0x7A, 0x69, 0x14, 0x53, 0xC6, 0x48 };
// ABP
// bluepill
static const u4_t DEVADDR = 0x26021008;
static const u1_t NWKSKEY[16] = { 0xE9, 0x10, 0xB1, 0xB3, 0xEC, 0xC4, 0x5C, 0x6B, 0x74, 0x73, 0x13, 0xE8, 0xB4, 0xF2, 0x3D, 0xCA };
static const u1_t APPSKEY[16] = { 0x66, 0xF4, 0x21, 0xE2, 0x69, 0xE5, 0x4B, 0x22, 0x31, 0xE5, 0x89, 0xFF, 0xDA, 0x28, 0x6D, 0x68 };
// ABP
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void);
static void MX_TIM4_Init(void);
static void MX_USART3_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
// provide application router ID (8 bytes, LSBF)
void os_getArtEui (u1_t* buf) {
// memcpy(buf, APPEUI, 8);
}
// provide device ID (8 bytes, LSBF)
void os_getDevEui (u1_t* buf) {
//memcpy(buf, DEVEUI, 8);
}
// provide device key (16 bytes)
void os_getDevKey (u1_t* buf) {
//memcpy(buf, DEVKEY, 16);
}
void initsensor(){
// Here you init your sensors
}
u2_t readsensor(){
u2_t value = 0xDF; /// read from evrything ...make your own sensor
return value;
}
static osjob_t reportjob;
// report sensor value every minute
static void reportfunc (osjob_t* j) {
// read sensor
u2_t val = readsensor();
debug_val("val = ", val);
// prepare and schedule data for transmission
LMIC.frame[0] = val << 8;
LMIC.frame[1] = val;
LMIC_setTxData2(1, LMIC.frame, 2, 0); // (port 1, 2 bytes, unconfirmed)
// reschedule job in 60 seconds
os_setTimedCallback(j, os_getTime()+sec2osticks(10), reportfunc);
}
void initfunc (osjob_t* j) {
// intialize sensor hardware
initsensor();
// reset MAC state
LMIC_reset();
// start joining
//LMIC_startJoining();
// init done - onEvent() callback will be invoked...
// ABP
uint8_t appskey[sizeof(APPSKEY)];
uint8_t nwkskey[sizeof(NWKSKEY)];
memcpy(appskey, APPSKEY, sizeof(APPSKEY));
memcpy(nwkskey, NWKSKEY, sizeof(NWKSKEY));
LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
// Disable link check validation
LMIC_setLinkCheckMode(0);
// TTN uses SF9 for its RX2 window.
LMIC.dn2Dr = DR_SF9;
// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF7,14);
os_setTimedCallback(j, os_getTime(), reportfunc);
// ABP
}
//////////////////////////////////////////////////
// LMIC EVENT CALLBACK
//////////////////////////////////////////////////
void onEvent (ev_t ev) {
debug_event(ev);
switch(ev) {
// network joined, session established
case EV_JOINING:
debug_str("try joining\r\n");
break;
case EV_JOINED:
debug_led(1);
// kick-off periodic sensor job
reportfunc(&reportjob);
break;
case EV_JOIN_FAILED:
debug_str("join failed\r\n");
break;
case EV_SCAN_TIMEOUT:
debug_str("EV_SCAN_TIMEOUT\r\n");
break;
case EV_BEACON_FOUND:
debug_str("EV_BEACON_FOUND\r\n");
break;
case EV_BEACON_MISSED:
debug_str("EV_BEACON_MISSED\r\n");
break;
case EV_BEACON_TRACKED:
debug_str("EV_BEACON_TRACKED\r\n");
break;
case EV_RFU1:
debug_str("EV_RFU1\r\n");
break;
case EV_REJOIN_FAILED:
debug_str("EV_REJOIN_FAILED\r\n");
break;
case EV_TXCOMPLETE:
debug_str("EV_TXCOMPLETE (includes waiting for RX windows)\r\n");
if (LMIC.txrxFlags & TXRX_ACK)
debug_str("Received ack\r\n");
if (LMIC.dataLen) {
debug_str("Received ");
debug_str(LMIC.dataLen);
debug_str(" bytes of payload\r\n");
}
break;
case EV_LOST_TSYNC:
debug_str("EV_LOST_TSYNC\r\n");
break;
case EV_RESET:
debug_str("EV_RESET\r\n");
break;
case EV_RXCOMPLETE:
// data received in ping slot
debug_str("EV_RXCOMPLETE\r\n");
break;
case EV_LINK_DEAD:
debug_str("EV_LINK_DEAD\r\n");
break;
case EV_LINK_ALIVE:
debug_str("EV_LINK_ALIVE\r\n");
break;
default:
debug_str("Unknown event\r\n");
break;
}
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI1_Init();
MX_TIM4_Init();
MX_USART3_UART_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim4); // <----------- change to your setup
__HAL_SPI_ENABLE(&hspi1); // <----------- change to your setup
osjob_t initjob;
// initialize runtime env
os_init();
// initialize debug library
debug_init();
// setup initial job
os_setCallback(&initjob, initfunc);
// execute scheduled jobs and events
os_runloop();
// (not reached)
return 0;
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Can you link to the source of the code please.
Next time you post code please take a few seconds to properly format your post instead of just cut-and-paste dumping the text.
hello good to all
I have a problem with the transmission of data to the TTN Server
What could be happening in the data transmission?
I started well until I reached number four and did not transmit again until number
twenty one
This has happened to me several times
Note: I have a led doing Toggle every time it goes through the transmit function
static void reportfunc ()
why on earth are you sending every 10 seconds?
set to longer duration, say 2 mins for testing only, maybe the library is enforcing airtime rules (didn’t read which library you are using sorry)
hi
You say that changing the transmission times can improve this phenomenon?
Possibly yes.
At the most basic level your breaking airtime rules/law re usage - others can tell you by how much, every 10 secs is vey bad, and to to help stop devices doing this some lmic libraries will enforce airtime uplink rules.
Just change transmit duration to 2min and run again, take this issue out of the equation - ppl wont be pleased to see a 10 delay being used even for testing
I am using the LMIC library for stm32cubemx
ostime_t avail; // channel is blocked until this time
The library does have code to enforce duty cycle limits (I think) from my very very quick scan, have you tried longer periods in uplinks?
yes
I have tested broadcast times of ten minutes and I still get the same result
Ten minutes and you then waited an hour to see exact same results? do you have actual device logs for the same matching period? would be useful to see gateway activity rather than application console view too
Just looking at that application console screen shot the time gap matches the number of 10 second transmits, you give no details about the spreading factor in use, is it your gateway? I’d be curious to see exactly what you over the 4 hours on a 10 min duty cycle - are you saying it does uplinks for the five 5 TX’s and then there is a gap of 2.8hrs until number 21 tx appears ?
Okay, I’ll do tests with a type of 200 seconds that is equivalent to 3:20 minutes, which is the minimum admitted by lorawan