Skip to content

Instantly share code, notes, and snippets.

@3v1n0
Last active November 2, 2020 22:05

Revisions

  1. 3v1n0 revised this gist Feb 11, 2015. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions wake-up-gopro.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env python

    import socket
    import struct

    GOPRO_IP = '10.5.5.9'
    GOPRO_MAC = 'd4d9xxxxxxxx' # Your GoPro MAC address

    def wake_on_lan(macaddress):
    """ Switches on remote computers using WOL. """

    # Check macaddress format and try to compensate.
    if len(macaddress) == 12:
    pass
    elif len(macaddress) == 12 + 5:
    sep = macaddress[2]
    macaddress = macaddress.replace(sep, '')
    else:
    raise ValueError('Incorrect MAC address format')
    # Pad the synchronization stream.
    data = ''.join(['FFFFFFFFFFFF', macaddress * 20])
    send_data = ''

    # Split up the hex values and pack.
    for i in range(0, len(data), 2):
    send_data = ''.join([send_data,
    struct.pack('B', int(data[i: i + 2], 16))])

    # Broadcast it to the LAN.
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
    sock.sendto(send_data, (GOPRO_IP, 9))

    if __name__ == '__main__':
    wake_on_lan(GOPRO_MAC)
  2. 3v1n0 revised this gist Feb 11, 2015. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions hero4-udp-keep-alive-send.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    import socket
    import sys
    from time import sleep

    def get_command_msg(id):
    return "_GPHD_:%u:%u:%d:%1lf\n" % (0, 0, 2, 0)

    UDP_IP = "10.5.5.9"
    UDP_PORT = 8554
    KEEP_ALIVE_PERIOD = 2500
    KEEP_ALIVE_CMD = 2
    MESSAGE = get_command_msg(KEEP_ALIVE_CMD)

    print("UDP target IP:", UDP_IP)
    print("UDP target port:", UDP_PORT)
    print("message:", MESSAGE)

    if sys.version_info.major >= 3:
    MESSAGE = bytes(MESSAGE, "utf-8")

    while True:
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
    sleep(KEEP_ALIVE_PERIOD/1000)
  3. 3v1n0 revised this gist Feb 11, 2015. 1 changed file with 5126 additions and 0 deletions.
    5,126 changes: 5,126 additions & 0 deletions gpControl.json
    5,126 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
  4. 3v1n0 created this gist Feb 10, 2015.
    5,429 changes: 5,429 additions & 0 deletions settings.json
    5,429 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.