-
Notifications
You must be signed in to change notification settings - Fork 2
/
command.go
152 lines (133 loc) · 4.9 KB
/
command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package goprowifi
import (
"errors"
"fmt"
)
// sendCommand basic handler to send all commands
func (g *Client) sendCommand(commandURL string) (httpStatus int, err error) {
bodyBytes, httpStatus, err := g.request(commandURL)
if err != nil {
err = fmt.Errorf("Can't unmarshal retrieve response %s %s", err, string(bodyBytes))
}
return
}
// CaptureStart operate the shutter Shutter
// Shutter
// Trigger: http://10.5.5.9/gp/gpControl/command/shutter?p=1
func (g *Client) CaptureStart() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/shutter?p=1")
if status != 200 {
err = errors.New("error starting starting capture")
}
return
}
// CaptureStop operate the shutter Shutter
// Shutter
// Stop (Video/Timelapse): http://10.5.5.9/gp/gpControl/command/shutter?p=0
func (g *Client) CaptureStop() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/shutter?p=0")
if status != 200 {
err = errors.New("error stopping starting capture")
}
return
}
// ModeVideo sets mode to Video (VIDEO)
// Video (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=0
func (g *Client) ModeVideo() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=0")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModeVideoTimeLapse sets mode to TimeLapse Video (VIDEO)
// TimeLapse Video (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=1
func (g *Client) ModeVideoTimeLapse() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=1")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModeVideoPhoto sets mode to Video + Photo (VIDEO)
// Video + Photo (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=2
func (g *Client) ModeVideoPhoto() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=2")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModeVideoLooping sets mode to Looping (VIDEO)
// Looping (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=3
func (g *Client) ModeVideoLooping() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=3")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModePhotoSingle sets mode to Single (PHOTO)
// Single (PHOTO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=1&sub_mode=1
func (g *Client) ModePhotoSingle() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=1&sub_mode=1")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModePhotoNight sets mode to Night (PHOTO)
// Night (PHOTO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=1&sub_mode=2
func (g *Client) ModePhotoNight() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=1&sub_mode=2")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModeMultiShotBurst sets mode to Burst (MultiShot)
// Burst (MultiShot): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=0
func (g *Client) ModeMultiShotBurst() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=0")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModeMultiShotTimelapse sets mode to Timelapse (MultiShot)
// Timelapse (MultiShot): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=1
func (g *Client) ModeMultiShotTimelapse() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=1")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// ModeMultiShotNightLapse sets mode to NightLapse (MultiShot)
// NightLapse (MultiShot): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=2
func (g *Client) ModeMultiShotNightLapse() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=2")
if status != 200 {
err = errors.New("error changing operation modes")
}
return
}
// TagMoment add highlight tag
// Sends tag command: http://10.5.5.9/gp/gpControl/command/storage/tag_moment
func (g *Client) TagMoment() (err error) {
status, err := g.sendCommand("http://10.5.5.9/gp/gpControl/command/storage/tag_moment")
if status != 200 {
err = errors.New("error tagging highlight")
}
return
}
// http://10.5.5.9/gp/gpControl/command/mode?p=3
// {
// "version": "5.00",
// "path_info": "command/mode",
// "query_string": "p=3",
// "error_code": -1,
// "error_msg": "500 Internal Server Error\r\n",
// "function": "gpcontrol_cgi_handler",
// "line": 186
// }