diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 8867416..fe39290 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -217,9 +217,14 @@ void Error_Handler(void);
#define SOAP_STATUS_Pin GPIO_PIN_10
#define SOAP_STATUS_GPIO_Port GPIOA
+#ifdef RM2
+#define SOAP_SWITCH_Pin GPIO_PIN_3 // 2024-04-08 WAS GPIO_PIN_3
+#define SOAP_SWITCH_GPIO_Port GPIOB
+#elif
/* IF_SENSOR_ON_OFF, MEMS_IF_1, PB3 */
#define SOAP_SWITCH_Pin GPIO_PIN_5 // 2024-04-08 WAS GPIO_PIN_3
#define SOAP_SWITCH_GPIO_Port GPIOB
+#endif
#define SOAP_DATA HAL_GPIO_ReadPin(SOAP_STATUS_GPIO_Port,SOAP_STATUS_Pin)
#endif
diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c
index 499979c..6b70c38 100644
--- a/Core/Src/gpio.c
+++ b/Core/Src/gpio.c
@@ -124,7 +124,7 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pin = SOAP_STATUS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
- //GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(SOAP_STATUS_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = SOAP_SWITCH_Pin;
diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c
index 372d3a1..64715f8 100644
--- a/Core/Src/stm32wlxx_it.c
+++ b/Core/Src/stm32wlxx_it.c
@@ -314,7 +314,7 @@ void EXTI9_5_IRQHandler(void)
/* USER CODE END EXTI9_5_IRQn 0 */
#ifndef RM2
HAL_GPIO_EXTI_IRQHandler(BUT3_Pin);
-#elif defined(RM2)
+#elif defined(RM2)&&(defined(VL53L0)||defined(VL53LX))
HAL_GPIO_EXTI_IRQHandler(TOF_INT_EXTI_PIN);
#endif
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 45821b5..10aea96 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -766,7 +766,7 @@ static void SendTxData(void)
EnvSensors_Read(&sensor_data);
#ifdef STS_R4
- //UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), CFG_SEQ_Prio_0);
+ UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), CFG_SEQ_Prio_0);
//STS_YunhornSTSEventP6_Process();
STS_R4_sensor_read(&sts_r4_sensor_data);
#endif
@@ -795,7 +795,7 @@ static void SendTxData(void)
#endif
- AppData.Buffer[i++] = AppLedStateOn;
+ AppData.Buffer[i++] = (uint8_t) (AppLedStateOn|0x80); // for first byte, cannot be 0x0
AppData.Buffer[i++] = (uint8_t) sts_mtmcode1;
AppData.Buffer[i++] = (uint8_t) sts_mtmcode2;
AppData.Buffer[i++] = (uint8_t) sts_hardware_ver;
@@ -921,8 +921,8 @@ static void SendTxData(void)
/* STS-R4 SOAP LEVEL SENSOR */
#ifdef STS_R4
AppData.Buffer[i++] = 2;
- AppData.Buffer[i++] = (uint8_t)(sts_r4_sensor_data.measure_tech & 0xFF);
- AppData.Buffer[i++] = (uint8_t)(sts_r4_sensor_data.on_off_event & 0xFF);
+ AppData.Buffer[i++] = (uint8_t)(sts_r4_sensor_data.measure_tech & 0xFF);
+ AppData.Buffer[i++] = (uint8_t)(sts_r4_sensor_data.on_off_event & 0xFF);
#endif //STS_R4
AppData.BufferSize = i;
@@ -962,7 +962,7 @@ static void OnTxTimerEvent(void *context)
/* USER CODE BEGIN OnTxTimerEvent_1 */
/* USER CODE END OnTxTimerEvent_1 */
- UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP6), CFG_SEQ_Prio_0);
+ APP_LOG(TS_OFF, VLEVEL_M, "\n\n TxTimerEvent *************\n");
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
/*Wait for next tx slot*/
@@ -1377,7 +1377,7 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
appHeartBeatBufferSize = 2;
appHeartBeatDataBuffer[0]=(uint8_t)(0x80|AppLedStateOn);
appHeartBeatDataBuffer[1]=(uint8_t)(SYS_GetBatteryLevel()/100); //TODO XXX change to battery level in mV
-
+ APP_LOG(TS_OFF, VLEVEL_M, "\n\n HEART-BEAT TIMER = %d\n\n", rfac_timer);
STS_SENSOR_Upload_Message(appHeartBeatDataPort, appHeartBeatBufferSize, (uint8_t*)appHeartBeatDataBuffer);
#endif
@@ -1411,7 +1411,7 @@ void OnYunhornSTSHeartBeatPeriodicityChanged(uint32_t periodicity)
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
/* USER CODE BEGIN OnYunhornSTSHeartBeatPeriodicityChanged_2 */
- APP_LOG(TS_OFF, VLEVEL_H,"**************** HeartBeatPeriodicity = %u (sec)\r\n", periodicity/1000 );
+ APP_LOG(TS_OFF, VLEVEL_M,"**************** HeartBeatPeriodicity = %u (ms)\r\n", periodicity );
/* USER CODE END OnYunhornSTSHeartBeatPeriodicityChanged_2 */
}
@@ -1426,3 +1426,24 @@ static void OnYunhornSTSWakeUpScanTimerEvent(void *context)
}
+/**
+ * @brief Yunhorn STS Tx Periodicity Change function
+ * @param duration of periodicty in ms (1/1000 sec)
+ */
+void OnYunhornSTSTxPeriodicityChanged(uint32_t periodicity)
+{
+ /* USER CODE BEGIN OnYunhornSTSTxPeriodicityChanged */
+
+ /* USER CODE END OnYunhornSTSTxPeriodicityChanged */
+
+ /* Update timer OnYunhornSTSTxPeriodicityChanged */
+
+ UTIL_TIMER_Stop(&TxTimer);
+ TxPeriodicity = periodicity;
+ UTIL_TIMER_SetPeriod(&TxTimer, TxPeriodicity);
+ UTIL_TIMER_Start(&TxTimer);
+
+ /* USER CODE BEGIN OnYunhornSTSTxPeriodicityChanged */
+ APP_LOG(TS_OFF, VLEVEL_M,"**************** TxPeriodicity = %u (sec)\r\n", TxPeriodicity/1000 );
+ /* USER CODE END OnYunhornSTSTxPeriodicityChanged */
+}
diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject
index 27a9d57..471b8cf 100644
--- a/STM32CubeIDE/.cproject
+++ b/STM32CubeIDE/.cproject
@@ -134,6 +134,7 @@