@@ -103,23 +103,38 @@ func SdkapiHandler(w http.ResponseWriter, r *http.Request) {
103
103
fmt .Fprint (w , string (jsonBytes ))
104
104
return
105
105
case r .URL .Path == "/api-sdk/get_sdk_settings" :
106
- resp , err := robot .Conn .PullJdocs (ctx , & vectorpb.PullJdocsRequest {
107
- JdocTypes : []vectorpb.JdocType {vectorpb .JdocType_ROBOT_SETTINGS },
108
- })
109
- if err != nil {
110
- w .Write ([]byte (err .Error ()))
106
+ i := 0
107
+ for {
108
+ resp , err := robot .Conn .PullJdocs (ctx , & vectorpb.PullJdocsRequest {
109
+ JdocTypes : []vectorpb.JdocType {vectorpb .JdocType_ROBOT_SETTINGS },
110
+ })
111
+ if err != nil {
112
+ w .Write ([]byte (err .Error ()))
113
+ return
114
+ }
115
+ if strings .Contains (resp .NamedJdocs [0 ].Doc .JsonDoc , "BStat.ReactedToTriggerWord" ) {
116
+ time .Sleep (time .Second / 2 )
117
+ if i > 3 {
118
+ logger .Println ("Bot refuses to return RobotSettings jdoc..." )
119
+ logger .Println ("Returned Jdoc: " , resp .NamedJdocs [0 ].Doc .JsonDoc )
120
+ w .Write ([]byte ("error: bot refuses to return robotsettings" ))
121
+ return
122
+ }
123
+ i = i + 1
124
+ continue
125
+ }
126
+ json := resp .NamedJdocs [0 ].Doc .JsonDoc
127
+ var ajdoc vars.AJdoc
128
+ ajdoc .DocVersion = resp .NamedJdocs [0 ].Doc .DocVersion
129
+ ajdoc .FmtVersion = resp .NamedJdocs [0 ].Doc .FmtVersion
130
+ ajdoc .JsonDoc = resp .NamedJdocs [0 ].Doc .JsonDoc
131
+ vars .AddJdoc ("vic:" + robotObj .ESN , "vic.RobotSettings" , ajdoc )
132
+ logger .Println ("Updating vic.RobotSettings (source: sdkapp)" )
133
+ w .WriteHeader (http .StatusOK )
134
+ w .Header ().Set ("Content-Type" , "application/octet-stream" )
135
+ w .Write ([]byte (json ))
136
+ return
111
137
}
112
- json := resp .NamedJdocs [0 ].Doc .JsonDoc
113
- var ajdoc vars.AJdoc
114
- ajdoc .DocVersion = resp .NamedJdocs [0 ].Doc .DocVersion
115
- ajdoc .FmtVersion = resp .NamedJdocs [0 ].Doc .FmtVersion
116
- ajdoc .JsonDoc = resp .NamedJdocs [0 ].Doc .JsonDoc
117
- vars .AddJdoc ("vic:" + robotObj .ESN , "vic.RobotSettings" , ajdoc )
118
- logger .Println ("Updating vic.RobotSettings (source: sdkapp)" )
119
- w .WriteHeader (http .StatusOK )
120
- w .Header ().Set ("Content-Type" , "application/octet-stream" )
121
- w .Write ([]byte (json ))
122
- return
123
138
case r .URL .Path == "/api-sdk/time_format_12" :
124
139
setSettingSDKintbool (robotObj , "clock_24_hour" , "false" )
125
140
fmt .Fprintf (w , "done" )
0 commit comments