Pacific Simplicity is the home to my tech blog of sorts, aiming to assist and provide information easily to other Linux users and Open Source hackers out there.  It contains articles on Linux, system admin hints, scripting, programming embedded systems, OpenWRT and of course Drupal . Check it out and don't forget to comment!

Posted: Sun, 06/19/2016 - 18:29

Here is my guide for a quickstart instead of reading their documentation:

Install Prerequisites

# sudo apt-get update
# sudo apt-get install -y git autoconf gcc libtool libxml2-dev libssl-dev make libncurses5-dev libssh2-1-dev openssh-server build-essentials git

Reconfigure SSHD

Edit sshd_config and under the line Port 22, add the following two lines

# sudo vi /etc/ssh/sshd_config

# What ports, IPs and protocols we listen for
Port 22
Port 830
Subsystem netconf /usr/sbin/netconf-subsystem --ncxserver-sockname=830@/tmp/ncxserver.sock

Restart SSH with the following command

sudo service ssh restart

Download, build and install OpenYuma

GIT clone, make and install the following - netconfd will run with your current user

# git clone <a href="https://github.com/OpenClovis/OpenYuma.git">https://github.com/OpenClovis/OpenYuma.git</a> openYuma
# cd openYuma
# make
# sudo make install

# sudo cp /etc/yuma/netconfd-sample.conf /etc/yuma/netconfd.conf
# /usr/sbin/netconfd --superuser=`whoami`

Connecting with yangcli

Open a second terminal and run the command:

# yangcli

Something like the following should appear - note the YOURUSERNAME and YOURPASSWORD variables which need to be replaced with something more appropriate

yangcli> connect server=localhost user=YOURUSERNAME password=YOURPASSWORD
val->res is NO_ERR.

yangcli: Starting NETCONF session for rbrash on localhost

NETCONF session established for rbrash on localhost

Client Session Id: 2
Server Session Id: 1

Server Protocol Capabilities

Server Module Capabilities

Server Enterprise Capabilities

Protocol version set to: RFC 6241 (base:1.1)
Default target set to: <candidate>
Save operation mapped to: commit
Default with-defaults behavior: explicit
Additional with-defaults behavior: trim,report-all,report-all-tagged

Checking Server Modules...

Posted: Thu, 06/16/2016 - 16:28

Upcoming will be my porting of this devices code into OpenWRT (ported and booting already) or LEDE when I decide which will be appropriate, but here is how you flash uboot and get the UART TTL to work (compared to the terrible manufacturer documentation.

Wiring setup for the UART on the board:

Posted: Tue, 06/14/2016 - 13:29

Apparently, Openwrt's trunk dropped support for GCC 5.2 which Ubuntu 15.10 is still on... so here are the steps I took to get it working:

Posted: Wed, 06/08/2016 - 13:52

Excluding the Bluez/BT process, here is a neat trick to do this:

To list your sources - run the following command. Note that the bluetooth monitor and source are missing - I am assuming you have the BT headset connected already and would be listed below as an additional 2 sources.

Posted: Wed, 05/25/2016 - 17:17

We spent some time looking at RFCOMM sockets in C using libbluetooth (bluez)... and we found this treat:

If you use the same channel for both the src and dest struct sockaddr_rc, or rather both as zero - it will never work. Apparently according to documentation on the internet - 0 - means, pick a free one. It actually doesn't and it will result in:

  • Connection refused
  • Host down
  • Permission denied (rarely)
int rfcomm_socket_for_client(char *src_address, char *dst_address)
        int s;

        // src addressing and binding
        struct sockaddr_rc loc_addr = { 0 };
        loc_addr.rc_family = AF_BLUETOOTH;
        loc_addr.rc_channel = 0;
        str2ba(src_address, &loc_addr.rc_bdaddr);
        // set the connection parameters (who to connect to)
        struct sockaddr_rc addr = { 0 };
        addr.rc_family = AF_BLUETOOTH;
        addr.rc_channel = (uint8_t) 1; 
        str2ba(dst_address, &addr.rc_bdaddr);

        // connect to server
        bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr));
        status = connect(s, (struct sockaddr *)&addr, sizeof(addr));

        if (status == 0) {
                printf("\nConnection established.");
                write(s, "Hello Master!", 6);
                return (0);
        } else {
                printf("\nConnection Failed.");

        return (0);

The other gotcha is PSCAN - you should either write the HCI code to enable it OR just use:

hciconfig hci[x] PSCAN

 * enable_scanmode(char *mac_address, char *opt)
 * @brief Enables scanmode which allows you to actually have a working RFCOMM host
 * @param mac_address
 * @param opt
 * @return 0 for success, -1 for error
 * @note Borrowed some of this from the bluez hciconfig tool
int enable_scanmode(char *mac_address, char *opt)

        /* Open HCI socket  */
        int ctl = 0;
        struct hci_dev_req dr = { 0 };
        dr.dev_id = hci_devid(mac_address);
        dr.dev_opt = SCAN_DISABLED;

        if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) {
                perror("Can't open HCI socket.");
                return (-1);

        if (strcmp(opt, "iscan") == 0) {
                dr.dev_opt = SCAN_INQUIRY;
        } else if (strcmp(opt, "pscan") == 0) {
                dr.dev_opt = SCAN_PAGE;
        } else if (strcmp(opt, "piscan") == 0) {
                dr.dev_opt = SCAN_PAGE | SCAN_INQUIRY;
        } else if (strcmp(opt, "noscan") == 0) {
                dr.dev_opt = SCAN_DISABLED;
        } else {
                printf("unknown scan option to set\n");
                return (-1);

        if (ioctl(ctl, HCISETSCAN, (unsigned long)&dr) < 0) {
                printf("Can't set scan mode on hci: %s %s-%d\n", mac_address, strerror(errno), errno);
                return (-1);
        return (0);