2 * Copyright (C) 2018 "IoT.bzh"
3 * Author Sebastien Douheret <sebastien@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
24 // TargetType definition
25 type TargetType string
28 // TypeTgtStandard Standard target type
29 TypeTgtStandard = "standard"
32 // Target Status definition
34 StatusTgtErrorConfig = "ErrorConfig"
35 StatusTgtDisable = "Disable"
36 StatusTgtEnable = "Enable"
39 // TargetConfig config of a target / board
40 type TargetConfig struct {
42 Name string `json:"name"`
43 Type TargetType `json:"type"`
45 Status string `json:"status"`
46 Terms []TerminalConfig `json:"terms"`
53 // TerminalType definition
54 type TerminalType string
57 // TypeTermSSH ssh terminal type
60 // StatusTermErrorConfig Configuration error
61 StatusTermErrorConfig = "ErrorConfig"
62 // StatusTermEnable Enable state
63 StatusTermEnable = "Enable"
64 // StatusTermOpen Open state
65 StatusTermOpen = "Open"
66 // StatusTermClose Close state
67 StatusTermClose = "Close"
68 // StatusTermClosing Closing state
69 StatusTermClosing = "Closing"
71 // TerminalInEvent Event send in WS when characters are sent (stdin)
72 TerminalInEvent = "term:input"
73 // TerminalOutEvent Event send in WS when characters are received (stdout or stderr)
74 TerminalOutEvent = "term:output"
75 // TerminalExitEvent Event send in WS on terminal/console exit
76 TerminalExitEvent = "term:exit"
81 // TerminalConfig config of a board terminal
82 TerminalConfig struct {
84 Name string `json:"name"`
85 Type TerminalType `json:"type"`
86 User string `json:"user"`
87 Options []string `json:"options"`
88 Status string `json:"status"`
89 Cols uint16 `json:"cols"`
90 Rows uint16 `json:"rows"`
93 // TerminalInMsg Message used to received input characters (stdin)
94 TerminalInMsg struct {
95 TermID string `json:"termID"`
96 Timestamp string `json:"timestamp"`
97 Stdin string `json:"stdin"`
100 // TerminalOutMsg Message used to send output characters (stdout+stderr)
101 TerminalOutMsg struct {
102 TermID string `json:"termID"`
103 Timestamp string `json:"timestamp"`
104 Stdout []byte `json:"stdout"`
105 Stderr []byte `json:"stderr"`
108 // TerminalExitMsg Message sent on terminal/console exit
109 TerminalExitMsg struct {
110 TermID string `json:"termID"`
111 Timestamp string `json:"timestamp"`
112 Code int `json:"code"`
113 Error error `json:"error"`
116 // TerminalResizeArgs JSON parameters of /terminal/:tid/resize command
117 TerminalResizeArgs struct {
118 Cols uint16 `json:"cols"`
119 Rows uint16 `json:"rows"`
122 // TerminalSignalArgs JSON parameters of /terminal/:tid/signal command
123 TerminalSignalArgs struct {
124 Signal string `json:"signal" binding:"required"` // signal number