I took a circular saw to the Nextcloud box and you won’t believe what happened next!

Ok, ok.. sorry for the click-bait headline – but It is mainly true.. I recently got a Nextcloud box , it was pretty easy to set up and here are some great instructions.

But this box is not just a Nextcloud box, it is  a box of unlimited possibilities. In just a few hours I added to my personal cloud  a WIFI access point and  chat server.   So here are some amazing facts you should know about Ubuntu and snaps:

Amazing fact #1 – One box, many apps

With snaps you can transform you single function device, into a box of tricks. You can add software to extend its functionality after you have made it. In this case I created an WIFI access point and added a Rocketchat server to it.

You can release a drone without autonomous capabilities, and once you are sure that you have nailed, you can publish a new app for it… or even sale a pro-version autopilot snap.

You can add an inexpensive Zigbee and Bluetooth module to your home router, and partner with a security firm to provide home surveillance services.. The possibilities are endless.

Amazing fact #2 – Many boxes, One heart

Maybe an infinite box of tricks is attractive to a geek like me,  but what it is interesting is product makers is :make one hardware, ship many products.

Compute parts (cpu,memory,storage) make a large part of  bill of materials of any smart device. So does validation and integration of this components with your software base… and then you need to provide updates for the OS and the kernel for years to come.

What if I told you could build (or buy) a single multi-function core – pre-integrated with a Linux OS  and use it to make drones, home routers, digital advertisement signs, industrial and home automation hubs, base stations, DSLAMs, top-of-rack switches,…

This is the real power of Ubuntu Core, with the OS and kernel being their own snaps – you can be sure the nothing has changes in them across these devices, and that you can reliably update of them.  You not only are able to share validation and maintenance cost across multiple projects, you would be able to increase the volume of your part order and get a better price.

20160927_101912

How was the box of tricks made:

Ingredients for the WIFI ap:

 

I also installed the Rocketchat server  snap for the store.

 

PiGlow API: one small snap for humanity…

My first steps into snappifying, I have publish a RestApi for PiGlow (glowapi 0.1.2). I though it might be a good first step and mildly useful for people wanting to set up build notifications, twitter mentions, whatever you fancy!

You can find it in the webdm store…
Code is here: https://code.launchpad.net/~vtuson/+junk/glowapi

And here is how it works:
PiGlow Api exposes PiGlow in your board port 8000, so you can easy accessing by POST in port 8000.

remeber to do the hardware assign, something like: sudo snappy hw-assign glowapi.vtuson /dev/i2c-1

API calls , method POST:

v1/flare
turns all the leds on to max brightness
v1/on
turns all the leds on to med brigthness
v1/clear
turns off all leds
v1/legs/:id
turns all the leds in a leg (:id) to a given brightness
(if not specify it uses a default setting)
parms: intensity , range 0 to 1
eg: http://localhost:8000/v1/legs/1?intensity=0.3
v1/legs/:id/colors/:colid
turns on one led (colid) in a leg (:id) to a given brightness
(if not specify it uses a default setting)
parms: intensity , range 0 to 1
eg: http://localhost:8000/v1/legs/1/colors/green?intensity=0.3
v1/colors/:colid
turn on all leds for a color across all legs
if not specify it uses a default setting)
parms: intensity , range 0 to 1
eg: http://localhost:8000/v1/colors/green?intensity=0.3

ID ranges
legs range : 0 – 2
colors:
green
white
blue
yellow
orange
red

The fastest scope in the store… or Formula one in 5 minutes with Twitter

I recently blogged about making a scopes in 5 minutes using youtube. I have seen also a fair amount of new scopes being created using RSS. By far, my favourite way to use scopecreator is Twitter.

If you want to check a few examples, I have published previously twitter-based scopes like breaking news, la liga and a few others. Today, I give you Formula One:

f1 f1_2 f1_3

The interesting thing about twitter is that many brands upload minute by minute new updates, which make a really good source for scopes.

To create a Formula One scope,I started by going to twitter and creating a list under my scope account (you can use your personal account). The list contains several relevant “official” Formula One accounts.  Using Twitter, I can then update the sources by adding and removing accounts from the list without the user needing to download an update for the scope.

Again, it took me about 5 min to get a working version of the scope.  Here is what needed to do:

  • First, we followed Chris’ instructions to install the scope creator tool.
  • Once we had it set up on my laptop, I run:
    scopecreator create twitter vtuson f1
    cd f1
  • Next, I configured the scope. The configuration is done in a json file called manifest.json. This file describes the content of what you will publish later to the store. You need to care about: “title”, “description”, “version” and “mantainer”. The rest are values populated by the tool:
    scopecreator edit config
    {
    "description": "Formula One scope",
    "framework": "ubuntu-sdk-14.10",
    "architecture": "armhf",
    "hooks": {
    "f1": {
    "scope": "f1",
    "apparmor": "scope-security.json"
    }
    },
    "icon": "icon",
    "maintainer": "Your Name <yourname@packagedomain>",
    "name": "f1.vtuson",
    "title": "Formula One",
    "version": "0.2"
    }
  • The following step was to set up the branding: Easy! Branding is define on an .ini file. “Display name” will be the name listed on the “manage” window once installed, and also will be the title of your scope if you don’t use a “PageHeader.Logo”. the [Appearance] section describes the colours and logos to use when banding a scope.
    scopecreator edit branding
    [ScopeConfig]
    ScopeRunner=./f1.vtuson_f1 --runtime %R --scope %S
    DisplayName=Formula One
    Description=This is an Ubuntu search plugin that enables information from Yelp $
    Author=Canonical Ltd.
    Art=
    Icon=images/icon.png
    SearchHint=Search
    [Appearance]
    PageHeader.Background=color:///#D51318
    PageHeader.ForegroundColor=#FFFFFF
    PreviewButtonColor=#D51318
  • The final part is to define the departments (drop down menu) for the scope. This is also a json file and it is unique the twitter scope template. You can either use “list” or “account” (or both) as departments.  The id is the twitter handle for the list or the account. For lists you will need to specify in the configuration section what account holds the list. As I defined a single entry, the formula one scope will have no drop down menu.
    scopecreator edit channels
    {
    “departments”: [
    {
    “name”:”Formula One”,
    “type”:”list”,
    “id”:”f1″
    }
    ],
    “configuration”: {
    “list-account”:”canonical_scope”,
    “openontwitter”:”See in Twitter”,
    “openlink”:”Open”,
    “retweet”:”Retweet”,
    “favorite”: “Favourite”,
    “reply”:”Reply”
    }
    }

After this, the only thing left to do is replace the placeholder icon, with a relevant logo:
~/f1/f1/images/logo.png
And build, check and publish the scope:
scopecreator build

This last command generates the click file that you need to upload to the store. If you have a device (for example a Nexus4 or an emulator ), it can also install it so you can test it. If you get any issues getting the scope to run, you might want to check your json files on http://jsonlint.com/. It is a great web tool that will help you make sure your json doc is ship shaped!

It is super simple to create a scope for a twitter list! so what are you going to create next?

Make a scope for your YouTube channel in 5 minutes

Not long back Chris Wayne published a post about a scope creator tool.  Last week, I was visiting bq and we decided with Victor Gonzalez  that we should have a scope for Canal bq. The folks at bq do an excellent job at creating “how to” and “first steps” videos, and they have started publishing some for the bq Aquaris E4.5 Ubuntu Edition.

Here is a few screenshots of the scope that is now available to download from the store:

bq1bq2bq3bq4

The impressive thing is that it took us about 5 min to get a working version of the scope.  Here is what needed to do:

  • First, we followed Chris’ instructions to install the scope creator tool.
  • Once we had it set up on my laptop, we run:
    scopecreator create youtube com.ubuntu.developer.victorbq canalbq
    cd canalbq
  • Next, we configured the scope. The configuration is done in a json file called manifest.json. This file describes the content of what you will publish later to the store. You need to care about: “title”, “description”, “version” and “mantainer”. The rest are values populated by the tool:
    scopecreator edit config
    {
    "name": "com.ubuntu.developer.victorbq.canalbq",
    "description": "Canal bq",
    "framework": "ubuntu-sdk-14.10",
    "architecture": "armhf",
    "title": "Canal bq",
    "hooks": {
    "canalbq": {
    "scope": "canalbq",
    "apparmor": "scope-security.json"
    }
    },
    "version": "0.3",
    "maintainer": "Victor Gonzalez <anemailfromvictor@bq.com>"
    }
  • The following step was to set up the branding: Easy! Branding is define on an .ini file. “Display name” will be the name listed on the “manage” window once installed, and also will be the title of your scope if you don’t use a “PageHeader.Logo”. the [Appearance] section describes the colours and logos to use when banding a scope.
    scopecreator edit branding
    [ScopeConfig]
    DisplayName=Canal bq
    Description=Youtube custommized channel
    Author=Canonical Ltd.
    Art=images/logo.png
    Icon=images/logo.png
    SearchHint=Buscar
    LocationDataNeeded=true
    [Appearance]
    PageHeader.Background=color:///#000000
    PageHeader.ForegroundColor=#FFFFFF
    PreviewButtonColor=#FFFFFF
    PageHeader.Logo=./images/logo.png
  • The final part is to define the departments (drop down menu) for the scope. This is also a json file and it is unique the youtube scope template. You can either use “playlists” or “channels” (or both) as departments. The id PLjQOV_HHlukyNGBFaSVGFVWrbj3vjtMjd corresponds to a play list from youtube, with url= https://www.youtube.com/playlist?list=PLjQOV_HHlukyNGBFaSVGFVWrbj3vjtMjd
    scopecreator edit channels{
    “maxResults”: “20”,
    “playlists”: [
    {
    “id”: “PLjQOV_HHlukyNGBFaSVGFVWrbj3vjtMjd”,
    “reminder”:”Aquaris E4,5 Ubuntu Edition”
    },
    {
    “id”: “PLjQOV_HHlukzBhuG97XVYsw96F-pd9P2I”,
    “reminder”: “Tecnópolis”
    },
    {
    “id”: “PLC46C98114CA9991F”,
    “reminder”: “aula bq”
    },
    {
    “id”: “PLE7ACC7492AD7D844”,
    “reminder”: “primeros pasos”
    },
    {
    “id”: “PL551D151492F07D63”,
    “reminder”: “accesorios”
    },
    {
    “id”: “PLjQOV_HHlukyIT8Jr3aI1jtoblUTD4mn0”,
    “reminder”: “3d”
    }
    ]
    }

After this, the only thing left to do is replace the placeholder icon, with the bq logo:
~/canalbq/canalbq/images/logo.png
And build, check and publish the scope:
scopecreator build

This last command generates the click file that you need to upload to the store. If you have a device (for example a Nexus4 or an emulator ), it can also install it so you can test it. If you get any issues getting the scope to run, you might want to check your json files on http://jsonlint.com/. It is a great web tool that will help you make sure your json doc is ship shaped!

It is super simple to create a scope for a youtube channel! so what are you going to create next?

uBrick – a Lego Scope

Just a quick note to tell you that I have published a new scope called uBrick that brings you the awesomeness of Lego, as a catalogue powered by brickset.com, directly to your Ubuntu phone home screen.

I wrote the scope in Go cause I find it easier to work with for a quick scope ( took about 8 hours with interruptions over 2 days to write this scope).  The scope is now available at the store, just search for uBrick.

Here are some pics:

lego1lego2lego3 lego4

Also I have to congratulate the folks at Brickset for a very nice API, even if it is using SOAP 🙂

[Ubuntu Touch] Update to Logviewer

I am pleased to announced that Logviewer is now published in the Ubuntu Touch store.  The app no longer runs unconfined but uses “read_path” pointing to “/var/log/” and “/home/phablet/.cache/”. If you think there is another interested log path let me know and I will try to include it.

Also, one feature that landed by popular request is submitting a selected section of a log to pastebin , thanks to Popey for the image:

pastebin

[Ubuntu Touch] Logviewer

I have been recently doing some android development for Techfunder, one thing that I have found really useful when testing my app is using CatLog. CatLog allows you to check the app and system logs on the go. This is extremely useful when you have a crash while you are not close to your laptop.

This motivated me to look into writing a similar app for Ubuntu Touch. So here it is: LogViewer!

logslogsettingsunitylog

This app, like CatLog, is for developers and requires unconstrained running. You will need to install it manually:

  • Download click package from launchpad
  • transfer to your device and install:
  1. adb push com.ubuntu.developer.vtuson.logviewer_0.1_armhf.click /home/phablet/
  2. adb shell

  3. su phablet
  4. cd ~
  5. pkcon -p install-local com.ubuntu.developer.vtuson.logviewer_0.2_armhf.click

When you launch the app, you will get a list of .log files in /home/phablet/.cache/upstart/ , if you click on an specific log, it will be displayed in a similar manner to tail -f. You can pause the autoreading, clear the screen and copy to clipboard parts of the logs from the bottom menu.

You can also access other files, change font size of the logs and the size of the text buffered from the settings page.

You can see the code and contribute 🙂 in launchpad:

https://launchpad.net/logviewer

Developing for Android and Ubuntu – with the same phone

We announced today a new solution to dual boot Android and Ubuntu on the same device. Over the last few weeks I have recently blogged about a Contacts import app for Ubuntu and  Techfunder, an Android app for crowd funding projects. What I didn’t mention before is that I have been developing and testing both in the same device!

I have been dog-fooding and developing a small part of our dual boot solution for a couple weeks now.  During that time, I’ve not only been able to boot between Android and Ubuntu as a user, but also as an application developer.

Dual boot brings no compromise to the SDK experience of either operating system.  I run Ubuntu SDK with QTCreator and Android’s ADT (eclipse-based) on my 12.04 LTS laptop.  And while the SDK for Android is more mature and fully featured, I still find Ubuntu (an particularly QML) much faster to prototype apps.

Dual boot is also about making the application developers life easier and cheaper.  Having to buy extra devices for testing new apps can be a put you off. You can now develop for Ubuntu by jusr re-using your Android device.. without having to disrupt your android projects!  For example,  yesterday I was working on applications on both sides, and I was easily booting back and forward and collecting logs in each side.

I hope to see more integration in between both development environments, I think it will be particularly neat to have something like  Android Monitor tool (aka DDMS) working for both OSs.

Btw, I have just released version 2.0 of Techfunder! Including home screen widgets, search and more categories. Don’t forget to check it out:

Get it on Google Play

[Ubuntu QML] Importing Google Contacts

I have a lot of contacts in my phone… I am sure you will have more, but syncing over 500 contacts to Ubuntu phone using the command line for Syncevolution gets tedious.

So I wrote a little QML app to do the trick for you. Unfortunately, to run a system command the application has to run unconfined, so I have not yet submitted it to the store.

But if you want to install it yourself it is pretty simple:

  1. Download this file
  2. push the downloaded file to your phone, like so: adb push com.ubuntu.developer.vtuson.contactsimporter_0.9_armhf.click /home/phablet
  3. then run this to install it: adb shell “sudo -u phablet pkcon -p install-local  /home/phablet/com.ubuntu.developer.vtuson.contactsimporter_0.9_armhf.click”

You should be good to use it now, the app looks like this: (and if you want to check out the code is here)

contactsimp

Ubuntu Touch: Building and testing a QML extension

Hi,

I found myself trying to build a QML Ubuntu Touch app project that includes a qml c++ extension and I found that I some how stumble a bit along the way. So, here are some of my notes on how I got it done. Hope that helps.

Creating the project.

Using QtCreator, create a new project and select – QML Extension Library + Tabbed Touch.  I found that it was easier to change the QML side of things than start with an extension and then add the whole project structure.

Build and Run your project locally

In QtCreator click on projects.  In Build, I set up the build path as my project root path. In run,  the executable is “/usr/bin/qmlscene” (make sure there is no spaces trailing) and then Arguments is set to “-I  ../backend/modules $@ yourapp.qml”, with a working directory of “projectroot/app”

Now if you try to run your project it should build it locally and run your app. After that you are on a roll.

Build on target device

Click Ctrl+f11 should install the platform developer tools in your device. However, I how found that this lately does not work.

Instead from the terminal:

first we will need to make the image in your device writeable:
adb shell touch /userdata/.writable_image  --> and reboot the phone.
then:
cd /usr/share/qtcreator/ubuntu/scripts
adb devices
./device_developertools_install <device_id>

Now you are ready to build, so back to QtCreator:

Build>Ubuntu>Build Application on Device

This should build the application with only some test problems, but the main binaries would be created. To package your app you will need to get

/home/phablet/dev_tmp/<yourapp>/backend/modules/lib<yourlib>.so

Creating a click package

create a manifest standard manifest file. Manifest.json

{
"description": "your text",
"framework": "ubuntu-sdk-13.10",
"hooks": {
"yourappname": {
"apparmor": "yourappname.json",
"desktop": "yourappname.desktop"
}
},
"maintainer": "your name<yourname@yourmail.com>",
"name": "com.ubuntu.developer.yourname.yourappname",
"title": "yourappname",
"version": "0.1",
"architecture": "armhf"
}

You will also need a yourapp.desktop file:

[Desktop Entry]
Name=yourappname
Comment=description
Exec=qmlscene -I plugin $@ yourapp.qml
Icon=icon.png
Terminal=false
Type=Application
X-Ubuntu-Touch=true

Note that Exec= has a -I plugin part to it. This is very important, will see later.

Now yourapp.json file that contains your confinement profile:

{
"policy_groups": [
"networking"
],
"policy_version": 1
}

Now time to setup a folder with all this stuff, not that the plugin folder is going to contain your lib which your are importing with -I option on the desktop file:
myproject>
-./click/
--icon.png
--manifest.json
--yourapp.json
--yourapp.desktop
--./plugin/
---./yourlib/
----lib(yourlibname).so
----qmldir

Now you are ready to build from your project root folder:
click build ./click

This should create a .click file in your project folder.

Installing in your device

adb pull your.click /home/phablet/
adb shell
su phablet
cd ~
pkcon -p install-local your.click

This should be enough, but sometimes I find that you need to restart unity:
pkill unity8 (you might need sudo)