goprocam 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/GoPro.rb +188 -0
  3. data/lib/constants.rb +489 -0
  4. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 547c5d03c5c2d0e6fcdbabf4fd6a58c925fe29fd
4
+ data.tar.gz: 213a1c890fcb87ed2a3048f6c6696b6e77c1344b
5
+ SHA512:
6
+ metadata.gz: d3ca736b50f63e0c79288f0f083661041c2652892f7d6b718779d8c634d70f37460c512a7ee901c97434096d1d9ef20f57f973d07a4a08f608561c1a98662584
7
+ data.tar.gz: 5cb851b3152c892502a7396fb1ecffad49d56a1a3090f4d60ec8b8a625cd4fafeddd473bc22046b11fb6deb0d02ef2e8592c8d520235e67beb204a3a678831cb
data/lib/GoPro.rb ADDED
@@ -0,0 +1,188 @@
1
+ require 'open-uri'
2
+ require 'socket'
3
+ require 'json'
4
+ GPIP = "10.5.5.9"
5
+ GOPROCONTROL = "http://10.5.5.9/gp/gpControl/"
6
+ GOPROMEDIA = "http://10.5.5.9/gp/gpMediaList/"
7
+ class Camera
8
+ def initialize()
9
+ end
10
+ def gpControlCommand(param,value)
11
+ response = open(GOPROCONTROL + 'setting/' + param + '/' + value).read
12
+ puts response
13
+ end
14
+
15
+ def status_raw()
16
+ response = open(GOPROCONTROL + 'status').read
17
+ puts response
18
+ end
19
+
20
+ def status(value, param)
21
+ response = open(GOPROCONTROL + 'status').read
22
+ parsed_resp = JSON.parse(response)
23
+ return parsed_resp[value][param]
24
+ end
25
+ def info_camera(option)
26
+ response = open(GOPROCONTROL + 'info').read
27
+ parsed_resp = JSON.parse(response)
28
+ return parsed_resp["info"][option]
29
+ end
30
+ def overview()
31
+ puts "camera overview"
32
+ puts "current mode: ", status(Status::Status, Status::STATUS::Mode)
33
+ puts "current submode: ", status(Status::Status, Status::STATUS::SubMode)
34
+ puts "pictures taken: ", status(Status::Status, Status::STATUS::PhotosTaken)
35
+ puts "videos taken: ", status(Status::Status, Status::STATUS::VideosTaken)
36
+ puts "videos left: ", status(Status::Status, Status::STATUS::RemVideoTime)
37
+ puts "pictures left: ", status(Status::Status, Status::STATUS::RemPhotos)
38
+ puts "camera SSID: ", status(Status::Status, Status::STATUS::CamName)
39
+ puts "Is Recording:", status(Status::Status, Status::STATUS::IsRecording)
40
+ puts "camera model: ", info_camera(Camera::Name)
41
+ puts "firmware version: ", info_camera(Camera::Firmware)
42
+ end
43
+ def shutter(value)
44
+ response = open(GOPROCONTROL + 'command/shutter?p=' + value).read
45
+ puts response
46
+ end
47
+ def take_photo()
48
+ if status(Status::Status, Status::STATUS::IsRecording) == "1"
49
+ shutter(Shutter::OFF)
50
+ end
51
+ camera_mode(Mode::PhotoMode)
52
+ shutter(Shutter::ON)
53
+ end
54
+ def camera_mode(mode, submode="0")
55
+ response = open(GOPROCONTROL + 'command/sub_mode?mode=' + mode + '&sub_mode=' + submode).read
56
+ puts response
57
+ end
58
+
59
+ def delete(option)
60
+ response = open(GOPROCONTROL + 'command/storage/delete/' + option).read
61
+ puts response
62
+ end
63
+
64
+ def delete_file(folder,file)
65
+ response = open(GOPROCONTROL + 'command/storage/delete?p=' + folder + "/" + file).read
66
+ puts response
67
+ end
68
+
69
+ def locate(param)
70
+ response = open(GOPROCONTROL + 'command/system/locate?p=' + param).read
71
+ puts response
72
+ end
73
+
74
+ def hilight()
75
+ response = open(GOPROCONTROL + 'command/storage/tag_moment').read
76
+ puts response
77
+ end
78
+
79
+ def power_off()
80
+ response = open(GOPROCONTROL + 'command/system/sleep').read
81
+ puts response
82
+ end
83
+ UDPSock = UDPSocket.new
84
+ def power_on()
85
+ begin
86
+ addr = ['<broadcast>', 9]
87
+
88
+ UDPSock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
89
+ data = "\xFF\xFF\xFF\xFF\xFF\xFF"
90
+ arr = "AA:BB:CC:DD:EE:FF" #actually works, replace if needed.
91
+ 16.times do |i|
92
+ data<< arr[0].hex.chr+arr[1].hex.chr+arr[2].hex.chr+arr[3].hex.chr+arr[4].hex.chr+arr[5].hex.chr
93
+ end
94
+ UDPSock.send(data, 0, addr[0], addr[1])
95
+ end
96
+
97
+ def sync_time()
98
+ datestr_year=Time.new.year.to_s.reverse[0...2].reverse.to_i.to_s(16)
99
+ datestr_month=Time.new.month.to_s(16)
100
+ datestr_day=Time.new.day.to_s(16)
101
+ datestr_hour=Time.new.hour.to_s(16)
102
+ datestr_min=Time.new.min.to_s(16)
103
+ datestr_sec=Time.new.sec.to_s(16)
104
+ datestr="%"+datestr_year+"%"+datestr_month+"%"+datestr_day+"%"+datestr_hour+"%"+datestr_min+"%"+datestr_sec
105
+ response = open(GOPROCONTROL + 'command/setup/date_time?p=' + datestr).read
106
+ puts response
107
+ end
108
+ def ap_setting(ssid,pass)
109
+ response = open(GOPROCONTROL + 'command/wireless/ap/ssid?ssid=' + ssid + "&pw=" + passwd).read
110
+ puts response
111
+ end
112
+ end
113
+
114
+ def reset(option)
115
+ #videoPT, photoPT, msPT, camera, etc...
116
+ puts case option
117
+ when Reset::VideoPT
118
+ #reset video PT
119
+ response = open(GOPROCONTROL + 'command/video/protune/reset').read
120
+ puts response
121
+ when Reset::PhotoPT
122
+ #reset photo PT
123
+ response = open(GOPROCONTROL + 'command/photo/protune/reset').read
124
+ puts response
125
+ when Reset::MultiShotPT
126
+ #reset Ms PT
127
+ response = open(GOPROCONTROL + 'command/multi_shot/protune/reset').read
128
+ puts response
129
+ when Reset::CamReset
130
+ response = open(GOPROCONTROL + 'command/system/factory/reset').read
131
+ puts response
132
+ end
133
+ end
134
+ def list_media()
135
+ response = open(GOPROMEDIA).read
136
+ return JSON.pretty_generate JSON.parse(response)
137
+ end
138
+ def get_media()
139
+ folder=""
140
+ file=""
141
+ response = open(GOPROMEDIA).read
142
+ parsed_resp = JSON.parse(response)
143
+ parsed_resp['media'].each do |child|
144
+ folder = child['d']
145
+ end
146
+ parsed_resp['media'].each do |child|
147
+ child['fs'].each do |child|
148
+ file = child['n']
149
+ end
150
+ end
151
+ return "http://10.5.5.9:8080/videos/DCIM/" + folder + "/" + file
152
+ end
153
+ def dl_media()
154
+ folder=""
155
+ file=""
156
+ response = open(GOPROMEDIA).read
157
+ parsed_resp = JSON.parse(response)
158
+ parsed_resp['media'].each do |child|
159
+ folder = child['d']
160
+ end
161
+ parsed_resp['media'].each do |child|
162
+ child['fs'].each do |child|
163
+ file = child['n']
164
+ end
165
+ end
166
+ url = get_media()
167
+ open(url) {|f|
168
+ File.open(folder+"-"+file,"wb") do |file|
169
+ file.puts f.read
170
+ end
171
+ }
172
+
173
+ end
174
+
175
+ def livestream(option)
176
+ puts case option
177
+ when "start"
178
+ response = open(GOPROCONTROL + 'execute?p1=gpStream&a1=proto_v2&c1=start').read
179
+ puts response
180
+ when "stop"
181
+ response = open(GOPROCONTROL + 'execute?p1=gpStream&a1=proto_v2&c1=stop').read
182
+ puts response
183
+ when "restart"
184
+ response = open(GOPROCONTROL + 'execute?p1=gpStream&a1=proto_v2&c1=restart').read
185
+ puts response
186
+ end
187
+ end
188
+ end
data/lib/constants.rb ADDED
@@ -0,0 +1,489 @@
1
+ class Status
2
+ Status="status"
3
+ Settings="settings"
4
+ class STATUS
5
+ Battery="1"
6
+ BatteryLevel="2"
7
+ IsBatteryBacPac="3"
8
+ BatteryBacPacLevel="4"
9
+ QuikCapture="9"
10
+ IsBusy="8"
11
+ Mode="43"
12
+ SubMode="44"
13
+ RecordElapsed="13"
14
+ CamName="30"
15
+ RemVideoTime="35"
16
+ RemPhotos="34"
17
+ BatchPhotosTaken="36"
18
+ VideosTaken="39"
19
+ PhotosTaken="38"
20
+ IsRecording="8"
21
+ RemainingSpace="54"
22
+ TotalHiLights="58"
23
+ LastHiLight="59"
24
+ SdCardInserted="33"
25
+ IsConnected="31"
26
+ GPS="68"
27
+ BattPercent="70"
28
+ end
29
+ end
30
+ class Camera
31
+ Name="model_name"
32
+ Number="model_number"
33
+ Firmware="firmware_version"
34
+ end
35
+ class Mode
36
+ VideoMode = "0"
37
+ PhotoMode = "1"
38
+ MultiShotMode = "2"
39
+ class SubMode
40
+ class Video
41
+ Video = "0"
42
+ TimeLapseVideo = "1"
43
+ VideoPhoto = "2"
44
+ Looping = "3"
45
+ end
46
+ class Photo
47
+ Single = "0"
48
+ Continuous = "1"
49
+ Night = "2"
50
+ end
51
+ class MultiShot
52
+ Burst = "0"
53
+ TimeLapse = "1"
54
+ NightLapse = "2"
55
+ end
56
+ end
57
+ end
58
+
59
+ class Shutter
60
+ ON = "1"
61
+ OFF = "0"
62
+ end
63
+
64
+ class Delete
65
+ ALL = "all"
66
+ LAST = "last"
67
+ end
68
+ class Locate
69
+ Start = "1"
70
+ Stop = "0"
71
+ end
72
+ class Reset
73
+ VideoPT="video"
74
+ PhotoPT="photo"
75
+ MultiShotPT="multishot"
76
+ CamReset="camera"
77
+ end
78
+
79
+ class Setup
80
+ ORIENTATION="52"
81
+ class Orientation
82
+ Up="1"
83
+ Down="2"
84
+ Auto="0"
85
+ end
86
+ QUIK_CAPTURE="54"
87
+ class QuikCapture
88
+ ON="1"
89
+ OFF="2"
90
+ end
91
+ LED_BLINK="55"
92
+ class LedBlink
93
+ Led_OFF="0"
94
+ Led_2="1"
95
+ Led_4="2"
96
+ end
97
+ LED_BLINK_H5="92"
98
+ class LedBlinkH5
99
+ Led_OFF="0"
100
+ Led_ON="2"
101
+ Led_FrontOff="1"
102
+ end
103
+ BEEP="56"
104
+ class Beep
105
+ OFF="2"
106
+ SemiLoud="1"
107
+ Loud="0"
108
+ end
109
+ AUTO_OFF="59"
110
+ class AutoOff
111
+ Never="0"
112
+ A1Min="1"
113
+ A2Min="2"
114
+ A3Min="3"
115
+ end
116
+ GPS="83"
117
+ class MapLocate
118
+ ON="1"
119
+ OFF="0"
120
+ end
121
+ VOICE_CONTROL="86"
122
+ class VoiceControl
123
+ ON="1"
124
+ OFF="0"
125
+ end
126
+ WIFI="63"
127
+ class Wifi
128
+ Remote="2"
129
+ SmartRemote="3"
130
+ OFF="0"
131
+ end
132
+ end
133
+ class Video
134
+ RESOLUTION="2"
135
+ class Resolution
136
+ R4k="1"
137
+ R4kSV="2"
138
+ R2k="4"
139
+ R2kSV="5"
140
+ R2k4by3="6"
141
+ R1440p="7"
142
+ R1080pSV="8"
143
+ R1080p="9"
144
+ R960p="10"
145
+ R720pSV="11"
146
+ R720p="12"
147
+ R480p="13"
148
+ end
149
+ FRAME_RATE="3"
150
+ class FrameRate
151
+ FR240="0"
152
+ FR120="1"
153
+ FR100="2"
154
+ FR60="5"
155
+ FR50="6"
156
+ FR48="7"
157
+ FR30="8"
158
+ FR25="9"
159
+ FR24="10"
160
+ end
161
+ FOV="4"
162
+ class Fov
163
+ Wide="0"
164
+ Medium="1"
165
+ Narrow="2"
166
+ SuperView="3"
167
+ Linear="4"
168
+ end
169
+
170
+ LOW_LIGHT="5"
171
+ class LowLight
172
+ ON="1"
173
+ OFF="0"
174
+ end
175
+ SPOT_METER="9"
176
+ class SpotMeter
177
+ ON="1"
178
+ OFF="0"
179
+ end
180
+ VIDEO_LOOP_TIME="6"
181
+ class VideoLoopTime
182
+ LoopMax="0"
183
+ Loop5Min="1"
184
+ Loop20Min="2"
185
+ Loop60Min="3"
186
+ Loop120Min="4"
187
+ end
188
+ VIDEO_PHOTO_INTERVAL="7"
189
+ class VideoPhotoInterval
190
+ Interval5Min="1"
191
+ Interval10Min="2"
192
+ Interval30Min="3"
193
+ Interval60Min="4"
194
+ end
195
+ VIDEO_EIS="78"
196
+ class VideoEIS
197
+ ON="1"
198
+ OFF="0"
199
+ end
200
+ PROTUNE_AUDIO="79"
201
+ class ProtuneAudio
202
+ ON="1"
203
+ OFF="0"
204
+ end
205
+ AUDIO_MODE="80"
206
+ class AudioMode
207
+ Stereo="0"
208
+ Wind="1"
209
+ Auto="2"
210
+ end
211
+ PROTUNE_VIDEO="10"
212
+ class ProTune
213
+ ON="1"
214
+ OFF="0"
215
+ end
216
+ WHITE_BALANCE="11"
217
+ class WhiteBalance
218
+ WBAuto="0"
219
+ WB3000k="1"
220
+ WB4000k="5"
221
+ WB4800k="6"
222
+ WB5500k="2"
223
+ WB6000k="7"
224
+ WB6500k="3"
225
+ WBNative="4"
226
+ end
227
+ COLOR="12"
228
+ class Color
229
+ GOPRO="0"
230
+ Flat="1"
231
+ end
232
+ ISO_LIMIT="13"
233
+ class IsoLimit
234
+ ISO6400= "0"
235
+ ISO1600= "1"
236
+ ISO400= "2"
237
+ ISO3200= "3"
238
+ ISO800= "4"
239
+ ISO200= "7"
240
+ ISO100= "8"
241
+ end
242
+ ISO_MODE="74"
243
+ class IsoMode
244
+ Max="0"
245
+ Lock="1"
246
+ end
247
+ SHARPNESS="14"
248
+ class Sharpness
249
+ High="0"
250
+ Med="1"
251
+ Low="2"
252
+ end
253
+ EVCOMP="15"
254
+ class EvComp
255
+ P2= "0"
256
+ P1_5="1"
257
+ P1= "2"
258
+ P0_5="3"
259
+ Zero = "4"
260
+ M0_5="5"
261
+ M1= "6"
262
+ M1_5="7"
263
+ M2= "8"
264
+ end
265
+
266
+ end
267
+ class Photo
268
+ RESOLUTION="17"
269
+ class Resolution
270
+ R12W="0"
271
+ R7W="1"
272
+ R7M="2"
273
+ R5W="3"
274
+ #HERO5 black only
275
+ R12L="10"
276
+ R12M="8"
277
+ R12N="9"
278
+ end
279
+ SPOT_METER="20"
280
+ class SpotMeter
281
+ ON="1"
282
+ OFF="0"
283
+ end
284
+ NIGHT_PHOTO_EXP="19"
285
+ class NightPhotoExp
286
+ ExpAuto="0"
287
+ Exp2Min="1"
288
+ Exp5Min="2"
289
+ Exp10Min="3"
290
+ Exp15Min="4"
291
+ Exp20Min="5"
292
+ Exp30Min="6"
293
+ end
294
+ CONTINUOUS_PHOTO_RATE="18"
295
+ class ContinuousPhotoRate
296
+ P3="0"
297
+ P5="1"
298
+ P10="2"
299
+ end
300
+ WDR_PHOTO="77"
301
+ class WDR
302
+ ON="1"
303
+ OFF="0"
304
+ end
305
+ RAW_PHOTO="82"
306
+ class RawPhoto
307
+ ON="1"
308
+ OFF="0"
309
+ end
310
+ PROTUNE_PHOTO="21"
311
+ class ProTune
312
+ ON="1"
313
+ OFF="0"
314
+ end
315
+ WHITE_BALANCE="22"
316
+ class WhiteBalance
317
+ WBAuto="0"
318
+ WB3000k="1"
319
+ WB4000k="5"
320
+ WB4800k="6"
321
+ WB5500k="2"
322
+ WB6000k="7"
323
+ WB6500k="3"
324
+ WBNative="4"
325
+ end
326
+ COLOR="23"
327
+ class Color
328
+ GOPRO="0"
329
+ Flat="1"
330
+ end
331
+ ISO_LIMIT="24"
332
+ class IsoLimit
333
+ ISO800="0"
334
+ ISO400="1"
335
+ ISO200="2"
336
+ ISO100="3"
337
+ end
338
+ ISO_MIN="75"
339
+ class IsoMin
340
+ ISO800="0"
341
+ ISO400="1"
342
+ ISO200="2"
343
+ ISO100="3"
344
+ end
345
+ SHARPNESS="25"
346
+ class Sharpness
347
+ High="0"
348
+ Med="1"
349
+ Low="2"
350
+ end
351
+ EVCOMP="26"
352
+ class EvComp
353
+ P2= "0"
354
+ P1_5="1"
355
+ P1= "2"
356
+ P0_5="3"
357
+ Zero = "4"
358
+ M0_5="5"
359
+ M1= "6"
360
+ M1_5="7"
361
+ M2= "8"
362
+ end
363
+ end
364
+
365
+ class Multishot
366
+ RESOLUTION="28"
367
+ class Resolution
368
+ R12W="0"
369
+ R7W="1"
370
+ R7M="2"
371
+ R5W="3"
372
+ #HERO5 black only
373
+ R12L="10"
374
+ R12M="8"
375
+ R12N="9"
376
+ end
377
+
378
+ SPOT_METER="33"
379
+ class SpotMeter
380
+ ON="1"
381
+ OFF="0"
382
+ end
383
+
384
+ NIGHT_LAPSE_EXP="31"
385
+ class NightLapseExp
386
+ ExpAuto="0"
387
+ Exp2Min="1"
388
+ Exp5Min="2"
389
+ Exp10Min="3"
390
+ Exp15Min="4"
391
+ Exp20Min="5"
392
+ Exp30Min="6"
393
+ end
394
+ NIGHT_LAPSE_INTERVAL="32"
395
+ class NightLapseInterval
396
+ IContinuous="0"
397
+ I4s="4"
398
+ I5s="5"
399
+ I10s="10"
400
+ I15s="15"
401
+ I20s="20"
402
+ I30s="30"
403
+ I1m="60"
404
+ I2m="120"
405
+ I5m="300"
406
+ I30m="1800"
407
+ I60m="3600"
408
+ end
409
+ TIMELAPSE_INTERVAL="30"
410
+ class TimeLapseInterval
411
+ IHalf1="0"
412
+ I1="1"
413
+ I2="2"
414
+ I5="5"
415
+ I10="10"
416
+ I30="30"
417
+ I60="60"
418
+ end
419
+ BURST_RATE="29"
420
+ class BurstRate
421
+ B3_1="0"
422
+ B5_1="1"
423
+ B10_1="2"
424
+ B10_2="3"
425
+ B10_3="4"
426
+ B30_1="5"
427
+ B30_2="6"
428
+ B30_3="7"
429
+ B30_6="8"
430
+ end
431
+ PROTUNE_MULTISHOT="21"
432
+ class ProTune
433
+ ON="1"
434
+ OFF="0"
435
+ end
436
+ WHITE_BALANCE="35"
437
+ class WhiteBalance
438
+ WBAuto="0"
439
+ WB3000k="1"
440
+ WB4000k="5"
441
+ WB4800k="6"
442
+ WB5500k="2"
443
+ WB6000k="7"
444
+ WB6500k="3"
445
+ WBNative="4"
446
+ end
447
+ COLOR="36"
448
+ class Color
449
+ GOPRO="0"
450
+ Flat="1"
451
+ end
452
+ ISO_LIMIT="37"
453
+ class IsoLimit
454
+ ISO800="0"
455
+ ISO400="1"
456
+ ISO200="2"
457
+ ISO100="3"
458
+ end
459
+ ISO_MIN="76"
460
+ class IsoMin
461
+ ISO800="0"
462
+ ISO400="1"
463
+ ISO200="2"
464
+ ISO100="3"
465
+ end
466
+ SHARPNESS="38"
467
+ class Sharpness
468
+ High="0"
469
+ Med="1"
470
+ Low="2"
471
+ end
472
+ EVCOMP="39"
473
+ class EvComp
474
+ P2= "0"
475
+ P1_5="1"
476
+ P1= "2"
477
+ P0_5="3"
478
+ Zero = "4"
479
+ M0_5="5"
480
+ M1= "6"
481
+ M1_5="7"
482
+ M2= "8"
483
+ end
484
+ end
485
+ class Livestream
486
+ RESTART = "restart"
487
+ START = "start"
488
+ STOP = "stop"
489
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goprocam
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Konrad Iturbe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Control and view status from your GoPro HERO4/HERO5 camera via WiFi.
14
+ email: mail@chernowii.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/GoPro.rb
20
+ - lib/constants.rb
21
+ homepage: http://rubygems.org/gems/goprocam
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.6.8
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Interface for your WiFi GoPro camera.
45
+ test_files: []