Skip to content

Commit

Permalink
- Update documentation
Browse files Browse the repository at this point in the history
- Working on LoRaWAN FUOTA
  • Loading branch information
Kampi committed Jun 20, 2023
1 parent ed72f71 commit 01bfc19
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 212 deletions.
11 changes: 9 additions & 2 deletions examples/ClockSynchronization/TimeServer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class States(Enum):
Parser.add_argument("-lp", "--lora-port", type = int, help = "LoRaWAN port", default = 202)
Parser.add_argument("-mp", "--mqtt-port", type = int, help = "MQTT port", default = 8583)
Parser.add_argument("-gp", "--grpc-port", type = int, help = "GRPC port", default = 8580)
Parser.add_argument("-n", "--number", type = int, help = "Number of clock sync force transmission (<= 7)", default = 7)
Parser.add_argument("-g", "--group", type = int, help = "Multicast group used", default = 0)
Parser.add_argument("-d", "--deveui", type = str, help = "Device EUI", default = "ac1f09fffe071978")
Parser.add_argument("-mc", "--multi", help = "Set to use multicast instead of a unicast (default)", action = "store_true")
Expand Down Expand Up @@ -61,6 +62,9 @@ def UnicastSend(Data, DevEUI, Port):

LogDirectory = args.log + os.path.os.sep + "Update-Logs"

if(args.number > 7):
Parser.error("Maximum number of forced transmissions is 7!")

if(not(os.path.exists(LogDirectory))):
os.makedirs(LogDirectory)
logging.basicConfig(filename = LogDirectory + os.path.sep + "{}.log".format(dt.now().strftime("%Y%d%m")), level = logging.INFO, format = "%(asctime)-15s :: %(name)-20s :: %(message)-15s")
Expand Down Expand Up @@ -159,14 +163,17 @@ def UnicastSend(Data, DevEUI, Port):
# Byte 4: Param
# Bits 0-3: TokenAns
# Bits 4-7: RFU
# Byte 3: FragSize
Data.append(1)
Data.append((Seconds >> 0) & 0xFF)
Data.append((Seconds >> 8) & 0xFF)
Data.append((Seconds >> 16) & 0xFF)
Data.append((Seconds >> 24) & 0xFF)
Data.append(Param)
MulticastSend(Data, args.lora_port)

if(args.multi):
MulticastSend(Data, args.lora_port)
else:
UnicastSend(Data, args.deveui, args.lora_port)

CurrentState = States.STATE_WAIT.value

Expand Down
2 changes: 0 additions & 2 deletions examples/FUOTA/UpdateServer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
TODO:
- Header transmission
- Clock synchronization
- FLush the gateway queue before start
'''

class States(Enum):
Expand Down Expand Up @@ -143,7 +142,6 @@ def UnicastSend(Data, DevEUI, Port):
FragmentationProv = Fragmentation.Fragmentation(args.input, args.length, args.redundancy)
FragmentationProv.WriteToFile(os.path.splitext(args.input)[0] + "_coded" + os.path.splitext(args.input)[1])
FragmentList = FragmentationProv.GetFragments()
FragmentList = FragmentList[:2]

CurrentState = States.STATE_CHECK_VERSION.value

Expand Down
Binary file modified examples/FUOTA/UpdateServer/files/Input.bin
Binary file not shown.
Binary file modified examples/FUOTA/UpdateServer/files/Input_coded.bin
Binary file not shown.
9 changes: 0 additions & 9 deletions examples/FUOTA/__old__/CreateBinary.py

This file was deleted.

Binary file removed examples/FUOTA/__old__/Input.bin
Binary file not shown.
Binary file removed examples/FUOTA/__old__/Input_coded.bin
Binary file not shown.
98 changes: 0 additions & 98 deletions examples/FUOTA/__old__/UpdateServer.py

This file was deleted.

27 changes: 27 additions & 0 deletions include/Modes/LoRaWAN/rak3172_lorawan_clock_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,31 @@ RAK3172_Error_t RAK3172_LoRaWAN_Clock_SetLocalTime(RAK3172_t& p_Device, struct t
*/
RAK3172_Error_t RAK3172_LoRaWAN_ClockSync_PackageVersion(RAK3172_t& p_Device);

/** @brief Check if the server has requested a force resync.
* @param p_Device RAK3172 device object
* @param p_NbTransmissions Pointer to requested transmissions
* @param p_Group (Optional) Use a multicast group instead of a unicast
* @param Timeout (Optional) Response timeout from the server in seconds
* @return #true when the server as requested a force resync
* #false otherwise
*/
bool RAK3172_LoRaWAN_ClockSync_isForceResync(RAK3172_t& p_Device, uint8_t* p_NbTransmissions, RAK3172_MC_Group_t* p_Group = NULL, uint32_t Timeout = 3);

/** @brief Handle an app time periodicity request.
* @param p_Device RAK3172 device object
* @param p_Period Period encodes the periodicity of the AppTimeReq transmissions. The actual periodicity in \n
* seconds is 128.2^Period +- rand(30) where rand(30) is a random integer in the +/-30sec \n
* range varying with each transmission.
* @param Time (Optional) Time is the current end-device’s clock time captured immediately before the transmission of the radio message.
* NOTE: Only neccessary when \ref NotSupported is set to #false
* @param NotSupported (Optional) Set to #true to disable the fuction on this device
* @param Timeout (Optional) Response timeout from the server in seconds
* @return RAK3172_ERR_OK when successful
* RAK3172_ERR_FAIL when the response can not be send
* RAK3172_ERR_INVALID_MODE when the device does not operate in LoRaWAN mode
* RAK3172_ERR_WRONG_PORT when the request was received on the wrong port
* RAK3172_ERR_INVALID_ARG when the server has transmitted an invalid request
*/
RAK3172_Error_t RAK3172_LoRaWAN_ClockSync_HandlePeriodicity(RAK3172_t& p_Device, uint8_t* p_Period, uint32_t Time = 0, bool NotSupported = false, uint32_t Timeout = 3);

#endif /* RAK3172_LORAWAN_CLOCK_SYNC_H_ */
2 changes: 1 addition & 1 deletion include/Modes/LoRaWAN/rak3172_lorawan_fuota.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
* RAK3172_ERR_INVALID_STATE when the interface is not initialized
* RAK3172_ERR_INVALID_MODE when the device is not initialized as LoRaWAN device. Please call \ref RAK3172_LoRaWAN_Init first
*/
RAK3172_Error_t RAK3172_FUOTA_Run(RAK3172_t& p_Device, RAK3172_MC_Group_t* p_Group = NULL, uint32_t Timeout = 10);
RAK3172_Error_t RAK3172_LoRaWAN_FUOTA_Run(RAK3172_t& p_Device, RAK3172_MC_Group_t* p_Group = NULL, uint32_t Timeout = 10);

#endif /* RAK3172_LORAWAN_FUOTA_H_ */
Loading

0 comments on commit 01bfc19

Please sign in to comment.