'============================================================================================
'============================================================================================
Private Sub btnWiFi_Click
If WiFiConnected = False Then
' mcuc.Initialize(Me, "shorttclock.local", 50000, 240000, 30000, 2000)
mcuc.Initialize(Me, "tiny_shark", 51010, 240000, 30000, 2000)
' mcuc.Initialize(Me, "192.168.1.132", 51010, 240000, 30000, 2000)
Dim host As String = GetHostName("192.168.1.132")
Log("Host = "& host)
Else
mcuc.socketClose
End If
End Sub
Public Sub connectToServer
Private clockSetData As clockSetData_t
Do While mcuSockConnStatus = False
setConnectionStatus(False)
netErrorTimer.Enabled = False
If tcpStream.IsInitialized Then
tcpStream.Close
End If
If mcu_socket.IsInitialized Then
mcu_socket.Close
End If
If mcu_socket.IsInitialized = False Then
mcu_socket.Initialize("mcu_socket")
mcu_socket.Connect(ipAddress, servPort, 0)
End If
Wait for mcu_socket_Connected(Successful As Boolean)
If Successful Then
#IF LOGGING_ON
Log("Socket Event - MCU Socket OK")
#END IF
If tcpStream.IsInitialized Then
tcpStream.Close
End If
setConnectionStatus(True)
Sleep(500) 'Allow time for the server to ack connection on the MCU Interface
If tcpStream.IsInitialized Then
tcpStream.Close
End If
Try
tcpStream.InitializePrefix(mcu_socket.InputStream, False, mcu_socket.OutputStream, "tcpStream")
setConnectionStatus(True)
clockSetData.clockMode = 0
clockSetData.jogValue = 0
clockSetData.jogRate = 0
CallSub2(Main,"mcucsendCmd",clockSetData)
Return
Catch
setConnectionStatus(False)
'TODO connectToServer
#IF MIN_LOGGING_ON Or LOGGING_ON
Log("TCP Stream Init Error")
#END IF
End Try
' Set the command timer on if cmd queue is empty so we send null cmd to MCU
mcuTranInProgress = False
Else
Sleep(500)
#IF MIN_LOGGING_ON Or LOGGING_ON
Log("Socket Event - MCU Socket Failed")
#END IF
End If
Loop
End Sub