Cable for connecting APRSdroid to a Baofeng UV-82 Radio (APRS via RF)

Sources:

Warning, this alternative *may* be more reliable than mine: https://github.com/johnboiles/BaofengUV5R-TRRS

And of course, using a Bluetooth TNC, etc, is going to be much more reliable than this hack.

I harvested a cheap Baofeng handheld speaker/microphone for its cable (although you can buy them here — the Kenwood type) and bought a 3.5mm TRRS plug from Digi-key. It’s a bit tight to solder the resistors inside the plug housing, but it is possible (just remember to put the plug housing on the cable BEFORE soldering, otherwise you’ll be unable to put it on later… a mistake I made about three times.)

aprs cable

Your wire colors may be different; I made this diagram match the wire colors from my cable so I wouldn’t get things confused.

aprs cable

This cable follows the above diagram precisely; note the color-coded heat shrink, and note that the TRRS plug’s internal wiring is such that the Tip is wired to the furthest-left solder point, followed by R1 and R2, and finally the Sleeve solder point is actually also the strain relief and threaded housing. So you’ve gotta think a bit backwards (and/or use an ohmmeter to check your wiring.)

I’m sure there is some science behind the correct resistor ohm values (and as in the Github link, an additional capacitor might help; I’m not sure, this is just a hack.) I used 480ohm resistors. The idea is to mute the audio slightly because amplified earphone output being wired straight into amplified microphone input is a surefire way to transmit nothing but distortion.

In my experience on a Galaxy Nexus running APRSdroid with this cable into a Pofung UV-82, the best reception is with the radio volume at barely audible (1/3rd of a rotation) and with the phone volume at 1/4. Further experimentation would yield better data, but keeping an eye on received packets and repeats of your transmissions can help you even if you don’t have a separate radio to listen on. You can also use a recording app on your phone to see what the phone is hearing.

Helpful settings in APRSdroid: 3-4 second preamble (so VOX has a chance to turn on); output via AFSK (not Internet/bluetooth etc); AFSK output via headset (not ringer/speaker). Also, before opening APRSdroid, set your phone to Vibrate so hopefully no notification sounds are transmitted.

Helpful settings on radio: VOX at ~2, Squelch at ~1. Ensure that both channels are set to the APRS channel before enabling VOX or connecting cable, and connect cable while radio is off, to avoid unwanted transmission. Consider listening to transmissions/receptions on a separate radio and looking at the radio’s receive/transmit lights to ensure that the phone is being polite and not transmitting over other stations.

Fixing: Cannot set session ID after the session has started in PHPUnit

I got this error after adding an onKernelRequest listener to my Symfony project and trying to pass Twig_Environment to it as an argument. It worked via the web browser, but not in any PHPUnit tests hitting multiple pages.

After much head scratching and reading of the Symfony source code, I ended up making an onKernelException listener instead. Magically, rendering a twig template from it (passing a TwigEngine argument) worked.

So, here’s how I handle custom exceptions in a custom way. Notice I’m testing for Twig_Error_Runtime because my specific error is coming via Twig; you may be able to just test for regular Symfony exceptions instead:

https://gist.github.com/zyphlar/e1089be4c0f0499ab08b

Two Unrelated (No association) Entities in One Form in Symfony2

A lot of tutorials are showing you how to create embedded forms with associations/relations — what about unrelated entities?

I figured out you can pass the second entity as a parameter to the parent form, pass it normally to the embedded form via the ‘data’ parameter, which will let the embedded form update the object. Then just persist() the object back in the controller like normal. No crazy data/request wrangling necessary! Continue reading

Logging NAT/Firewall/state entries in Pfsense

Sometimes you really need to know what computers on your network were doing yesterday at noon, because you get a nastygram from the MPAA about bittorrent demanding that you do something — but bittorrent is notoriously hard to block.

You can try installing BandwidthD on your Pfsense router, to see who’s using a bunch of bandwidth at that time, and you can look back through DHCP or WiFi logs to see who was connected at the time, but the complaint letter tells you the exact time and port number used. Wouldn’t it be cool if you could log that?

Here’s what I came up with. Download the Cron package for Pfsense, and add a new Cron job:

Minute: 1
Hour/etc: *
Who: root
Command: pfctl -ss | egrep '(>.*>|<.*<)' | logger

The firewall states (who is connected to what) will now dump to your system log every hour — kinda noisy, but also kinda effective for tracking long downloads on random ports.