Skip to main content
. 2024 Dec 21;24(24):8165. doi: 10.3390/s24248165
Algorithm 1. Image transmission algorithm.
//P(v): v’s downstream node
//C(v): v’s upstream node
//v.rch: v’s reception channel
//v.tch: v’s transmission channel
1    At GW://requests image from srcMN
2       broadcast IREQ = (srcMN, WSNpath, WSNChList, dCHm);

3    At node v that receives IREQ:
4    if v = srcMN then
5       curTime = systemTime();
6       set nextTxTimer = curTime + TxInt;
7       change myLoRaCh to dCHm;//channel switching
8       srcMN.tch = WSNChList [0];//takes the first channel
9       transmit iPacket on srcMN.tch using WSN;
10   else if v belongs to WSNpath then
11     turn on WSNmodule;
12     (v.rch, v.tch) = chMapping(v, WSNpath, WSNChList);
13     wait for iPacket on v.rch;
14   endif;

//Transmits iPackets at TxInt intervals
15   At srcMN that nextTxTimer expires:
16     curTime = systemTime();
17     set nextTxTimer = curTime + TxInt;
18     transmit iPacket on v.tch;
//Forwarding packet and waiting for new packet
19   At node v that receives iPacket from C(v):
20   transmit iPacket to P(v) on v.tch;
21   wait for iPacket on v.rch;

//myPos = index in WSNpath starting with 1
//WSNChList = list of three channels
22   function chMapping(v, WSNpath, WSNChList);
//myPos > 1 since v cannot be srcMN
23     myPos = findPos(v, WSNpath);
24     if myPos is even then//dedicated channel
25          k = (myPos/2 - 1) % 3;
26          v.rch = v.tch = WSNChList [k];
27     else//if odd
28          k = ((myPos − 1)/2 − 1) % 3;
29          v.rch = WSNChList[k];//upstream node ch
30          k = ((myPos + 1)/2 − 1) % 3;
31          v.tch = WSNChList [k];//downstream node ch
32     endif;
33     return (v.tch, v.rch);
34   endFunction