--revised for accurate format
This commit is contained in:
parent
734b12f30d
commit
2671b759f8
|
@ -735,10 +735,20 @@ static void SendTxData(void)
|
||||||
STS_RR_Sensor_Read(&sts_rr_sensor_data);
|
STS_RR_Sensor_Read(&sts_rr_sensor_data);
|
||||||
AppData.Port = YUNHORN_STS_R1_LORA_APP_DATA_PORT; /* STS-R1 Data Port */
|
AppData.Port = YUNHORN_STS_R1_LORA_APP_DATA_PORT; /* STS-R1 Data Port */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
AppData.Buffer[i++] = AppLedStateOn;
|
||||||
|
AppData.Buffer[i++] = (uint8_t) sts_mtmcode1;
|
||||||
|
AppData.Buffer[i++] = (uint8_t) sts_mtmcode2;
|
||||||
|
AppData.Buffer[i++] = (uint8_t) sts_hardware_ver;
|
||||||
|
AppData.Buffer[i++] = (uint8_t) 99*batteryLevel/254;
|
||||||
|
|
||||||
|
#if 0
|
||||||
APP_LOG(TS_ON, VLEVEL_M, "VDDA: %d\r\n", batteryLevel);
|
APP_LOG(TS_ON, VLEVEL_M, "VDDA: %d\r\n", batteryLevel);
|
||||||
APP_LOG(TS_ON, VLEVEL_M, "temp: %d\r\n", (int16_t)(sensor_data.temperature));
|
APP_LOG(TS_ON, VLEVEL_M, "temp: %d\r\n", (int16_t)(sensor_data.temperature));
|
||||||
|
|
||||||
//AppData.Port = LORAWAN_USER_APP_PORT;
|
AppData.Port = LORAWAN_USER_APP_PORT;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef STS_P2
|
#ifdef STS_P2
|
||||||
AppData.Port = 106; /* STS-P2 Data Port */
|
AppData.Port = 106; /* STS-P2 Data Port */
|
||||||
#endif
|
#endif
|
||||||
|
@ -758,6 +768,8 @@ static void SendTxData(void)
|
||||||
CayenneLppCopy(AppData.Buffer);
|
CayenneLppCopy(AppData.Buffer);
|
||||||
AppData.BufferSize = CayenneLppGetSize();
|
AppData.BufferSize = CayenneLppGetSize();
|
||||||
#else /* not CAYENNE_LPP */
|
#else /* not CAYENNE_LPP */
|
||||||
|
|
||||||
|
#if 0
|
||||||
humidity = (uint16_t)(sensor_data.humidity * 10); /* in %*10 */
|
humidity = (uint16_t)(sensor_data.humidity * 10); /* in %*10 */
|
||||||
temperature = (int16_t)(sensor_data.temperature);
|
temperature = (int16_t)(sensor_data.temperature);
|
||||||
pressure = (uint16_t)(sensor_data.pressure * 100 / 10); /* in hPa / 10 */
|
pressure = (uint16_t)(sensor_data.pressure * 100 / 10); /* in hPa / 10 */
|
||||||
|
@ -792,30 +804,41 @@ static void SendTxData(void)
|
||||||
AppData.Buffer[i++] = (uint8_t)((altitudeGps >> 8) & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)((altitudeGps >> 8) & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(altitudeGps & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(altitudeGps & 0xFF);
|
||||||
}
|
}
|
||||||
#ifdef VL53L0
|
#endif
|
||||||
#if defined(STS_R1)||defined(STS_R1D)||defined(STS_R5)
|
|
||||||
|
#ifdef VL53L0 //VL53L0
|
||||||
|
#if defined(STS_R1)||defined(STS_R5)
|
||||||
|
AppData.Buffer[i++] = 2;
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_1_distance_mm >>8 & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_1_distance_mm >>8 & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_1_distance_mm & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_1_distance_mm & 0xFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STS_R1D
|
||||||
|
AppData.Buffer[i++] = 4;
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_1_distance_mm >>8 & 0xFF);
|
||||||
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_1_distance_mm & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm >>8 & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm >>8 & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm & 0xFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STS_R5_EXT
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm >>8 & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm >>8 & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm & 0xFF);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(STS_R1D)
|
#if defined(STS_R1D)
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm >>8 & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm >>8 & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_2_distance_mm & 0xFF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(STS_R5_EXT)
|
#if defined(STS_R5_EXT)
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm >>8 & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm >>8 & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_rr_sensor_data.tof_3_distance_mm & 0xFF);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#ifdef VL53LX
|
#endif //VL53L0
|
||||||
|
|
||||||
|
#ifdef VL53LX // VL53L1X
|
||||||
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Walk_In_People_Count>>8) & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Walk_In_People_Count>>8) & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Walk_In_People_Count & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Walk_In_People_Count & 0xFF);
|
||||||
|
|
||||||
|
@ -824,8 +847,8 @@ static void SendTxData(void)
|
||||||
|
|
||||||
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Walk_Around_People_Count>>8) & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Walk_Around_People_Count>>8) & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Walk_Around_People_Count & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Walk_Around_People_Count & 0xFF);
|
||||||
#endif
|
#endif // VL53L1X
|
||||||
#ifdef VL53LX
|
#ifdef VL53LX // VL53L1X
|
||||||
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Count_Period) & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Count_Period) & 0xFF);
|
||||||
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Count_Period_Unit) & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)((sts_p2_sensor_data.Count_Period_Unit) & 0xFF);
|
||||||
|
|
||||||
|
@ -839,8 +862,10 @@ static void SendTxData(void)
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Sum_Day_Walk_Around_People_Count & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Sum_Day_Walk_Around_People_Count & 0xFF);
|
||||||
|
|
||||||
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Count_Valid & 0xFF);
|
AppData.Buffer[i++] = (uint8_t)(sts_p2_sensor_data.Count_Valid & 0xFF);
|
||||||
#endif
|
#endif // VL53L1X
|
||||||
|
|
||||||
AppData.BufferSize = i;
|
AppData.BufferSize = i;
|
||||||
|
|
||||||
#endif /* CAYENNE_LPP */
|
#endif /* CAYENNE_LPP */
|
||||||
|
|
||||||
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
|
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
|
||||||
|
@ -1267,8 +1292,8 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
|
||||||
appHeartBeatDataPort = YUNHORN_STS_R1_LORA_APP_HTBT_PORT;
|
appHeartBeatDataPort = YUNHORN_STS_R1_LORA_APP_HTBT_PORT;
|
||||||
#endif
|
#endif
|
||||||
appHeartBeatBufferSize = 2;
|
appHeartBeatBufferSize = 2;
|
||||||
appHeartBeatDataBuffer[0]=0x80;
|
appHeartBeatDataBuffer[0]=(uint8_t)(0x80|AppLedStateOn);
|
||||||
appHeartBeatDataBuffer[1]=0x63; //TODO XXX change to battery level %
|
appHeartBeatDataBuffer[1]=(uint8_t)(SYS_GetBatteryLevel()/100); //TODO XXX change to battery level in mV
|
||||||
|
|
||||||
STS_SENSOR_Upload_Message(appHeartBeatDataPort, appHeartBeatBufferSize, (uint8_t*)appHeartBeatDataBuffer);
|
STS_SENSOR_Upload_Message(appHeartBeatDataPort, appHeartBeatBufferSize, (uint8_t*)appHeartBeatDataBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -370,7 +370,8 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
||||||
sts_tof_vl53l0x_SetupSingleShot(RangingConfig);
|
sts_tof_vl53l0x_SetupSingleShot(RangingConfig);
|
||||||
|
|
||||||
sensor_data_ready = 0 ;
|
sensor_data_ready = 0 ;
|
||||||
for (i=0; i< MAX_TOF_COUNT; i++)
|
//for (i=0; i< MAX_TOF_COUNT; i++)
|
||||||
|
for (i=0; i< nSensorPresent; i++)
|
||||||
{
|
{
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\n i=%u Present=%u DevAdd=%02x \n", i, VL53L0XDevs[i].Present, VL53L0XDevs[i].I2cDevAddr);
|
APP_LOG(TS_OFF, VLEVEL_M, "\n\n i=%u Present=%u DevAdd=%02x \n", i, VL53L0XDevs[i].Present, VL53L0XDevs[i].I2cDevAddr);
|
||||||
if (VL53L0XDevs[i].Present ==1)
|
if (VL53L0XDevs[i].Present ==1)
|
||||||
|
@ -386,7 +387,7 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
||||||
{
|
{
|
||||||
sts_tof_distance_data[i] = (int)VL53L0XDevs[i].LeakyRange;
|
sts_tof_distance_data[i] = (int)VL53L0XDevs[i].LeakyRange;
|
||||||
nDevMask |= (1 << i);
|
nDevMask |= (1 << i);
|
||||||
sensor_data_ready |= 1;
|
sensor_data_ready |= 1<<i;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
//HandleError(ERR_DEMO_RANGE_ONE);
|
//HandleError(ERR_DEMO_RANGE_ONE);
|
||||||
|
@ -432,6 +433,11 @@ void STS_RR_Sensor_Read(sts_tof_range_data_t *sts_rr_sensor_data)
|
||||||
sts_rr_sensor_data->tof_3_distance_mm = sts_tof_distance_data[2];
|
sts_rr_sensor_data->tof_3_distance_mm = sts_tof_distance_data[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void STS_Prepare_Packet_Data(void)
|
||||||
|
{
|
||||||
|
//AppData.Buffer = 0x0;
|
||||||
|
//AppData.BufferSize = 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue