IsConnected logic

This commit is contained in:
2026-09-08 15:41:44 +01:00
parent 56c7081e8f
commit 1ad9dd4ab7
3 changed files with 27 additions and 14 deletions
+16 -1
View File
@@ -20,7 +20,6 @@ const (
IRSDK_BROADCASTMSGNAME string = "IRSDK_BROADCASTMSG"
fileMapSize uint32 = 1164 * 1024
connTimeout int64 = 30
stConnected int = 1
)
const (
@@ -117,6 +116,22 @@ const (
csFocusAtDriver int = 0 // ctFocusAtDriver + car number...
)
// StatusField - START
const (
irsdk_stConnected = 0x01
)
func (i *IBT) SessionStatusConnected() bool {
return i.Headers.Status == irsdk_stConnected
}
// NOTE: move this away from here
// func (i *IBT) SessionTimedOut() bool {
// return sdk.lastValidData+connTimeout > time.Now().Unix()
// }
// StatusField - END
// Camera positions
type bitfieldValue struct {
Value int
+11 -8
View File
@@ -59,16 +59,19 @@ type IBT struct {
}
func (i *IBT) IsConnected() bool {
if i.Headers != nil {
if sessionStatusOK(int(i.Headers.Status)) {
return true
}
// if sessionStatusOK(int(i.Headers.Status)) && (sdk.lastValidData+connTimeout > time.Now().Unix()) {
// return true
// }
if i.Headers == nil {
return false
}
return false
if !i.SessionStatusConnected() {
return false
}
if i.SessionStateInvalid() {
return false
}
return true
}
func (i *IBT) exportYAML() error {
-5
View File
@@ -370,11 +370,6 @@ func parseSessionInfo(buf []byte, len int32) (*SessionInfoYAML, error) {
return &sessionInfo, nil
}
// sessionStatusOK will tell us if we are connected to the live data
func sessionStatusOK(status int) bool {
return (status & stConnected) > 0
}
// ToString will return a readable string of the struct
func (s *SessionInfoYAML) ToString() string {
stringified, _ := json.MarshalIndent(s, "", " ")