Skip to content

Instantly share code, notes, and snippets.

View chrissnell's full-sized avatar

Chris Snell chrissnell

View GitHub Profile
package main
import (
"encoding/json"
"fmt"
)
/*
JSON looks like this:
@chrissnell
chrissnell / gist:40b9c4dd8d6f0b101099
Last active August 29, 2015 14:01
Revinate Cloud Instance Provisioning
##
## Revinate Cloud Instance Provisioning
## Chris Snell <chris.snell@revinate.com>
##
# We only run this block if the file /etc/firstboot exists
if [ -f /etc/firstboot ]; then
# These are the URLs for the EC2-compatible metadata service running in our cloud
HOSTNAME_METADATA="http://169.254.169.254/2009-04-04/meta-data/hostname"
sudo tcpdump -Xi wlan2 port 14580
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan2, link-type EN10MB (Ethernet), capture size 65535 bytes
11:29:03.142268 IP utila.island.nu.32949 > aprs.nh6z.net.14580: Flags [S], seq 3333231990, win 14600, options [mss 1460,sackOK,TS val 127420093 ecr 0,nop,wscale 3], length 0
0x0000: 4500 003c 53cb 4000 4006 8d8f 0a32 0019 E..<S.@.@....2..
0x0010: c6b2 8864 80b5 38f4 c6ad 1576 0000 0000 ...d..8....v....
0x0020: a002 3908 5990 0000 0204 05b4 0402 080a ..9.Y...........
0x0030: 0798 46bd 0000 0000 0103 0303 ..F.........
11:29:03.176173 IP aprs.nh6z.net.14580 > utila.island.nu.32949: Flags [S.], seq 196851892, ack 3333231991, win 14480, options [mss 1460,sackOK,TS val 939309337 ecr 127420093,nop,wscale 3], length 0
0x0000: 4520 003c 0000 4000 3506 ec3a c6b2 8864 E..<..@.5..:...d
2014-06-09 18:23:27.481 NW5W-1 R KD0SOR-7>TW4WPQ,JUPITR*,WIDE1*,WIDE2-1:`2)^]lh7>/`"49}_
2014-06-09 18:23:51.271 APRSIS R NW5W-10>APRS,TCPIP*,qAC,T2CMH:@091824z4715.66N/12228.20W_048/001g003t064r000p000P000b10210h63 http://fifestreet.com weewx-VantagePro
2014-06-09 18:23:57.391 NW5W-1 T NW5W-1>APRX28,WIDE2-2:!4715.68N/12228.20W-aprx iGate http://nw5w.com
2014-06-09 18:24:51.482 APRSIS R NW5W-10>APRS,TCPIP*,qAC,T2QUEBEC:@091825z4715.66N/12228.20W_359/002g003t064r000p000P000b10209h65 http://fifestreet.com weewx-VantagePro
2014-06-09 18:25:08.711 NW5W-1 R K7FRC>T7RYRX,W7PFR-1*,WIDE1*,WIDE2-1:`2.^\l#4>/'"53}|"6%X'k|!wSm!|3
2014-06-09 18:25:27.613 NW5W-1 R WW7RA>APRS,BALDI*,WIDE2-1:!4732.88N/12248.45W_>WW7RA Digi & Remote Wx Sta
2014-06-09 18:25:28.514 NW5W-1 R BALDI>APRX27:!4713.13NI12150.61W&PHG7830/W2,WAn-N,Baldi Mtn N7FSP
2014-06-09 18:25:43.427 NW5W-1 R TWOODS>APOT21,SOMTN*,WIDE1*,JUPITR*,WIDE2-1:!4645.38N/12207.08W#KD7ISZ
2014-06-09 18:25:51.180 APRSIS R NW5W-10>APRS,TCPIP*,qAC,T2T
mycall NW5W-1
myloc lat 4715.68N lon 12228.20W
<aprsis>
passcode NNNN
server oregon.aprs2.net
filter b/NW5W-10
heartbeat-timeout 0
</aprsis>
.. igate from aprsis
interface_receive_3rdparty() aif=0x3397c, aif->digicount=1
pbuf_alloc(118,115) -> 0xb6f66000
parse_aprs_uncompressed position ok: lat 47.261 lng -122.470
.. parse_aprs() rc=OK type=0x8021 srcif=APRSIS tnc2addr='NW5W-10>APRS:@091933z4715.66N/12228.20W_009/002g004t066r000p000P000b10207h53 http://fifestreet.com weewx-VantagePro' info_start='@091933z4715.66N/12228.20W_009/002g004t066r000p000P000b10207h53 http://fifestreet.com weewx-VantagePro'
pbuf_free(0xb6f66000)
parse_aprs_uncompressed position ok: lat 47.261 lng -122.470
.. parse_aprs() rc=OK type=0x8021 srcif=APRSIS tnc2addr='NW5W-10>APRS:@091933z4715.66N/12228.20W_009/002g004t066r000p000P000b10207h53 http://fifestreet.com weewx-VantagePro' info_start='@091933z4715.66N/12228.20W_009/002g004t066r000p000P000b10207h53 http://fifestreet.com weewx-VantagePro'
## produce 3rd-party frame for transmit:
ax25hdr 82 a0 a4 a6 40 40 60 9c|ae 6a ae 40 40 62 ae 92|88 8a 64 40 03 = APRS 0N|W5W 1WI|DE2 .
Byte# HexVal Char Char>>1 Binary
----- ------ ---- ------- ------
0 0xc0 À ` 11000000
1 0x0 00000000
2 0x82 ‚ A 10000010
3 0xa0   P 10100000
4 0xb4 ´ Z 10110100
5 0x60 ` 0 01100000
6 0x60 ` 0 01100000
7 0x62 b 1 01100010
mycall NW5W-1
myloc lat 4715.68N lon 12228.20W
<aprsis>
passcode NNNN
server northwest.aprs2.net
filter b/NW5W-10
heartbeat-timeout 0
</aprsis>
// A little blurb I wrote to toggle something on and off, always making sure to toggle off before shutdown
toggle := make(chan bool, 1)
outputPin, err := hwio.GetPinWithMode(pin, hwio.OUTPUT)
if err != nil {
log.Printf("Error getting GPIO pin: %v\n", err)
}
go func() {
# Testing packages.
ok cmd/addr2line 0.423s
? cmd/cgo [no test files]
ok cmd/fix 0.013s
ok cmd/go 0.014s
ok cmd/gofmt 0.053s
ok cmd/nm 0.521s
ok cmd/objdump 2.551s
ok cmd/pack 2.934s