Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Antoine Rivera
Serres connectées
Commits
3213ff7a
Commit
3213ff7a
authored
Apr 11, 2019
by
Marcelo
Browse files
Transmission des données chaque 3 mesures
Code lorawan modifié pour envoyer les données chaque 3 mesures
parent
f55f1e50
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/standby/standby.cpp
View file @
3213ff7a
...
...
@@ -22,7 +22,6 @@ int config_RTC(const uint16_t time)
// Reset and Clock Control
// Power interface clock enabled
_SET_BIT
(
RCC
->
APB1ENR
,
RCC_APB1ENR_PWREN
);
enable_bkp_access
();
// Select the RTC clock source: LSE oscillator (32768Hz)
_SET_BIT
(
RCC
->
CSR
,
RCC_CSR_RTCSEL_LSE
);
// Enable the external low-speed LSE oscillator
...
...
@@ -80,7 +79,7 @@ void enter_Standby(void)
void
standby_mode
(
const
uint16_t
time
)
{
config_
LowPower
();
config_
Standby
();
config_RTC
(
time
);
enter_Standby
();
__WFI
();
// Waiting for Interruption -> Enter low-power mode
...
...
src/main.cpp
View file @
3213ff7a
...
...
@@ -29,7 +29,7 @@
#define LC10 { 868300000, { ( ( DR_6 << 4 ) | DR_6 ) }, 1 }
#define LORAWAN_APP_PORT 15
#define LORAWAN_APP_DATA_SIZE
1
5
#define LORAWAN_APP_DATA_SIZE
4
5
#define LORAWAN_APP_DATA_MAX_SIZE 64
static
uint8_t
DevEui
[]
=
LORAWAN_DEVICE_EUI
;
...
...
@@ -45,7 +45,7 @@ static uint8_t IsTxConfirmed = LORAWAN_CONFIRMED_MSG_ON;
static
bool
AppLedStateOn
=
false
;
volatile
bool
Led3StateChanged
=
false
;
const
int16_t
T_sleep
=
18
00
;
//
30
minutes
const
int16_t
T_sleep
=
3
00
;
//
5
minutes
static
bool
NextTx
=
true
;
...
...
@@ -104,23 +104,20 @@ static SHT31 sensor1 (I2C_SDA, I2C_SCL, false, true);
static
SHT31
sensor2
(
I2C_SDA
,
I2C_SCL
,
false
,
false
);
static
SHTx
::
SHT15
sensor3
(
D9
,
D8
);
void
DeviceUpdate
(
void
);
void
SerialDisplayRefresh
(
void
);
void
SerialRxProcess
(
void
);
int16_t
Round
(
float
number
);
int16_t
RoundT
(
float
number
);
static
void
PrepareTxFrame
(
uint8_t
port
);
static
bool
SendFrame
(
void
);
static
void
OnTxNextPacketTimerEvent
(
void
);
static
void
OnLed1TimerEvent
(
void
);
static
void
OnLed2TimerEvent
(
void
);
static
void
McpsConfirm
(
McpsConfirm_t
*
mcpsConfirm
);
static
void
McpsIndication
(
McpsIndication_t
*
mcpsIndication
);
static
void
MlmeConfirm
(
MlmeConfirm_t
*
mlmeConfirm
);
int
main
(
void
)
{
LoRaMacPrimitives_t
LoRaMacPrimitives
;
LoRaMacCallback_t
LoRaMacCallbacks
;
MibRequestConfirm_t
mibReq
;
// Sensors configuration
sensor3
.
setOTPReload
(
false
);
sensor3
.
setResolution
(
true
);
...
...
@@ -132,127 +129,130 @@ int main (void)
SerialDisplayUpdateEui
(
6
,
AppEui
);
SerialDisplayUpdateKey
(
7
,
AppKey
);
DeviceState
=
DEVICE_STATE_INIT
;
PrepareTxFrame
(
AppPort
);
standby_mode
(
T_sleep
);
}
// main
while
(
1
)
bool
DeviceUpdate
(
void
)
{
LoRaMacPrimitives_t
LoRaMacPrimitives
;
LoRaMacCallback_t
LoRaMacCallbacks
;
MibRequestConfirm_t
mibReq
;
SerialRxProcess
();
if
(
IsNetworkJoinedStatusUpdate
==
true
)
{
SerialRxProcess
();
if
(
IsNetworkJoinedStatusUpdate
==
true
)
{
IsNetworkJoinedStatusUpdate
=
false
;
mibReq
.
Type
=
MIB_NETWORK_JOINED
;
LoRaMacMibGetRequestConfirm
(
&
mibReq
);
SerialDisplayUpdateNetworkIsJoined
(
mibReq
.
Param
.
IsNetworkJoined
);
}
if
(
Led3StateChanged
==
true
)
{
Led3StateChanged
=
false
;
SerialDisplayUpdateLedState
(
3
,
AppLedStateOn
);
}
if
(
UplinkStatusUpdated
==
true
)
{
UplinkStatusUpdated
=
false
;
SerialDisplayUpdateUplink
(
LoRaMacUplinkStatus
.
Acked
,
LoRaMacUplinkStatus
.
Datarate
,
LoRaMacUplinkStatus
.
UplinkCounter
,
LoRaMacUplinkStatus
.
Port
,
LoRaMacUplinkStatus
.
Buffer
,
LoRaMacUplinkStatus
.
BufferSize
);
}
if
(
DownlinkStatusUpdated
==
true
)
{
DownlinkStatusUpdated
=
false
;
SerialDisplayUpdateDownlink
(
LoRaMacDownlinkStatus
.
RxData
,
LoRaMacDownlinkStatus
.
Rssi
,
LoRaMacDownlinkStatus
.
Snr
,
LoRaMacDownlinkStatus
.
DownlinkCounter
,
LoRaMacDownlinkStatus
.
Port
,
LoRaMacDownlinkStatus
.
Buffer
,
LoRaMacDownlinkStatus
.
BufferSize
);
}
IsNetworkJoinedStatusUpdate
=
false
;
mibReq
.
Type
=
MIB_NETWORK_JOINED
;
LoRaMacMibGetRequestConfirm
(
&
mibReq
);
SerialDisplayUpdateNetworkIsJoined
(
mibReq
.
Param
.
IsNetworkJoined
);
}
if
(
Led3StateChanged
==
true
)
{
Led3StateChanged
=
false
;
SerialDisplayUpdateLedState
(
3
,
AppLedStateOn
);
}
if
(
UplinkStatusUpdated
==
true
)
{
UplinkStatusUpdated
=
false
;
SerialDisplayUpdateUplink
(
LoRaMacUplinkStatus
.
Acked
,
LoRaMacUplinkStatus
.
Datarate
,
LoRaMacUplinkStatus
.
UplinkCounter
,
LoRaMacUplinkStatus
.
Port
,
LoRaMacUplinkStatus
.
Buffer
,
LoRaMacUplinkStatus
.
BufferSize
);
}
if
(
DownlinkStatusUpdated
==
true
)
{
DownlinkStatusUpdated
=
false
;
SerialDisplayUpdateDownlink
(
LoRaMacDownlinkStatus
.
RxData
,
LoRaMacDownlinkStatus
.
Rssi
,
LoRaMacDownlinkStatus
.
Snr
,
LoRaMacDownlinkStatus
.
DownlinkCounter
,
LoRaMacDownlinkStatus
.
Port
,
LoRaMacDownlinkStatus
.
Buffer
,
LoRaMacDownlinkStatus
.
BufferSize
);
}
switch
(
DeviceState
)
{
case
DEVICE_STATE_INIT
:
LoRaMacPrimitives
.
MacMcpsConfirm
=
McpsConfirm
;
LoRaMacPrimitives
.
MacMcpsIndication
=
McpsIndication
;
LoRaMacPrimitives
.
MacMlmeConfirm
=
MlmeConfirm
;
LoRaMacCallbacks
.
GetBatteryLevel
=
BoardGetBatteryLevel
;
LoRaMacInitialization
(
&
LoRaMacPrimitives
,
&
LoRaMacCallbacks
);
mibReq
.
Type
=
MIB_ADR
;
mibReq
.
Param
.
AdrEnable
=
LORAWAN_ADR_ON
;
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
mibReq
.
Type
=
MIB_PUBLIC_NETWORK
;
mibReq
.
Param
.
EnablePublicNetwork
=
LORAWAN_PUBLIC_NETWORK
;
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
LoRaMacTestSetDutyCycleOn
(
LORAWAN_DUTYCYCLE_ON
);
SerialDisplayUpdateDutyCycle
(
LORAWAN_DUTYCYCLE_ON
);
LoRaMacChannelAdd
(
3
,
(
ChannelParams_t
)
LC4
);
LoRaMacChannelAdd
(
4
,
(
ChannelParams_t
)
LC5
);
LoRaMacChannelAdd
(
5
,
(
ChannelParams_t
)
LC6
);
LoRaMacChannelAdd
(
6
,
(
ChannelParams_t
)
LC7
);
LoRaMacChannelAdd
(
7
,
(
ChannelParams_t
)
LC8
);
LoRaMacChannelAdd
(
8
,
(
ChannelParams_t
)
LC9
);
LoRaMacChannelAdd
(
9
,
(
ChannelParams_t
)
LC10
);
mibReq
.
Type
=
MIB_RX2_DEFAULT_CHANNEL
;
mibReq
.
Param
.
Rx2DefaultChannel
=
(
Rx2ChannelParams_t
){
869525000
,
DR_3
};
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
mibReq
.
Type
=
MIB_RX2_CHANNEL
;
mibReq
.
Param
.
Rx2Channel
=
(
Rx2ChannelParams_t
){
869525000
,
DR_3
};
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
SerialDisplayUpdateActivationMode
(
OVER_THE_AIR_ACTIVATION
);
SerialDisplayUpdateAdr
(
LORAWAN_ADR_ON
);
SerialDisplayUpdatePublicNetwork
(
LORAWAN_PUBLIC_NETWORK
);
LoRaMacDownlinkStatus
.
DownlinkCounter
=
0
;
DeviceState
=
DEVICE_STATE_JOIN
;
break
;
switch
(
DeviceState
)
{
case
DEVICE_STATE_INIT
:
LoRaMacPrimitives
.
MacMcpsConfirm
=
McpsConfirm
;
LoRaMacPrimitives
.
MacMcpsIndication
=
McpsIndication
;
LoRaMacPrimitives
.
MacMlmeConfirm
=
MlmeConfirm
;
LoRaMacCallbacks
.
GetBatteryLevel
=
BoardGetBatteryLevel
;
LoRaMacInitialization
(
&
LoRaMacPrimitives
,
&
LoRaMacCallbacks
);
mibReq
.
Type
=
MIB_ADR
;
mibReq
.
Param
.
AdrEnable
=
LORAWAN_ADR_ON
;
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
mibReq
.
Type
=
MIB_PUBLIC_NETWORK
;
mibReq
.
Param
.
EnablePublicNetwork
=
LORAWAN_PUBLIC_NETWORK
;
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
LoRaMacTestSetDutyCycleOn
(
LORAWAN_DUTYCYCLE_ON
);
SerialDisplayUpdateDutyCycle
(
LORAWAN_DUTYCYCLE_ON
);
LoRaMacChannelAdd
(
3
,
(
ChannelParams_t
)
LC4
);
LoRaMacChannelAdd
(
4
,
(
ChannelParams_t
)
LC5
);
LoRaMacChannelAdd
(
5
,
(
ChannelParams_t
)
LC6
);
LoRaMacChannelAdd
(
6
,
(
ChannelParams_t
)
LC7
);
LoRaMacChannelAdd
(
7
,
(
ChannelParams_t
)
LC8
);
LoRaMacChannelAdd
(
8
,
(
ChannelParams_t
)
LC9
);
LoRaMacChannelAdd
(
9
,
(
ChannelParams_t
)
LC10
);
mibReq
.
Type
=
MIB_RX2_DEFAULT_CHANNEL
;
mibReq
.
Param
.
Rx2DefaultChannel
=
(
Rx2ChannelParams_t
){
869525000
,
DR_3
};
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
mibReq
.
Type
=
MIB_RX2_CHANNEL
;
mibReq
.
Param
.
Rx2Channel
=
(
Rx2ChannelParams_t
){
869525000
,
DR_3
};
LoRaMacMibSetRequestConfirm
(
&
mibReq
);
SerialDisplayUpdateActivationMode
(
OVER_THE_AIR_ACTIVATION
);
SerialDisplayUpdateAdr
(
LORAWAN_ADR_ON
);
SerialDisplayUpdatePublicNetwork
(
LORAWAN_PUBLIC_NETWORK
);
LoRaMacDownlinkStatus
.
DownlinkCounter
=
0
;
case
DEVICE_STATE_JOIN
:
MlmeReq_t
mlmeReq
;
DeviceState
=
DEVICE_STATE_JOIN
;
return
false
;
mlmeReq
.
Type
=
MLME_JOIN
;
case
DEVICE_STATE_JOIN
:
MlmeReq_t
mlmeReq
;
mlmeReq
.
Req
.
Join
.
DevEui
=
DevEui
;
mlmeReq
.
Req
.
Join
.
AppEui
=
AppEui
;
mlmeReq
.
Req
.
Join
.
AppKey
=
AppKey
;
mlmeReq
.
Req
.
Join
.
NbTrials
=
100
;
mlmeReq
.
Type
=
MLME_JOIN
;
if
(
NextTx
==
true
)
{
LoRaMacMlmeRequest
(
&
mlmeReq
)
;
}
mlmeReq
.
Req
.
Join
.
DevEui
=
DevEui
;
mlmeReq
.
Req
.
Join
.
AppEui
=
AppEui
;
mlmeReq
.
Req
.
Join
.
AppKey
=
AppKey
;
mlmeReq
.
Req
.
Join
.
NbTrials
=
100
;
if
(
NextTx
==
true
)
{
LoRaMacMlmeRequest
(
&
mlmeReq
);
}
DeviceState
=
DEVICE_STATE_SEND
;
DeviceState
=
DEVICE_STATE_SEND
;
IsNetworkJoinedStatusUpdate
=
true
;
break
;
IsNetworkJoinedStatusUpdate
=
true
;
return
false
;
case
DEVICE_STATE_SEND
:
if
(
NextTx
==
true
)
{
SerialDisplayUpdateUplinkAcked
(
false
);
SerialDisplayUpdateDonwlinkRxData
(
false
);
PrepareTxFrame
(
AppPort
);
case
DEVICE_STATE_SEND
:
if
(
NextTx
==
true
)
{
SerialDisplayUpdateUplinkAcked
(
false
);
SerialDisplayUpdateDonwlinkRxData
(
false
);
NextTx
=
SendFrame
();
}
DeviceState
=
DEVICE_STATE_CYCLE
;
break
;
NextTx
=
SendFrame
();
}
DeviceState
=
DEVICE_STATE_CYCLE
;
return
false
;
case
DEVICE_STATE_CYCLE
:
DeviceState
=
DEVICE_STATE_SLEEP
;
break
;
case
DEVICE_STATE_CYCLE
:
DeviceState
=
DEVICE_STATE_SLEEP
;
return
false
;
case
DEVICE_STATE_SLEEP
:
// Wake up through events
standby_mode
(
T_sleep
);
break
;
case
DEVICE_STATE_SLEEP
:
// Wake up through events
return
true
;
default:
DeviceState
=
DEVICE_STATE_INIT
;
break
;
}
default:
DeviceState
=
DEVICE_STATE_INIT
;
return
false
;
}
}
// main
}
void
SerialDisplayRefresh
(
void
)
{
...
...
@@ -294,62 +294,131 @@ void SerialRxProcess (void)
}
}
static
void
PrepareTxFrame
(
uint8_t
port
)
int16_t
Round
(
float
number
)
{
switch
(
port
)
{
case
15
:
{
int
temp1
,
humi1
,
temp2
,
humi2
,
temp3
,
humi3
;
sensor1
.
update
();
sensor2
.
update
();
sensor3
.
update
();
AppData
[
0
]
=
1
;
if
(
IsTxConfirmed
==
true
)
{
temp1
=
(
int
)
(
sensor1
.
readTemperature
()
*
10.0
);
// Temperature - Air 1
humi1
=
(
int
)
(
sensor1
.
readHumidity
());
// Humidity - Air 1
temp2
=
(
int
)
(
sensor2
.
readTemperature
()
*
10.0
);
// Temperature - Air 2
humi2
=
(
int
)
(
sensor2
.
readHumidity
());
// Humidity - Air 2
temp3
=
(
int
)
(
sensor3
.
getTemperature
()
*
10.0
);
// Temperature - Sol
humi3
=
(
int
)
(
sensor3
.
getHumidity
());
// Humidity - Sol
// Temperature roof
AppData
[
1
]
=
(
temp1
>>
8
);
AppData
[
2
]
=
(
uint8_t
)
temp1
;
// Humidity roof
AppData
[
3
]
=
2
;
AppData
[
4
]
=
(
uint8_t
)
humi1
;
// Temperature ground
AppData
[
5
]
=
12
;
AppData
[
6
]
=
(
temp2
>>
8
);
AppData
[
7
]
=
(
uint8_t
)
temp2
;
// Humidity ground
AppData
[
8
]
=
26
;
AppData
[
9
]
=
(
uint8_t
)
humi2
;
if
(
number
>
255.0
)
return
0
;
int16_t
result
=
(
int16_t
)
number
;
return
result
+
(
((
number
-
result
)
*
10
)
>
5
);
}
int16_t
RoundT
(
float
number
)
{
if
(
number
>
3276.5
||
number
<
-
3276.5
)
return
0
;
number
*=
10.0
;
int16_t
result
=
(
int16_t
)
number
;
int16_t
decimal
=
(
(
number
>
0
)
?
(((
number
-
result
)
*
10
)
>
5
)
:
-
(((
number
-
result
)
*
10
)
<
-
5
)
);
return
result
+
decimal
;
}
// Temperature uderground
AppData
[
10
]
=
25
;
AppData
[
11
]
=
(
temp3
>>
8
);
AppData
[
12
]
=
(
uint8_t
)
temp3
;
static
void
PrepareTxFrame
(
uint8_t
port
)
{
sensor1
.
update
();
sensor2
.
update
();
sensor3
.
update
();
uint16_t
mesures
[
6
]
=
{
RoundT
(
sensor1
.
readTemperature
());
RoundT
(
sensor2
.
readTemperature
());
RoundT
(
sensor3
.
getTemperature
());
Round
(
sensor1
.
readHumidity
());
Round
(
sensor2
.
readHumidity
());
Round
(
sensor3
.
getHumidity
());
};
if
(
port
==
15
)
{
uint32_t
temp
=
0x00000000U
;
uint32_t
mesure_pointer
=
0
;
// Humidity underground
AppData
[
13
]
=
27
;
AppData
[
14
]
=
(
uint8_t
)
humi3
;
}
mesure_pointer
=
read_RTC_bkp_reg
(
BKP4
);
mesure_pointer
=
((
mesure_pointer
>>
16
)
&
0xFF
);
// retrieve le 3rd byte from BKP4
switch
(
mesure_pointer
)
{
case
0
:
refresh_RTC_bkp_reg
();
// refresh all the BKPx registers so that they cant't lose their previous data
for
(
int
i
=
0
;
i
<
2
;
i
++
)
temp
|=
((
mesures
[
i
]
&
0xFFFFU
)
<<
(
i
*
16
));
write_RTC_bkp_reg
(
BKP0
,
temp
);
temp
=
0
;
temp
|=
((
mesures
[
2
]
&
0xFFFFU
)
|
((
mesures
[
3
]
&
0xFFU
)
<<
16
)
|
((
mesures
[
4
]
&
0xFFU
)
<<
24
));
write_RTC_bkp_reg
(
BKP1
,
temp
);
mesure_pointer
++
;
temp
=
0
;
temp
|=
((
mesures
[
5
]
&
0xFFU
)
|
((
mesure_pointer
&
0xFFU
)
<<
16
));
write_RTC_bkp_reg
(
BKP4
,
temp
);
break
;
case
1
:
refresh_RTC_bkp_reg
();
// refresh all the BKPx registers so that they cant't lose their previous data
for
(
int
i
=
0
;
i
<
2
;
i
++
)
temp
|=
((
mesures
[
i
]
&
0xFFFFU
)
<<
(
i
*
16
));
write_RTC_bkp_reg
(
BKP2
,
temp
);
temp
=
0
;
temp
|=
((
mesures
[
2
]
&
0xFFFFU
)
|
((
mesures
[
3
]
&
0xFFU
)
<<
16
)
|
((
mesures
[
4
]
&
0xFFU
)
<<
24
));
write_RTC_bkp_reg
(
BKP3
,
temp
);
mesure_pointer
++
;
temp
=
read_RTC_bkp_reg
(
BKP4
);
temp
&=
0xFFU
;
// we keep the first BYTE (humi3 from mesure 1)
temp
|=
(((
mesures
[
5
]
&
0xFFU
)
<<
8
)
|
((
mesure_pointer
&
0xFFU
)
<<
16
));
write_RTC_bkp_reg
(
BKP4
,
temp
);
break
;
case
2
:
int16_t
mesures_to_send
[
12
+
6
];
// 2 previous mesures + the current one
temp
=
read_RTC_bkp_reg
(
BKP0
);
for
(
int
i
=
0
;
i
<
2
;
i
++
)
mesures_to_send
[
i
]
=
(
int16_t
)((
temp
>>
(
i
*
16
))
&
0xFFFFU
);
temp
=
read_RTC_bkp_reg
(
BKP1
);
mesures_to_send
[
2
]
=
(
int16_t
)(
temp
&
0xFFFFU
);
// temp3
mesures_to_send
[
3
]
=
(
int16_t
)((
temp
>>
16
)
&
0xFFU
);
// humi1
mesures_to_send
[
4
]
=
(
int16_t
)((
temp
>>
24
)
&
0xFFU
);
// humi2
temp
=
read_RTC_bkp_reg
(
BKP2
);
for
(
int
i
=
0
;
i
<
2
;
i
++
)
mesures_to_send
[
i
+
6
]
=
(
int16_t
)((
temp
>>
(
i
*
16
))
&
0xFFFFU
);
temp
=
read_RTC_bkp_reg
(
BKP3
);
mesures_to_send
[
8
]
=
(
int16_t
)(
temp
&
0xFFFFU
);
// temp3
mesures_to_send
[
9
]
=
(
int16_t
)((
temp
>>
16
)
&
0xFFU
);
// humi1
mesures_to_send
[
10
]
=
(
int16_t
)((
temp
>>
24
)
&
0xFFU
);
// humi2
temp
=
read_RTC_bkp_reg
(
BKP4
);
mesures_to_send
[
5
]
=
(
int16_t
)(
temp
&
0xFFU
);
// humi3 of mesure 1
mesures_to_send
[
11
]
=
(
int16_t
)((
temp
>>
8
)
&
0xFFU
);
// humi3 of mesure 2
for
(
int
i
=
12
;
i
<
18
;
i
++
)
mesures_to_send
[
i
]
=
mesures
[
i
-
12
];
// reset the registers
reset_RTC_bkp_reg
();
for
(
int
i
=
0
;
i
<
45
;
i
++
)
AppData
[
i
]
=
0
;
// clear buffer
int
j
=
0
;
// payload index
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
AppData
[
j
++
]
|=
0x01
;
// identifier - Temperature roof
AppData
[
j
++
]
|=
(
mesures_to_send
[
0
+
6
*
i
]
>>
8
)
&
0xFF
;
// Temperature roof MSB
AppData
[
j
++
]
|=
(
mesures_to_send
[
0
+
6
*
i
])
&
0xFF
;
// Temperature roof LSB
AppData
[
j
++
]
|=
0x0C
;
// identifier - Temperature ground
AppData
[
j
++
]
|=
(
mesures_to_send
[
1
+
6
*
i
]
>>
8
)
&
0xFF
;
// Temperature ground MSB
AppData
[
j
++
]
|=
(
mesures_to_send
[
1
+
6
*
i
])
&
0xFF
;
// Temperature ground LSB
AppData
[
j
++
]
|=
0x19
;
// identifier - Temperature underground
AppData
[
j
++
]
|=
(
mesures_to_send
[
2
+
6
*
i
]
>>
8
)
&
0xFF
;
// Temperature underground MSB
AppData
[
j
++
]
|=
(
mesures_to_send
[
2
+
6
*
i
])
&
0xFF
;
// Temperature underground LSB
AppData
[
j
++
]
|=
0x02
;
// identifier - Humidity roof
AppData
[
j
++
]
|=
(
mesures_to_send
[
3
+
6
*
i
]
&
0xFF
);
// Humidity roof
AppData
[
j
++
]
|=
0x1A
;
// identifier - Humidity ground
AppData
[
j
++
]
|=
(
mesures_to_send
[
4
+
6
*
i
]
&
0xFF
);
// Humidity ground
AppData
[
j
++
]
|=
0x1B
;
// identifier - Humidity underground
AppData
[
j
++
]
|=
(
mesures_to_send
[
5
+
6
*
i
]
&
0xFF
);
// Humidity underground
}
DeviceState
=
DEVICE_STATE_INIT
;
while
(
!
DeviceUpdate
());
break
;
default:
break
;
}
break
;
default:
break
;
}
}
// PrepareTxFrame
}
// PrepareTxFrame
static
bool
SendFrame
(
void
)
{
...
...
@@ -404,30 +473,6 @@ static bool SendFrame (void)
return
true
;
}
// SendFrame
static
void
OnTxNextPacketTimerEvent
(
void
)
{
MibRequestConfirm_t
mibReq
;
LoRaMacStatus_t
status
;
TimerStop
(
&
TxNextPacketTimer
);
mibReq
.
Type
=
MIB_NETWORK_JOINED
;
status
=
LoRaMacMibGetRequestConfirm
(
&
mibReq
);
if
(
status
==
LORAMAC_STATUS_OK
)
{
if
(
mibReq
.
Param
.
IsNetworkJoined
==
true
)
{
DeviceState
=
DEVICE_STATE_SEND
;
NextTx
=
true
;
}
else
{
DeviceState
=
DEVICE_STATE_JOIN
;
}
}
}
static
void
McpsConfirm
(
McpsConfirm_t
*
mcpsConfirm
)
{
if
(
mcpsConfirm
->
Status
==
LORAMAC_EVENT_INFO_STATUS_OK
)
...
...
@@ -661,7 +706,7 @@ static void McpsIndication (McpsIndication_t * mcpsIndication)
break
;
}
}
DownlinkStatusUpdated
=
true
;
}
// McpsIndication
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment