Friday, July 29, 2016

Using Scratch to control Raspberry Pi GPIO

In the previous post, I have built my first circuit and able to control the LED light using the gpio command:
http://pandaeatsbamboo.blogspot.hk/2016/07/the-hello-world-circuit-with-raspberry.html

Similar control can be done via Scratch, this is the official tutorial:
https://www.raspberrypi.org/blog/a-new-version-of-scratch-for-raspberry-pi-now-with-added-gpio/

This is a super simple Scratch script to illustrate this:


In this simple script, when you click the flag icon, it will set the gpio pin 17 (BCM) to 1 to switch on the LED.  When you press the spacebar on your keyboard, it will set the gpio pin 17 to 0 to switch off the LED.  With this you can incorporate the GPIO control into your own scratch script.  Give it a try!

Tuesday, July 26, 2016

The "Hello World" circuit with Raspberry - Single LED

Probably the "Hello World" of building a simple circuit with Raspberry is a single LED circuit.  So I decided to give it a try.  Not difficult frankly speaking, just to get all the ingredients together and there are plenty of goods tutorial if you spend a minute to google.

This is the official URL that you can first check it out:
https://www.raspberrypi.org/documentation/usage/gpio-plus-and-raspi2/

The circuit that I've used is exactly the same as the one you can find from the above URL, except that the "switch" is not a physical one, I used the gpio command to control it.


This is how it looks physically.  I've connected the GPIO pin to my breadboard using the female-to-male jumper cable.  Physical pin 11 is used for +ve and physical pin 6 is the ground pin.


Check out this link about breadboard.  An other things about building a circuit.


Some holes (usually the top and bottom rows) are connected in row and some (usually the middle) are in column.  

I've followed this link and used a 330 ohm resistor.  Check your LED spec to decide the correct resistor.  My LED works fine in a 11mA current circuit so 330 ohm resistor is good for my case.

Also check out the above link for LED.  The LED should have 2 legs, the longer leg is +ve and shorter leg is -ve.

One thing that I've spent quite some time is the pinout.  The BCM and physical board pin numbering is a bit confusing.  Say for my case, I've used physical pin 11, and in BCM numbering it is pin 17.  It will spend you hours to troubleshoot if you don't get it right.

You can use the gpio readall command to print out all its number convention and other details.




Another thing is, your physical GPIO pin 11 will be providing 3.3V power and you have to change its mode to OUT.  You can do it with the gpio command below:



gpio -1 means you are referring to the physical pinout numbering.

gpio -g means you are referring to the BCM pinout numbering.



This is a python script to switch on then off the LED light instead of using the gpio command.  You can find a similar script from the link provided above.  The only difference here is I am using GPIO.BOARD which means I'm referring to the physical pin number 11.


If you want to use the BCM numbering, then you can setmode to GPIO.BCM

Hope it will save you some time from troubleshooting layer 1 problem and to build up your first circuit with Raspberry!


Thursday, July 14, 2016

Raspberry Pi Cam + Cisco Spark - Motion Detection Demo

In the previous post, I've setup a Raspberry Pi Surveillance camera with Live streaming capability, and it can also save a video file when motion is detected.

http://pandaeatsbamboo.blogspot.com/2016/07/live-streaming-video-from-raspberry-pi.html

Spark integration is done too so that when motion is detected, a Spark message is posted with video files.  This is how it works:



Live streaming video from the Raspberry Pi with Camera v2

Just got my Raspberry Pi Camera v2, cannot wait to unbox and play with it.


I didn't get a good case to fit in the camera module, but it works.  :)


First of all you can start by taking a picture to make sure your camera is working fine:

raspistill -o image.jpg

To capture your first video, you can use the command raspivid:

raspivid -o video.h264

The video is in raw h.264 format.  It is fine to be played back by my omxplayer on the Raspberry, however if you want most of the other video players to play it, it will be better to convert the file into mp4.

sudo apt-get install gpac
MP4Box -fps 30 -add video.h264 video.mp4

For some application such as "motion", the motion detection and video streaming applications, it needs to recognised the video device as /dev/video0.  It is not the case by default for the Pi Camera.

To enable that, you need to run:

sudo modprobe bcm2835-v4l2

You can also put this command in /etc/rc.local so that the next reboot it will run automatically.

Motion is an open source motion detection and surveillance software which can help you to convert your Raspberry Pi into a home surveillance camera.  To start with, you can get the motion package:

sudo apt-get install motion

A few parameters under motion.conf that you can change, such as:

daemon on

which makes the motion run in background when you start the motion server.

You can also change the resolution in the conf file:
width 1280
height 720

change the following parameter to off so that you can access from host other than localhost:
stream_localhost off
webcontrol_localhost off

You can now access the stream via http::8081


And you will get a bunch of files in your home directory, make sure you have enough storage, if not probably you might need to do it off box to a NAS or whatever it is.  These files are created when motion is detected.



These are the links that I've used to aid my setup, listing all here for your reference:
http://www.instructables.com/id/Raspberry-Pi-as-low-cost-HD-surveillance-camera/?ALLSTEPS
http://www.makeuseof.com/tag/raspberry-pi-camera-module/
http://www.raspberrypi-spy.co.uk/2013/05/capturing-hd-video-with-the-pi-camera-module/

Wednesday, July 13, 2016

Expressway 8.8 registration - in action

In the previous post I've shared that the latest Expressway 8.8 supports endpoint registration:
http://pandaeatsbamboo.blogspot.com/2016/07/expressway-88-video-endpoint.html

I want to give it a try therefore I have upgraded my lab Expressway C to the latest version 8.8.  First of all there is a getting started wizard, and it will let you decide what role the Expressway will play and it will customize the UI accordingly and hide those that are not needed.



New license types are introduced (Room systems, Desktop systems), and it aligns with the UCM licensing model.  You will need UCL Enhanced / CUWL for desktop systems, and Telepresence room system license for Room systems.





I've some difficulties in using the endpoint activation wizard to register it to Expressway.  However it works well when I manually do it on the codec web admin page.  Under SIP configuration:



It is now registered, it can be seen from the codec admin page:


From the Expressway admin page:

This is how it looks on the DX70 itself:



Sunday, July 10, 2016

Using Web and Cisco Spark to control a Lego EV3 Robot


I have bought the Lego Mindstorms EV3 robot for more than 2 years, however I didn't spend any time on it until recently.  My daughter was sick and she has to stay at home, to keep her busy I built the EV3 together with her and we had run some pre-set missions to make the robot move and did some simple tasks.  It works great, except that I have to use the Mindstorm software to program it.


There is also another iPhone app to give you basic control of your robot, however it only accepts bluetooth connection, which makes me a lot less flexible compare with Wifi.




I have done some googling and find this post:
http://programmablebrick.blogspot.hk/2014/11/seanbot-ev3-robot-controlled-via-web.html

It looks interesting to me and I would want to make it my first EV3 project.  This is what I've done:

1. Get an microSD card.  So happen I've found one old 2GB card at home and I've used that for this project.  Flash it with the ev3dev OS following the instruction in this page, it is based on Debian Linux:
http://www.ev3dev.org/docs/getting-started/

2. Putting the microSD card into my EV3 and power it on.  It will not affect your original firmware in EV3, it is just like dual booting another OS.




3. Setting up the wireless network.  I've bought a wireless USB dongle from a local computer store, and it is less than US$9.  It works like a charm.  I did purposely pick one without 802.11ac, older model, claim to have Linux support.  Just bet on it, provided that it is so cheap.


4. Plug that into the USB port of EV3.  Use the screen on EV3 to choose my home wifi network, and entered the WPA PSK.  It is now connected, and able to access the Internet.


5. SSH to the box.  Use apt-get to get the packages, make sure you did a apt-get upgrade and update before you download the other packages.


sudo apt-get update; sudo apt-get upgrade
sudo apt-get install apache2 libapache2-mod-php5 unzip

6. Download the files in zip in this github project -  https://github.com/dwalton76/LegoEV3D4.  Unzip and copy these contents into your apache document root, in my case it is /var/www/html.  I download it to my Mac and then scp to the EV3, unzip it then copy it to the document root.

7. Install the python-ev3 on EV3 - https://github.com/topikachu/python-ev3.  My version of python is 2.7, therefore these are the commands that I've issued to my EV3.

Python 2.7

apt-get update
apt-get install virtualenv virtualenvwrapper python-setuptools python-smbus python-pil
source /etc/bash_completion.d/virtualenvwrapper
mkvirtualenv ev3_py27 --python=/usr/bin/python2.7 --system-site-packages
workon ev3_py27
easy_install -U python-ev3
type deactive to exit

8. Download the python-ev3 project in zip file - https://github.com/topikachu/python-ev3.  Similar to step 6, copy the content to the EV3.  In python-ev3, there is a ev3 folder.  Make sure this folder is copied to /var/www/html.  You will need to make sure you do this otherwise your LegoR2D2.py will not work.

9. Some python libraries dependencies need to be resolved, and this is what I've done:
easy_install web.py

10.  Start your apache using the command /etc/init.d/apache2 start.  Run the LegoR2D2 python scripts with sudo.  tcp/8080 will be listened after you run the script.


11. Launch your web browser.  I have tried Chrome and Firefox, for some reasons it only works on my Firefox, probably it is something specific to my laptop.  By the way this is what you will see:



12.  Click on the arrows to move your robot!  Is that it?  No!  How about we using a Cisco Spark Chatbot to control the EV3?











Friday, July 8, 2016

Raspberry Pi 3 + Cisco Spark - My home presence check

Just got my Raspberry Pi 3 a few days ago.  I know there are loads of projects that I can do with that, before knowing what I actually want to do, I want to try something quick and simple to keep the box warm.  I've an python scripts based on the post here:

http://www.instructables.com/id/Raspberry-Pi-Bluetooth-InOut-Board-or-Whos-Hom/

I modified it slightly to send a message to a Spark room when the Raspberry Pi detects my iPhone bluetooth mac address:

#!/usr/bin/python

import bluetooth
import time
import pyCiscoSpark

print "Home Attendance"

accesstoken="Bearer "
roomid=""

while True:
        currenttime=time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        print "Checking " + currenttime

        result = bluetooth.lookup_name('ff:ff:ff:ff:ff:ff', timeout=5)
        if (result != None):
                print "Danny: in"
                resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is at home now - " + currenttime)
                #print (resp_dict)
        else:
                print "Danny: out"
                resp_dict = pyCiscoSpark.post_message(accesstoken,roomid,"BT: Danny is NOT at home now - " + currenttime)

        time.sleep(60)

Replace ff:ff:ff:ff:ff:ff with your phone Bluetooth mac address.  I've also used the pyCiscoSpark.py in Github for posting a message to the Spark room:

https://github.com/brbester/pyCiscoSpark

So this is how it looks like when the script is running:



Spark room:

Wednesday, July 6, 2016

Precision 60 camera - Support SX20?

Precision 60 camera is a nice camera with good horizontal FoV:
http://www.cisco.com/c/en/us/products/collateral/collaboration-endpoints/telepresence-precision-cameras/datasheet-c78-734009.html



It is the widest FoV (80 degree) after the x2.5 camera has announced end of sales.  However it only support SX80, but NOT mid-range SX20.  So if you want to have a good horizontal FoV in a small room, you can either choose SX80 + P60, or MX200G2, because MX200G2 is using the 2.5x camera with 83 degree horizontal PoV.
MX200G2 datasheet:



Clearing CAPWAP AP config

Got multiple disks failure in my lab yesterday and fortunately not a lot of crucial VMs are affected.  One of those is the vWLC that I've used for my home AP.  As I've configured FlexConnect, the AP still works fine without the presence of the controller, however I still want to fix it otherwise I can't make changes in the future.

After rebuilding the vWLC with the same IP address, the AP failed to register to the new vWLC.

*Jul  5 10:56:02.000: %CAPWAP-5-DTLSREQSEND: DTLS connection request sent peer_ip: 192.168.24.70 peer_port: 5246
*Jul  5 10:56:02.015: %CAPWAP-1-SSC_CERT_AUTH_FAILED: Failed to authorize controller, SSC certificate validation failed.Peer certificate verification failed FFFFFFFF
*Jul  5 10:56:02.015: DTLS_CLIENT_ERROR: ../capwap/base_capwap/capwap/base_capwap_wtp_dtls.c:509 Certificate verified failed!
*Jul  5 10:56:02.015: %DTLS-5-SEND_ALERT: Send FATAL : Bad certificate Alert to 192.168.24.70:5246
*Jul  5 10:56:02.015: %DTLS-5-SEND_ALERT: Send FATAL : Close notify Alert to 192.168.24.70:5246

It didn't look right to me, and after trying a few things, this error didn't go away.  So what I have to do is to remove write erase the AP.  You can do it from console or telnet, if telnet is enabled.  I have got telnet enabled so I telnet to my AP, and use the following commands:

! This command is the most important, without this you can't use the clear capwap commands
debug capwap console cli

then

clear capwap private-config

Or you can also simply write erase the AP.  After that, configure option 43 hex in the dhcp pool.  I've only one controller so the prefix to add is f104, follows by the hex of my controller IP address 192.168.24.70.


option 43 hex f104.c0a8.1846

Too lazy to convert it manually, I just used the calculator here:

And now all works great!  Everything back to normal!

Monday, July 4, 2016

SX10 - H.323 Support in CE8.2

Besides expanding portfolio supports in Cisco Spark room services (check here), another added feature in CE8.2 is the SX10 H.323 support.  Previously SX10 only supports SIP for registration, in CE8.2 it supports H.323 as well so now in line with the rest of the video endpoints.

CE8.2 - Cisco Spark on-boarding

SX10N is the first endpoint that is supported to register to Cisco Spark cloud service.  Starting from CE8.2, all the remaining SX, MX and DX endpoints are supported to register to Cisco Spark cloud.  There are some considerations that you need to take if you want to register the endpoints to the Spark cloud.  According to the release notes:
http://www.cisco.com/c/dam/en/us/td/docs/telepresence/endpoint/software/ce8/release-notes/ce-software-release-notes-ce8.pdf

So it means that SX10 and SX20 are supported only when using TRC6 remote, but not Touch 10.  On SX80 only directing pairing of Touch 10 is supported, but not network pairing.  This is something that people will possibly miss out if not reading the release notes carefully.

Follow up - LDAP search features on UCM 11.5

In the previous post, I've tested the new LDAP search (LDAP-UDS proxy) features on UCM 11.5:

http://pandaeatsbamboo.blogspot.com/2016/06/new-ldap-search-function-in-ucm-115.html

In my test, this new features only work for those video endpoints such as DX, but not IP phones such as 8861, 7975 and 9971 that were hooked up to my lab UCM.  It was confirmed that the devices that support the UDS API search will support this feature, in the case of IP phones such as 8861, it is using CCMCIP and not UDS and that's why it doesn't work.  So to summarize:

Devices that support the UDS API such as DX:
- when I do an user search, it will use the UCM as an UDS proxy to query the LDAP servers, and will return the results from the LDAP servers.  No UCM local users will be searched.

Devices that do not support the UDS API, and using CCMCIP, such as 8861 IP phones
- when I do a corporate directory search, it will return the UCM local database, it could be a mix of LDAP synchronized users and UCM local users depends on the actual environment.  UCM will return the result instead of proxy the requests to the LDAP server at the backend.

UCM User facing features when publisher is down

Starting from UCM 6.0, the User facing features (such as CFA, hunt login / logout, extension mobility, DND, etc) can be changed while the publisher is down.  However you can only make the changes from the phone, but NOT the UCM admin page or UCM user page.

Take CFA as an example.  When the publisher is down, users can update CFA on their phones, but not from the CCM user portal.  Admin can't change it from the CCMAdmin page too.  All web based UCM admin and user updates must be done on the publisher.

Although the above is the expected behaviour, in my lab I can configure CFA for my phone on the self-service portal (CCMUser page) when the publisher is down.  However I can't cancel the CFA from the web self-service portal.  Hope this is only an issue specific to my lab as it doesn't make any sense to me.  The CFA activate and cancel works perfectly on the phone though, while the pub is down.

Sunday, July 3, 2016

Expressway 8.8 - Video Endpoint registration

This is something that catches my attention in the release notes.  In the previous release, one of the major difference between VCS and Expressway is the ability to register video endpoints.  While VCS allows endpoint registrations, Expressway works together with UCM and all the endpoints are registered to UCM as single call control.  For UCM centric customers with 3rd party video endpoints, they will need to deploy a pair of VCS just for 3rd party video endpoints registration.

Now with Expressway 8.8, it allows endpoint registrations, which means you can have your DX, SX and MX endpoints register directly to Expressway.  It also allows 3rd party endpoint registration, however for this release, only SIP endpoints are supported.  H323 will be supported in future releases.

The licensing model for Expressway registrations will follow the UCM UCL / CUWL / Telepresence room systems licensing, instead of the VCS way.  It allows you to starts small with relatively less investment.  It also makes it easier for existing UCM customers to understand this new licensing model on Expressway.

Can you run Expressway alone without UCM for video centric deployment?  Technically you can, however you will lose advance UCM capability such as Jabber, Extension Mobility, SNR, Shared Line, Multiline, VM/UM, etc.  If you want to have these capabilities in your environment, registering these endpoints to the UCM is suggested, with Expressway as your collaboration edge for B2B, MRA, CMR Cloud, etc.

Release notes:
http://www.cisco.com/c/dam/en/us/td/docs/voice_ip_comm/expressway/release_note/Cisco-Expressway-Release-Note-X8-8.pdf

Page 22:


Page 70:


Related post:
Collaboration Edge - Step-by-Step integration guide with UCM:
http://pandaeatsbamboo.blogspot.com/2014/06/collaboration-edge-expressway-step-by.html

Friday, July 1, 2016

New Wireless phone 8821 is now available

After a prolonged wait, the next generation of 7925 is released.  A few things noted from the datasheet, including hardened design with IP67 and MIL-STD-810G compliant, security enhancement by supporting SHA2 and SCEP, and better wireless radio by supporting 11ac.

8821 datasheet:
http://www.cisco.com/c/en/us/products/collateral/collaboration-endpoints/wireless-ip-phone-8821/datasheet-c78-737346.html?cachemode=refresh



8821-EX datasheet:
http://www.cisco.com/c/en/us/products/collateral/collaboration-endpoints/wireless-ip-phone-8821-ex/datasheet-c78-737347.html?cachemode=refresh


Warning: Less than a month to order add-on UCM licenses

Check this out, all of the version before 8.6 will be end of sale its add on license options which means you are not able to order add on license after 31 Jul 2016
https://communities.cisco.com/docs/DOC-57172



CSR 11.5 documentation is now live!

Documents are all here:
http://www.cisco.com/c/en/us/support/unified-communications/collaboration-systems-release-11-5/model.html

Updated Compatibility matrix
http://www.cisco.com/c/dam/en/us/td/docs/voice_ip_comm/uc_system/unified/communications/system/Compatibility/CSR-Compatibility-Matrix-InteractiveHTML.html