'*******************************************************************************************************************************************
'Class Module Callbacks *
'*******************************************************************************************************************************************
'Called by EdgeConnection. Any status generated by the EDGEConnection class will end up here.
Public Sub EDGEConnection_HandleStatus(Status As Int)
'0 = Connected and operating
'1 = Connection Error on MQTT Connect
'2 = MQTT has disconnected
'3 = Invalid scoreboard version
'4 = Timeout occured attempting to connect to the MQTT Server
'5 = Timeout occured from Scoreboard display handling commands
'6 = POST Error occured during connection to a physical scoreboard
'7 = Timeout occured during POST on a physical scoreboard
'8 = Invalid password supplied to scoreboard
Select Case Status
Case 0 'System up and operational
StatusCode = 2 'Set Status as operational
Case 1
StatusCode = 19 'MQTT Connection error
Case 2
StatusCode = 17 'Scoreboard disconnected.
Case 3
StatusCode = 20
Case 4
StatusCode = 19
Case 5
StatusCode = 3
Case 6
StatusCode = 4
Case 7
StatusCode = 21
Case 8
StatusCode = 6
End Select
If Connecting = True Then CallSubDelayed2(Me, "Status_Event", Status) 'Tell the pending HandleConnection to resume and handle the response.
End Sub
'Called from HMIConnection class. Power on/off events will fire this.
'Connect = true when powering on. False when powering off.
Public Sub HMIConnection_HandleConnection(Connect As Boolean) As ResumableSub
Dim StatusCode As Int
If Connect = True Then 'We are connecting to the scoreboard display
Connecting = True
EDGE.Connect 'Connect to the Display/Scoreboard instance
Wait For Status_Event (Response As Int) 'Wait for something forwarded from EDGEConnection_HandleStatus
Connecting = False
Return Response
Else 'We are disconnecting from the scoreboard display
Connecting = False
Wait For (EDGE.Disconnect) Complete (Result As Boolean) 'Disconnect from the scoreboard.
StatusCode = 17
Return 255 'Send a random response from a disconnect, as it doesn't really matter the state of the system
End If
End Sub