Posts

Showing posts from 2017

Connecting to a Wifi SSID from the macOS command line

Sometimes it's useful to be able to connect to an SSID (or switch from one to the other) from the command line. Here is how to do this on macOS (tested on High Sierra):

networksetup -setairportnetwork [interface] [SSID] [password]

For example:

networksetup -setairportnetwork en0 SSID1
networksetup -setairportnetwork en0 SSID2
networksetup -setairportnetwork en0 MyHouseSSID MyPassword

Using this command to connect to the same SSID your already connected acts as a reconnect.

Get wifi details from macOS command line

GUI is great but CLI is awesome. Here are a few macOS CLI commands go get wifi details:

Get details about your current connection/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I

Sample output:

     agrCtlRSSI: -61
     agrExtRSSI: 0
    agrCtlNoise: -90
    agrExtNoise: 0
          state: running
        op mode: station
     lastTxRate: 162
        maxRate: 300
lastAssocStatus: 0
    802.11 auth: open
      link auth: wpa2-psk
          BSSID: 9c:3d:cf:d0:e2:34
           SSID: Maison_5GHz
            MCS: 12
        channel: 36,1

Get the list of an SSID broadcast scan (aka list of available visible SSID)
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

Sample output:

                            SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
                         VLAN805 54:3d:37:d1:b5:c8 -42  11      Y  US NONE
                         VLAN205 54:3d:37:91:b5:c8 -43  11      Y  US NONE
   …

Sync with remote as you code

If your like me, sometimes you can not test the code your writing on your workstation and the code need to be 'installed' or 'deployed' to a remote server in order to test it because of hardware constrain or physical environment (IO, network,...).

The following is a simple shell script that will monitor a local path and rsync it to a remote server when a file is changed. It can also remote execute some commands (like restarting services for example).

#!/bin/sh

if [ -z ${1} ] || [ -z ${2} ] || [ -z ${3} ] || [ -z ${4} ]; then
cat <<EOF
Usage:
  remote_sync local_path remote_user remote_server remote_path [remote_script]

local_path:    Local path from where the files will be copied from (required)
remote_user:   Remote user to use for rsync  (required)
remote_server: Remote server (IP of FQDN)  (required)
remote_path:   Remote path where the files will be copied to  (required)
remote_script: Remote script to execute after syncing the files (optional)
              Script mus…

Arduino: Upload timeout and !!! in a string

If you ever see the following when uploading your sketch to an Arduino board (using the Arduino IDE, PlatformIO or any other):

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

Look for !!! (3 exclamation points characters  aka bang) in your code and remove them.

Why ? These 3 exclamation point characters are actually used to tell the Arduino bootloader to…

Omega2 with Arduino Dock2 review

Image
Ok, so this is a Kickstarter project (Kickstarter Link) that I backed in 2016. I opted for the Omega2 with the Arduino Dock 2 option cause I'm a big fan of Arduino ;-)
I got delivery of the unit on December 29th 2016 (a nick xmas present !). Loved the simple yes effective packaging:






As you can see they even took care or putting a label on the box with the device MAC address (the same label is on the device itself) which makes it easier to know the IP address from your DHCP logs.
As I said I opted for the Omega2 with the Arduino Dock. The pinout is 100% pin compatible with an Arduino Uno.


There is however one flaw... There are no, I mean zero mounting holes on the Arduino dock.

This means there is no way to tie a shield to the Arduino dock and/or tie the dock in an enclosure securely.
Setting up the unit was pretty straight forward. Like a ChromeCast the units boots in an access point mode broadcasting an SSID matching the last 2 bytes of it's MAC address. From there it's …