Creating Battery Level Indicator in Qt/QML using Icon Font


The purpose of this post is to create a battery charge level indicator in Qt/QML. For the buttery icon we’ll use Font Awesome, which is a free icon font, so that we don’t need to design the icon from scratch.

Here is the list of contents of this post.

Contents
– Steps
1. Download icon font and add to your project
2. Create “BatteryIcon” component
3. Use “BatteryIcon” component
– Summary
– Reference

 

Steps
1. Download icon font and add to your project

1-1. Download Font Awesome from here and extract the zip file.

1-2. Copy .ttf file to your Qt Creator project folder.

1-3. Then, right-click on “qml.qrc” and select “Add Existing Files…” in the left side bar.

1-4. Select .ttf file to add.

 

2. Create “BatteryIcon” component

2-1. In your Qt Creator project, click on “Resources” in the left side bar.

2-2. Then, right-click on “qml.qrc” and select “Add New…”

2-3. Select “Qt” and “QML File (Qt Quick2)”.

2-4. Input “BatteryIcon” as the file name and click on “Finish”.

2-5. Copy below lines to the file.

— BatteryIcon.qml —

import QtQuick 2.0

Item {
    property string iconColor
    property int iconSize: 32 // in pixcel
    property int level // 0-4 levels

    function getUnicode()
    {
        if (level == 0)
            return "\uf244" // fa-battery-empty
        else if (level == 1)
            return "\uf243" // fa-battery-quarter
        else if (level == 2)
            return "\uf242" // fa-battery-half
        else if (level == 3)
            return "\uf241" // fa-battery-three-quarters
        else if (level == 4)
            return "\uf240" // fa-battery-full
        else
            return "\uf244" // fa-battery-empty
    }

    Text {
        font.family: fontAwesome.name
        color: iconColor
        font.pixelSize: iconSize
        text: getUnicode()
    }

    FontLoader { id: fontAwesome; source: "qrc:/fontawesome-webfont.ttf" }
}

2-6. Click on “qml.qrc” and “/” in the left side bar.

2-7. Right-click on the .ttf file and select “Copy URL …”.

2-8. Update URL on Line 31 with the URL copied at Step 2-7.

 

3. Use “BatteryIcon” component

3-1. Use BatteryIcon component like below example. It has three properties, icon color, icon size (in pixel) and battery level from 0 to 4 (0:empty, 1:quarter, 2:half, 3:three quarters and 4:full).

BatteryIcon{
    iconSize: 48
    iconColor: "blue"
    level: 2
}

If everything is fine, it will show like below battery icon.

 

Summary

I needed some icons for a project but was hesitant to create because I thought it’s gonna take some time. Then I found this article. It was really helpful for me at the situation, and Font Awesome is, yes, awesome! Using icon fonts for QML is makes sense. It requires less work, and it works perfectly.

 

Reference

– How to make a quick custom Qt/QML checkbox using icon fonts
https://medium.com/@eduard.metzger/how-to-make-a-quick-custom-qml-checkbox-using-icon-fonts-b2ffbd651144

– Font Awesome — The iconic font and CSS toolkit
http://fontawesome.io/icons/

 

 

Creating Bluetooth Beacon with Raspberry Pi by using Bluetooth Developer Studio


This post shows how to make a Raspberry Pi a Bluetooth Beacon by using Bluetooth Developer Studio and its Beacon plugin. Bluetooth Developer Studio is a free application development tool from Bluetooth SIG and with Beacon plugin, it generates a script file which makes a Raspberry Pi a Bluetooth beacon.

The steps below basically follow a tutorial (Turning your Raspberry Pi into a Beacon using Bluetooth Developer Studio v1.0) which is included in Beacon plugin for Bluetooth Developer Studio but are simplified for my learning purpose. Please note, this is not very practical but rather kind of “getting started with” Bluetooth Developer Studio and Bluetooth Beacon.

Here are the contents of this post.

 

Prerequisites

  • Raspberry Pi
    Assuming your Raspberry Pi is up and running. If it’s not already, please set it up first. Raspberry Pi 3 B+ or Raspberry Pi Zero W is recommended since they have a built-in Bluetooth chip. If you want to use other model which doesn’t have Bluetooth chip, you need a Bluetooth Low Energy USB dongle such as this.
  • Windows PC (Windows 7 or higher)
    Bluetooth Developer Studio works on only Windows 7 and higher.

 

Steps
1. Install Bluetooth Developer Studio and Beacon plugin
1-1. Download Bluetooth Developer Studio from here. As of 9/2/2017, the latest version is 1.1. It requires registration to download.

1-2. Install Bluetooth Developer Studio by following the Setup wizard.

1-3. Download Beacon plugin from here.

1-4. Unzip the downloaded file and go to \beacon-1\tutorial\RaspberryPi\starter-files.

1-5. Then, copy “beacon-plugin” folder into Bluetooth Developer Studio’s plugins folder.
(e.g. “C:\Program Files (x86)\Bluetooth SIG\Bluetooth Developer Studio\Plugins”)

1-6. Go into the newly copied folder (i.e. “beacon-plugin”) and open “plugin.js” with a text editor.

1-7. Search the lines below and change “true” to “false” on the if statement.

// set the true / false value on the following line to true to read in the data from the service and false to read in from GAP settings
if (false)

* Note: Change the permissions to modify the file if needed.

 

2. Create Beacon Profile
2-1. Launch Bluetooth Developer Studio.

2-2. Create a new project from “FILE” > “NEW”

2-3. Enter “Beacon” in the “NAME” field of “NEW PROJECT” window.

2-4. Enter “org.bds.beacon” in the “NAMESPACE” field, then click “OK” button.

2-5. Click on “New Profile”, change the name to “Beacon”, then click “SAVE”.

2-6. Click on the “Custom Service” button.

2-7. Click on “Beacon new service” and change it to “Beacon”, then, “SAVE”.

2-8. Click on “GAP” button

2-9. Enter beacon data as below and click on “DONE”.
TX Power : “-127″
Manufacturer Specific Data” : “ffeeddccbbaa99887766554433221100facefeed”

2-10. From the menu bar, select “FILE” > “SAVE” to save the profile.

 

3. Generate Beacon script

3-1. From the top menu, select “TOOLS” > “GENERATE CODE”.

3-2. Select “Beacon” plugin and click on “GENERATE”.

 

3-3. After “Code generated successfully”, check on “Open output location when finished”, then click on “FINISH”.

The folder which contains the generated script file will be opened automatically.

 

4. Execute Beacon script on Raspberry Pi

4-1. Copy the generated “Beacon.sh” script to Raspberry Pi’s home directory. (e.g. via USB drive, scp)

4-2. Open terminal on Raspberry Pi and add execute access to the script.

sudo chmod +x ~/Beacon.sh

4-3. Run the script.

. ~/Beacon.sh

If it worked you should be able to see output such as:

$ . ~/Beacon.sh
hci0:	Type: BR/EDR  Bus: UART
	BD Address: xx:xx:xx:xx:xx:xx  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING 
	RX bytes:7550 acl:0 sco:0 events:716 errors:0
	TX bytes:22202 acl:0 sco:0 commands:716 errors:0

< HCI Command: ogf 0x08, ocf 0x0008, plen 32
  1F 02 01 1A 1B FF 18 01 BE AC FF EE DD CC BB AA 99 88 77 66 
  55 44 33 22 11 00 FA CE FE ED 81 01 
> HCI Event: 0x0e plen 4
  01 08 20 00 

If you get an error like,

-bash: ./Beacon.sh: /bin/bash^M: bad interpreter: No such file or directory

and/or,

Beacon.sh: line 2: $'\r': command not found

that is because the script file has Windows style line endings and bash doesn’t understand it. You can fix the error by changing the line endings from Windows style to Unix style by the following command.

sed -i 's/\r$//' Beacon.sh

 

5. Verify
You can check if it’s really broadcasting the beacon data by using a smartphone app such as “BLE Scanner” on Android.

 

 

Shrinking Raspbian OS Image


I’ve been using Raspberry Pi for my projects and have many Raspbian OS image backups. It’s eating up storage space on my PC, so I decided to shrink those images so that I can create more space. I’ve found several sites explain how to do it and writing this post mostly for myself to repeat the process since it’s a little complicated.

If you will follow the steps, please do so at your own risk. Manipulating partition may cause damage to your system.

 

Contents
– Assumptions
– Steps
1. Find out SD card mount points on your PC
2. Create OS image from SD card
3. Shrink root partition
4. Update partition table
5. Trim empty space from the image file
– Summary
– Reference

 

Assumptions

Hardware

  • Linux PC (I used Ubuntu 16.04)
  • Micro-SD card reader like this (in case your PC doesn’t have SD card slot)
  • Micro-SD card which contains Raspbian OS you want to shrink

Software

  • GParted (Partition management tool)
    If it’s not installed on your PC, please do so.
sudo apt-get install gparted -y

 

Steps
1. Find device name of SD card on your PC
1-1. Before insert SD card into your PC, check all the mounted devices by typing:

df -h

Output should be like this:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           385M  6.2M  379M   2% /run
/dev/sda1       290G   24G  252G   9% /
tmpfs           1.9G   24M  1.9G   2% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           385M   68K  385M   1% /run/user/1000

1-2. Then, insert the SD card and check it again.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           385M  6.2M  379M   2% /run
/dev/sda1       290G   24G  252G   9% /
tmpfs           1.9G   24M  1.9G   2% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           385M   68K  385M   1% /run/user/1000
/dev/sdb2        30G  3.3G   25G  12% /media/max/037616fd-28fe-4652-8248-2042ea30b929
/dev/sdb1        42M   21M   21M  51% /media/max/boot

1-3. Compare the outputs. Since Raspbian has two partitions, there should be two new lines added. In the example above, /dev/sdb1 and /dev/sdb2. Also, the device name of the SD card is /dev/sdb. The last character in a mount point represents the partition number.

 

2. Create OS image from SD card
2-1. First, unmount the partitions.

sudo umount /dev/sdb1 /dev/sdb2

2-2. Copy the image from SD card to PC. In the below example, please replace “/dev/sdb” with device name which you found out in above steps, and “raspbian.img” with anything you want for the file name on your PC.

sudo dd bs=4M if=/dev/sdb of=raspbian.img status=progress conv=fsync

2-3. Change owner of the newly created image file.

sudo chown $USER:$USER raspbian.img

 

3. Shrink root partition
3-1. Raspbian has two partitions, “boot” and “root”. “boot” is very small and it’s not worth to compress. So, let’s find out the start sector of “root” partition by typing:

fdisk -l raspbian.img

The output should be like this. Take a note of value of “Start” of the bigger partition. It’s start sector of “root” partition. In example below, it’s “94208”.

$ fdisk -l raspbian.img
Disk raspbian.img: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xede1dcd1

Device        Boot Start      End  Sectors  Size Id Type
raspbian.img1       8192    93814    85623 41.8M  c W95 FAT32 (LBA)
raspbian.img2      94208 62333951 62239744 29.7G 83 Linux

3-2. Create a loopback device with the Raspbian image so that GParted can recognize the image as device. Please replace “94208” with the value you got in previous step.

sudo losetup /dev/loop0 raspbian.img -o $((94208*512))

3-3. Launch GParted.

sudo gparted /dev/loop0

It will open a new window.

3-4. Click “/dev/loop0” and select “Partition” > “Resize/Move”.

3-5. Then, change “New size” of the image.
Note: This step is a little tricky. It seems it requires some margin but I couldn’t figure out how much margin it exactly requires. Seems it differs based on the “Minimum size”. I needed to do trial-and-error till successfully complete resizing.

3-6. Click on “Resize” button.

3-7. Select “Edit” > “Apply All Operations”.
Note : If you get “resize2fs: New size smaller than minimum” error, go back to step 3-4.

3-8. Click on “Save Details”.

3-9. Open saved “gparted_details.htm” file on browser and search a line starts with “resize2fs”. The value followed by “K” is new size for “root” partition. Take a note of this value. In example below, it’s “4934656K”.

resize2fs -p /dev/loop0 4934656K  00:00:00    ( SUCCESS )

3-10. Click on “Close” button and close GParted.

3-11. Remove the loopback device.

sudo losetup -d /dev/loop0

 

4. Update partition table
4-1. Create a new loopback device for the whole image

sudo losetup /dev/loop0 raspbian.img

4-2. Launch fdisk to update partition table.

sudo fdisk /dev/loop0

4-3. Delete 2nd partition (i.e. root partition).
4-3-1. Type “d” and enter.

Command (m for help): d

4-3-2. Type “2” and enter to select 2nd partition.

Partition number (1,2, default 2): 2

4-4. Create new 2nd partition.
4-4-1. Type “n” and enter to create new partition.

Command (m for help): n

4-4-2. Type “p” and enter to make it a primary partition.

Select (default p): p

4-4-3. Type “2” and enter to select partition number.

Partition number (2-4, default 2): 2

4-4-4. Enter the start sector of 2nd partition. (See step 3-1)

First sector (2048-31116287, default 2048): 94208

4-4-5. Type “+” and the new size for 2nd partition (see step 3-9).

Last sector, +sectors or +size{K,M,G,T,P} (94208-62333951, default 62333951): +4934656K

4-5. Apply all the changes by typing “w” and enter.

Command (m for help): w

Then you’ll get a warning message like below but you can ignore it.

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

 

5. Trim empty space from the image file
5-1. Find out the end sector of the 2nd partition by using fdisk.

sudo fdisk -l /dev/loop0

The output should be like this:

$ sudo fdisk -l /dev/loop0
Disk /dev/loop0: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x366b9010

Device       Boot Start     End Sectors  Size Id Type
/dev/loop0p1       8192   93814   85623 41.8M  c W95 FAT32 (LBA)
/dev/loop0p2      94208 9963519 9869312  4.7G 83 Linux

Note down the end sector value of 2nd partition. (i.e. “9963519”)

5-2. Remove the loopback device.

sudo losetup -d /dev/loop0

5-3. Trim the empty space from the image file. Please replace “9963519” in the example below with your end sector value from the previous step.

truncate -s $(((9963519+1)*512)) raspbian.img

That’s it. Now the Raspbian image has been shrinked. In the example below, the size is now 1.8 GB. (originally it’s 30 GB)

$ ls -lh raspbian.img 
-rw-r--r-- 1 max max 4.8G Sep 10 21:36 raspbian.img

 

Summary
It’s not very easy but it can definitely reduce the size of the SD card image. If you want more free space on your PC, you can zip the image file.

zip raspbian.zip raspbian.img

Here is an example (32 GB SD card) of comparison between before, after, and after + zip.

-rw-r--r-- 1 max max 30G Sep 6 16:19 raspbian-before.img
-rw-r--r-- 1 max max 4.8G Sep  6 19:18 raspbian-after.img
-rw-rw-r-- 1 max max 1.9G Sep  6 19:22 raspbian-after.zip

 

To write Raspbian image (.img or .zip) to SD card, please see this.

 

Reference
– Shrinking Raspberry Pi SD Card Images
http://www.aoakley.com/articles/2015-10-09-resizing-sd-images.php

– How to BackUp and Shrink Your Raspberry Pi Image
http://www.instructables.com/id/How-to-BackUp-and-Shrink-Your-Raspberry-Pi-Image/

– Installing operating system images on Linux
https://www.raspberrypi.org/documentation/installation/installing-images/linux.md

 

 

Writing Raspbian OS Image to SD Card on Linux


This is how to write Raspbian OS image to SD card by using Linux command line. Since the steps below use “dd” command which may cause damage to your system if used wrongly, please be careful about the usage.

 

Contents
– Assumptions
– Steps
1. Download Raspbian OS Image
2. Find device name of SD card on Linux
3. Write Raspbian OS image to SD card
– Reference

 

Assumptions

  • Raspberry Pi board
  • Micro SD card
  • Linux PC
  • Micro SD card adapter

 

Steps
1. Download Raspbian OS Image
1-1. Download Raspbian OS zip archive from the official site to your Linux PC.

 

2. Find device name of SD card on Linux
2-1. Before insert SD card into your PC, check all the mounted devices by typing:

df -h

Output should be like this:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           789M  9.5M  780M   2% /run
/dev/sda1       451G   17G  412G   4% /
tmpfs           3.9G   61M  3.8G   2% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           789M   72K  789M   1% /run/user/1000

2-2. Then, insert the SD card and check it again.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           789M  9.5M  779M   2% /run
/dev/sda1       451G   17G  412G   4% /
tmpfs           3.9G   61M  3.8G   2% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           789M   72K  789M   1% /run/user/1000
/dev/sdb2        30G  8.4G   20G  31% /media/max/037616fd-28fe-4652-8248-2042ea30b929
/dev/sdb1        42M   21M   21M  51% /media/max/boot

2-3. Compare the outputs. Newly added device is for the SD card. Since the last part (“1”) is the partition number, the device name for whole SD card is /dev/sdb. Take a note of the device name.

2-4. Unmount the SD card partition(s). Type below, replacing /dev/sdb1 with your SD card device name.

umount /dev/sdb1

 

3. Write Raspbian OS image to SD card
3-1. Type below to unzip the archive and write it to SD card. Please replace “2017-08-16-raspbian-stretch.zip” with the file name of your OS image archive and “/dev/sdb” with your SD card device (see step 2-3).

unzip -p 2017-08-16-raspbian-stretch.zip | sudo dd of=/dev/sdb bs=4M status=progress conv=fsync

In case you are writing .img file, type below:

sudo dd bs=4M if=2017-08-16-raspbian-stretch.img of=/dev/sdb status=progress conv=fsync

 

Reference
– INSTALLING OPERATING SYSTEM IMAGES ON LINUX
https://www.raspberrypi.org/documentation/installation/installing-images/linux.md

– RPi Easy SD Card Setup
http://elinux.org/RPi_Easy_SD_Card_Setup

 

 

Enabling Hands-Free Profile on Raspberry Pi (Raspbian Stretch) by using PulseAudio


The purpose of this post is to enable Bluetooth Handsfree Profile (HFP) with PulseAudio on Raspbian Stretch so that Raspberry Pi can act like as a handsfree speaker phone or a handsfree car kit. This is an updated version of this post. When I wrote the previous post, I was using Raspbian Jessie and some steps needed to be updated to apply Raspbian Stretch.

There is one thing needs to be mentioned before start. The original plan was to use Raspberry Pi3’s on-board Bluetooth chip for this project. Unfortunately, it didn’t work. It seems that the problem is related with the chip. So, we have to use a Bluetooth dongle instead.

 

Here is the list of contents of this post.

Contents
– Prerequisites
– Steps
1. Preparations
2. oFono Installation
3. PulseAudio Installation & Settings
4. Connecting Your Phone
5. Making a Call
– Summary
– Reference

 

Prerequisites

Below are the required application versions to enable Bluetooth HFP according to PulseAudio release note.

  • Bluez 5.0 or later (v5.43 is pre-installed in Stretch)
  • PulseAudio 6.0 or later (not pre-installed in Stretch, but it supports v10.0)
  • oFono 1.13 or later (not pre-installed in Stretch, but it supports v1.18)

 

Steps
1. Preparations
1-1. Connect Bluetooth dongle and USB sound card with Raspberry Pi.
1-2. Connect the microphone and speakers to 3.5 mm audio jacks on the USB sound card.
1-3. Boot up Raspberry Pi Board.
1-4. As described, we don’t use on-board Bluetooth chip. So we’ll disable it. To do that, open “/etc/modprobe.d/raspi-blacklist.conf”.

sudo nano /etc/modprobe.d/raspi-blacklist.conf

1-5. Add lines below and save.

blacklist btbcm
blacklist hci_uart

1-6. According to a Raspberry Pi Foundation blog post, Bluetooth audio is handled by ALSA through bluez-alsa in Stretch. However, since in this post we are using PulseAudio, let’s uninstall bluez-alsa.

sudo apt-get purge bluealsa -y

1-7. Then reboot the board.

sudo reboot

1-8. After reboot, check dmesg and make sure there is no Bluetooth-related errors.

dmesg | grep -i bluetooth

1-9. Also, make sure hci0 is UP.

hciconfig

The result should be like this:

hci0:    Type: BR/EDR  Bus: USB
    BD Address: XX:XX:XX:XX:XX:XX  ACL MTU: 310:10  SCO MTU: 64:8
    UP RUNNING
    RX bytes:622 acl:0 sco:0 events:38 errors:0
    TX bytes:1437 acl:0 sco:0 commands:38 errors:0

If it’s DOWN for some reason, then turn it up.

sudo hciconfig hci0 up

 

2. oFono Installation
2-1. oFono is not installed by default, so let’s install it.

sudo apt-get install ofono -y

2-2. Make sure if it’s successfully installed.

$ ofonod --version
1.18

2-2. Then, start the service.

sudo systemctl start ofono

You can check the service running like below.

$ systemctl -a |grep ofono
  ofono.service     loaded    active   running   Telephony service

 

3. PulseAudio Installation & Settings
3-1. In Raspbian Stretch, PulseAudio is not pre-installed. Install PulseAudio and its Bluetooth module:

sudo apt-get install pulseaudio pulseaudio-module-bluetooth -y

3-2. Check the version. It should be v10.0 (or higher).

$ pulseaudio --version
pulseaudio 10.0

3-3. Open “/etc/pulse/default.pa”.

sudo nano /etc/pulse/default.pa

3-4. Add “headset=ofono” on the line of ‘module-bluetooth-discover’.

load-module module-bluetooth-discover headset=ofono

3-5. Restart Raspberry Pi.

sudo reboot

 

4. Connecting Your Phone
4-1. Launch bluetoothctl.

bluetoothctl

4-2. Then, input below commands.

power on
agent on
default-agent

4-3. Start searching your phone. Make sure your phone is discoverable.

scan on

4-4. After detecting your phone, turn scan off.

scan off

devices command shows a list of found devices.

[bluetooth]# devices
Device XX:XX:XX:XX:XX:XX Galaxy S7

4-5. Then, pair, trust and connect to your phone by specifying the Bluetooth device address (in this case it’s “XX:XX:XX:XX:XX:XX”, please replace it wity your device’s address).

pair XX:XX:XX:XX:XX:XX
trust XX:XX:XX:XX:XX:XX
connect XX:XX:XX:XX:XX:XX

If everything is ok, you should see “successful” at the end of the result for each command like below.

[bluetooth]# pair XX:XX:XX:XX:XX:XX
...
Pairing successful
[bluetooth]# trust XX:XX:XX:XX:XX:XX
...
trust succeeded
[bluetooth]# connect XX:XX:XX:XX:XX:XX
...
Connection successful

 

5. Making a Call
To make a call, you can use oFono test scripts which is included in the source code.
5-1. First, download the source and extruct.

wget https://www.kernel.org/pub/linux/network/ofono/ofono-1.18.tar.gz
tar -xzvf ofono-1.18.tar.gz

5-2. Then, you can make a call by:

python ./ofono-1.18/test/dial-number 8586515050

If you want to end the call, then type:

python ./ofono-1.18/test/hangup-active

 

Summary
Since Raspbian Stretch supports PulseAudio v10.0, the steps are now a little simpler than previous one. I confirmed both sending and receiving audio are fine during a hands free call. I confirmed Bluetooth audio streaming (A2DP) is working too.


Update (May 2, 2018):
The steps to enable equalizer on HFP sending audio is newly posted.


 

Reference

– Raspbian Stretch has arrived for Raspberry Pi
https://www.raspberrypi.org/blog/raspbian-stretch/

– Connect Bluetooth Headset To Raspberry Pi 3 (A2DP & HSP)
http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp

– PulseAudio 6.0 Release Notes –freedesktop.org
https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/6.0/

– PulseAudio Documentation –freedesktop.org
https://freedesktop.org/wiki/Software/PulseAudio/Documentation/