## 4 Proposed Methodologies
### Network-Switching Policy  
As mentioned previously, OCC is a strictly directional LOS technology. If the LOS path of the light signal is blocked, the communication is terminated. Thus, efficient handover between OCC and BLE is required. Network switching is unnecessary in static user scenarios (e.g., patients who are unconscious and/or being transported in ambulances) but necessary when the patient is mobile, because the OCC performance remarkably depends on the LOS Euclidean distance between the LED and camera. The BLE performance is also influenced by user mobility. Efficient handover is thus required for reliable data transmission.  
\(d_{\alpha,\beta}\) varies with the patient's movement. The signal-blockage probability should be considered as it hampers the OCC performance. In addition, when changing the \(d_{\alpha,\beta}\), the SS changes as well, consequently triggering the possibilities for the LED to be projected inside the image sensor with a number of strips below \(\Gamma_{crit}\). The network-switching procedure from OCC to BLE is summarized in Algorithm 3. When \(d_{\alpha,\beta}\) is changed, \(\Gamma\) of the current camera is immediately compared with the threshold. The communication with the current camera is continued if \(\Gamma\) is above \(\Gamma_{crit}\). Otherwise, its \(\lambda\) is compared with the other cameras that simultaneously detect the LED. The camera with the highest \(\lambda\) will be acceptable for communication. However, if no camera can meet the \(\Gamma_{crit}\) requirement, the network will be switched to BLE.  
Figure 5: Considered indoor scenario for the selection mechanism.  
```
1. O2B_Handover ()
2. Initialization: Communication with camera is in progress;
3. Begin
4. ifd\({}_{\alpha,\beta}\) is changed then
5. if\(\Gamma<\Gamma_{\text{crit}}\)then
6. Initiation of neighboring cameras;
7. if\(\xi>1\)then
8. for\(j=1;j<\xi\)
9. if\(\lambda(1)>\lambda(j)\)then
10. Accept BLE;
11. Set \(\lambda(j)=\lambda(1)\);
12. Set \(j=j+1\);
13. elseif\(\Gamma(j)>\Gamma_{\text{crit}}\)
14. Accept Camera (j);
15. Set \(\lambda(j)=\lambda(1)\);
16. Set \(j=j+1\);
17. else
18. Accept BLE;
19. Set \(j=j+1\);
20. endif
21. endfor
22. else
23. Accept BLE;
24. endif
25. else
26. Continue communication with Camera (1);
27. endif
28. else
29. Continue communication with Camera (1);
30. endif
31. End
```  
**Algorithm 3**Network-switching algorithm from OCC to BLE.  
When the BLE transmitter is activated in the patch circuit, the room cameras are reinitiated at the next change of d\({}_{\alpha,\beta}\). If any camera detects the LED, its \(\Gamma\) is immediately compared with \(\Gamma_{\text{crit}}\). If the compared \(\Gamma\) is below \(\Gamma_{\text{crit}}\), the BLE transmission continues; otherwise, it is replaced by the camera monitoring. If the LED is detected by more than one camera, the \(\lambda\) values of all the in-range cameras are compared, and the network communication switches to the camera with the highest \(\lambda\). Algorithm 4 summarizes the network switching strategy from BLE to OCC.  
```
1. B2O_Handover ()
2. Initialization: Communication with BLE is in progress;
3.ifd\({}_{\alpha,\beta}\) is changed then
4. Initiation of room cameras;
5.forj = 1, j! \(\xi\)
6.ifCamera (j) detect LED then
7.ifI(j)? \(\Gamma_{\text{crit}}\)then
8. Select Camera (j);
9.if\(\lambda(\text{j})>\lambda(\text{j}+1)\)then
10. Accept Camera (j);
11. Set j = j + 1;
12.else
13. Accept Camera (j+1);
14. Set j = j + 1;
15.endif
16.else
17. Set j = j + 1;
18.endif
19. Set j = j + 1;
20.else
21. Continue communication using BLE;
22.endif
23.endfor
24.else
25. Continue communication using BLE;
26.endif
27.End
```  
**Algorithm 4**Network switching algorithm BLE to OCC.