Author: Paul

  • ODBC and ESQL

    To setup ODBC bridge from IBM Integration Bus to Db2, download and install the ODBC bridge from the IBM Data Server Runtime Clients. It’s a 1.3 GB download, and you only need about a 40 MB file for your system.

    The installation is straight forward – Click Next, and Finish.

    The complexity and detailed steps are in the configuration of the ODBC Bridge and IIB.

    To setup the ODBC bridge and IIB, follow these directions:

    1. Start > Run

    2. Type ODBC

    3. Click on Data Sources

    4. Click on `Configure ODBC

    5. Enter the Connection Details

    Name Value
    Username db2admin
    Password fakepass!
    IP 9.32.18.166
    Port 50000
    Database name SAMPLE
    1. Name the alias as SAMPLE

    2. Launch a Command prompt

    3. Start > Run

    4. Enter cmd

    5. Change directory to server\bin

    6. Launch iib

    C:\Program Files\IBM\IIB\10.0.0.4\server\ 
    bin>mqsisetdbparms.exe TESTNODE_cheetah -n SAMPLE -u db2admin -p fakepass!
    
            BIP8071I: Successful command completion. 
            TESTNODE_cheetah should be your local node in Eclipse. 
    

    You want to restart the Node (you can look in the lower right of your toolkit)

    1. Right Click the Node

    2. Select Stop, Then Start

    Now, that it is setup, the steps to read the data, the ESQL is easy:

    You can then send a message using the IIB tests , and confirm using your database Db2 select * from DB2ADMIN.EMPLOYEE.

    To Write Data, create a New Input Message with

    {
    "EMPNO" : "2229",
    "FIRSTNME" : "Paul",
    "LASTNAME" : "B",
    "JOB" : "PRES",
    "EDLEVEL" : 18
    }
    
  • OAuth 2.0 Flow – A Metaphor

    The following video helps explain the OAuth 2.0 Flow and authorization. This video was originally shared as part of a prior project on Social Application Development.

  • Swagger Enumerations in YAML

    Recently, I have been spending time looking at the Swagger 2.0 Specification.  There XML representation and Enumerations are tricky.  Here is an example of a Swagger Enumeration in YAML.

    You can test the YAML at http://petstore.swagger.io/#!/default/get_demo

  • Raspberry Pi – Part IV – Simple Wiring Test

    I am plugging away working with my Pi. I went back to the Ada Fruit Site, and started working on one of the tutorials from the part I purchased – https://www.adafruit.com/products/2125   I want to be able to demonstrate a simple wiring with my Pi works.

    I selected Email Notifier. I read through it, and realized I needed to convert it to work for the B+ model. The pi4j website has a nice diagram for the pins http://pi4j.com/images/j8header-b-plus-large.png and I simplified the test a bit.

    I launched the simple python file

    pi@seconds ~ $ sudo python testPi.py

    Pi with a Green Light - Using Python
    Pi with a Green Light – Using Python

    I added the pi4j dependency to my maven pom

    <dependency>
        <groupId>com.pi4j</groupId>
        <artifactId>pi4j-core</artifactId>
       <version>1.0</version>
    </dependency>

    I create a servlet which replicated the same code from before (GPIO).

    I copied the war file to the local webapp directory, and restarted jetty

    pi@seconds /opt/jetty/web/bbq/webapps $ sudo cp ~/pi.webapp.war ./
    pi@seconds /opt/jetty/web/bbq/webapps $ sudo chown jetty:jetty pi.webapp.war
    pi@seconds /opt/jetty/web/bbq/webapps $ sudo /etc/init.d/jetty restart

    Refer to https://wiki.eclipse.org/Jetty/Howto/Deploy_Web_Applications  and I did have to add –module=jsp to the start.ini for my web configuration.

    I hit the servlet – http://192.168.1.200/pi.webapp/Control?status=true

    Exception
    Exception

    Which makes sense, since “Software using the Pi4J library must be run with ROOT level permissions.” (actually it doesn’t since I am running as root)…

    Issues remain.  I’ll tackle them on a different day 🙂   … Part 5 …

  • Raspberry Pi – Part III – Setting up Jetty

    The Raspberry Pi is a device that has so many options open: You can extend the hardware. You can extend the software. I choose to tackle extending the software to start, so I can get the experience that I want setup, and running on the device.  The experience I am after is the web interface to control my Raspberry Pi.

    For a Java developer, I conclude that a lightweight interface hosted on a Jetty server is probably easiest.  The Jetty server is a 12.9M download and 30M expanded. It’s also used frequently in devices, and why reinvent the wheel, use the approach that Industry is using.  Jetty is designed for a small memory footprint.   (I did consider using Tomcat Embedded, and came to the conclusion I’d probably want to many features.)

    I downloaded the Jetty archive to my local user’s directory. Note, since I want to just use jetty.zip I’m renaming the output file with wget -O.

    wget -O jetty.zip http://download.eclipse.org/jetty/stable-9/dist/jetty-distribution-9.2.10.v20150310.zip

    I make a directory for the application server, and move over jetty.zip to that directory.

    sudo mkdir -p /opt/jetty
    sudo mv jetty.zip /opt/jetty

    Next I launched into the sudoers root shell, and extract the Jetty archive.  I decided to move it into the runtime folder, so I can have an easy place to backup from.  (Remove the extra space from the .zip)

    sudo -s 
    cd /opt/jetty
    unzip jetty.zip
    mv jetty-distribution-9.2.10.v20150310/ runtime
    rm jetty.zip

    Next, I wanted to setup Jetty as a service, and check that Jetty starts

    cp runtime/bin/jetty.sh /etc/init.d/jetty
    echo JETTY_HOME=`pwd`/runtime > /etc/default/jetty
    service jetty start
    Starting Jetty: . . . OK Sun Apr 12 15:38:40 UTC 2015
    service jetty stop
    Stopping Jetty: OK

    Next, I want to automatically start Jetty with the right runlevels

    update-rc.d jetty defaults

    I want to configure Jetty to run with a set user jetty.

    mkdir -p /opt/jetty/web/bbq
    mkdir -p /opt/jetty/temp
    useradd --user-group --shell /bin/false --home-dir /opt/jetty/temp jetty

    There is a base configuration that needs to be setup the base site.

    cd /opt/jetty/web/bbq
    java -jar /opt/jetty/runtime/start.jar --add-to-start=deploy,http,logging

    Next, edit the default port value.

    vi start.ini
    
    ## HTTP port to listen on
    jetty.port=80

    Finally, I wrap the configuration of the jetty service and app.

    chown -R jetty:jetty /opt/jetty
    echo "JETTY_HOME=/opt/jetty/runtime" > /etc/default/jetty
    echo "JETTY_BASE=/opt/jetty/web/bbq" >> /etc/default/jetty
    echo "TMPDIR=/opt/jetty/temp" >> /etc/default/jetty

    A good check is to look at service jetty status, and confirm the settings, and then restart your Raspberry Pi. I did find that the startup time was significantly effected by the additional service.  ( +25 seconds from the original 15)

    Navigate to http://192.168.1.200/ (or whatever IP you have used) and confirm the page loads Jetty.  If you see a 404, you’re off and ready for the next phase. (as am I) 🙂

    Jetty Starting Point
    Jetty Starting Point

  • Configure WLAN0 on Raspberry Pi

    I  don’t know how I did it.  I lost wireless connectivity, so I was forced to plugin my Raspberry Pi to the Lan.  Once, plugged in I could find it via the DHCP table on my router.

    I first checked the iwlist wlan0 scan to see if my home network was listed.  The home network was listed.  It was.

    I checked the wpa_supplicant configuration ~ $ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf  and confirmed it pointed to the right network. I also checked dmesg to see if there were any hints for wpa_supplicant.

    I looked at the /etc/network/interfaces and found

    iface wlan0 inet manual

    which I converted to

    iface wlan0 inet dhcp

     Also wpa-debug-level 3 was very helpful and must proceed the wpa-roam statement in the interfaces.

    Also running the wpa_supplicant command can result in some good details

    pi@seconds ~ $ sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

    I also found this link helpful. https://wiki.debian.org/WiFi/HowToUse It showed how to reset manual to dhcp in the /etc/network/interfaces file

    Finally, I used http://weworkweplay.com/play/automatically-connect-a-raspberry-pi-to-a-wifi-network/ to finally review, and finally I broke down and set a static ip. Not sure why it won’t automatically take a dhcp configuration.

  • Raspberry Pi – Part II – Get Up and Going with Java

    In recent weeks, I haven’t revisited the Raspberry Pi – Running, Vacation, Work have conspired to keep me away from hobby project.

    I’ve stared at the parts long enough, and decide to plug the Raspberry Pi base into the wired network. I plugged in the Raspberry Pi into the Power outlet, and I got the Red Light.  I logged into my router to see if the Pi picked up the Raspberry Pi, and I found the IP from my routers IP reservations table.   I was able to SSH into the Pi and quickly check the release version ( cat issue ) – Raspbian GNU/Linux 7 \n \l.

    Headless + SSH + Version

    I turned on the SSH server using sudo raspi-config and the advanced options.

    The first thing I thought – Upgrade / Update to get the latest environment for the Raspberry Pi.  It’s a good start – always good to be up-to-date. Per the documentation, it may be necessary to run – sudo apt-get clean.

    sudo apt-get upgrade
    sudo apt-get update

    The raspi-config is another item that may need to be updated.   The update goes out and queries for the latest raspi-config, installs and relaunches the raspi-config.

    sudo raspi-config
    Select Option 8 - Advanced Options
    Selection Option A0 - Update 
    Select Yes

    raspi-config
    raspi-config

    Next, I looked updated the Java version.  From reading the documentation, the next versions of the Pi are going to automatically include the Java installs.

    sudo apt-get update && sudo apt-get install oracle-java7-jdk

    Java Installation
    Java Installation

    I grabbed the Pi4J project jar files. The Pi4J is an opensource project which has some great details on PINOUT and boilerplate java code to access the underlying pin readouts.  I ran some quick code to get the latest snapshot installed.

    wget http://get.pi4j.com/download/pi4j-1.1-SNAPSHOT.deb
    sudo dpkg -i pi4j-1.1-SNAPSHOT.deb

    WGET
    WGET

    dpkg
    dpkg

    Pi4J is also installed on the Sonatype repositories and developed on GitHub.  Pi4J includes a script for managing updates.   It’s very convenient with the Apache 2.0 License.

    I was ready run a sample program – Get Sample, Compile and Run.

    wget https://raw.githubusercontent.com/Pi4J/pi4j/master/pi4j-example/src/main/java/ListenGpioExample.java
    pi4j ListenGpioExample.java
    pi4j -run ListenGpioExample

    First Sample
    First Sample

    Eventually, I am going to get to the point where I use the diagram from Pi4j.  The future efforts are going to take some time to get to – This step was the right step in the direction I want to go.  BBQ Champion.

  • Raspberry Pi – Initial Thoughts

    Thanks To Ada Fruit  I picked up a first version Raspberry Pi B+.   The experience brings me back to building my first computer and modifying it.

    I picked up an B+ Kit from Ada Fruit (based on the fact they have awesome tutorials).  I also picked up a Motor Controller, a Bread Board to hook up peripherals, and a Touch Screen Display.  The touch screen display wasn’t actually compatible with the kit I purchased.  Lesson learned – check the Male and Female connectors for the Displays and PIN (IN/OUT) counts.

    I laid out all the components on the bubble wrap, and I started assembling the components into one computer. The experience was rather like assembling a jigsaw puzzle.

    Easy As Pi
    Easy As Pi

    I used the 4G microSD card that came with the B+ kit.  I used it to immediately configure Debian and setup SSH. I got it on the wireless using the USB dongle for wireless, and I ran the updates for aptitude update and aptitude full-upgrade.  It’s nice that it persists all these changes.

    Now, that I am on the wireless, I can unplug the Raspberry Pi from the monitor, and connect to it via SSH.  It’s fantastic stuff. I am now going to work on my motor controller.

    Running Debian
    Running Debian

  • Setting up Db2 JDBC Access

    I have been working IBM Integration Broker 10.0.0.4. I found it hard to find concise documentation on setting up/creating a new provider

    mqsicreateconfigurableservice TESTNODE_cheetah -c JDBCProviders \
    -o DB2Two -n connectionUrlFormat -v \
    "jdbc:db2://[serverName]:[portNumber]/[databaseName]:user=[user];password=[password];"
    
    mqsisetdbparms TESTNODE_cheetah -n jdbc::employeeIdentity -u db2admin -p passw0rd1940!
    
    mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n securityIdentity -v employeeIdentity
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n portNumber -v 50000
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n serverName -v 9.32.18.166
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n databaseType -v DB2
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n databaseName -v SAMPLE
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n jarsURL -v c:\db2jars
    
    mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n type4DatasourceClassName -v com.ibm.db2.jcc.DB2XADataSource
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n type4DriverClassName -v com.ibm.db2.jcc.DB2Driver
    
    mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n databaseVersion -v 10.1
     mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n environmentParms -v ""
    
    mqsichangeproperties TESTNODE_cheetah -c JDBCProviders -o DB2Two -n jdbcProviderXASupport -v true
    

    Restart the Integration Server

    Links