Run Bluetooth Low Energy tests
This section describes how to set up and run Bluetooth Low Energy tests using AWS IoT Device Tester for FreeRTOS.
Bluetooth tests are not required for core qualification. If you do not want to test your
device with FreeRTOS Bluetooth support you may skip this setup, be sure to leave the BLE feature
in device.json set to No
.
Prerequisites
-
Follow the instructions in First test of your microcontroller board.
-
A Raspberry Pi 4B or 3B+. (Required to run the Raspberry Pi BLE companion application)
-
A micro SD card and SD card adapter for the Raspberry Pi software.
Raspberry Pi setup
To test the BLE capabilities of the device under test (DUT), you must have a Raspberry Pi Model 4B or 3B+.
To set up your Raspberry Pi to run BLE tests
-
Download one of the custom Yocto images that contains the software required to perform the tests.
Note
The Yocto image should only be used for testing with AWS IoT Device Tester for FreeRTOS and not for any other purpose.
-
Flash the yocto image onto the SD card for Raspberry Pi.
-
Using an SD card-writing tool such as Etcher
, flash the downloaded
file onto the SD card. Because the operating system image is large, this step might take some time. Then eject your SD card from your computer and insert the microSD card into your Raspberry Pi.image-name
.rpi-sd.img
-
-
Configure your Raspberry Pi.
-
For the first boot, we recommend that you connect the Raspberry Pi to a monitor, keyboard, and mouse.
-
Connect your Raspberry Pi to a micro USB power source.
-
Sign in using the default credentials. For user ID, enter
root
. For password, enteridtafr
. -
Using an Ethernet or Wi-Fi connection, connect the Raspberry Pi to your network.
-
To connect your Raspberry Pi over Wi-Fi, open
/etc/wpa_supplicant.conf
on the Raspberry Pi and add your Wi-Fi credentials to theNetwork
configuration.ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 update_config=1 network={ scan_ssid=1 ssid="
your-wifi-ssid
" psk="your-wifi-password
" } -
Run
ifup wlan0
to start the Wi-Fi connection. It might take a minute to connect to your Wi-Fi network.
-
-
For an Ethernet connection, run
ifconfig eth0
. For a Wi-Fi connection, runifconfig wlan0
. Make a note of the IP address, which appears asinet addr
in the command output. You need the IP address later in this procedure. -
(Optional) The tests execute commands on the Raspberry Pi over SSH using the default credentials for the yocto image. For additional security, we recommend that you set up public key authentication for SSH and disable password-based SSH.
-
Create an SSH key using the OpenSSL
ssh-keygen
command. If you already have an SSK key pair on your host computer, it is a best practice to create a new one to allow AWS IoT Device Tester for FreeRTOS to sign in to your Raspberry Pi.Note
Windows does not come with an installed SSH client. For information about how to install an SSH client on Windows, see Download SSH Software
. -
The
ssh-keygen
command prompts you for a name and path to store the key pair. By default, the key pair files are namedid_rsa
(private key) andid_rsa.pub
(public key). On macOS and Linux, the default location of these files is~/.ssh/
. On Windows, the default location isC:\Users\
.user-name
-
When you are prompted for a key phrase, just press ENTER to continue.
-
To add your SSH key onto your Raspberry Pi so AWS IoT Device Tester for FreeRTOS can sign into the device, use the
ssh-copy-id
command from your host computer. This command adds your public key into the~/.ssh/authorized_keys
file on your Raspberry Pi.ssh-copy-id root@
raspberry-pi-ip-address
-
When prompted for a password, enter
idtafr
. This is the default password for the yocto image.Note
The
ssh-copy-id
command assumes the public key is namedid_rsa.pub
. On macOS and Linux, the default location is~/.ssh/
. On Windows, the default location isC:\Users\
. If you gave the public key a different name or stored it in a different location, you must specify the fully qualified path to your SSH public key using theuser-name
\.ssh-i
option tossh-copy-id
(for example,ssh-copy-id -i ~/my/path/myKey.pub
). For more information about creating SSH keys and copying public keys, see SSH-COPY-ID. -
To test that the public key authentication is working, run
ssh -i
./my/path/myKey
root@raspberry-pi-device-ip
If you are not prompted for a password, your public key authentication is working.
-
Verify that you can sign in to your Raspberry Pi using a public key, and then disable password-based SSH.
-
On the Raspberry Pi, edit the
/etc/ssh/sshd_config
file. -
Set the
PasswordAuthentication
attribute tono
. -
Save and close the
sshd_config
file. -
Reload the SSH server by running
/etc/init.d/sshd reload
.
-
-
-
Create a
resource.json
file.-
In the directory in which you extracted AWS IoT Device Tester, create a file named
resource.json
. -
Add the following information about your Raspberry Pi to the file, replacing
rasp-pi-ip-address
with the IP address of your Raspberry Pi.[ { "id": "ble-test-raspberry-pi", "features": [ {"name":"ble", "version":"4.2"} ], "devices": [ { "id": "ble-test-raspberry-pi-1", "connectivity": { "protocol": "ssh", "ip": "
rasp-pi-ip-address
" } } ] } ] -
If you didn't choose to use public key authentication for SSH, add the following to the
connectivity
section of theresource.json
file."connectivity": { "protocol": "ssh", "ip": "
rasp-pi-ip-address
", "auth": { "method": "password", "credentials": { "user": "root", "password": "idtafr" } } } -
(Optional) If you chose to use public key authentication for SSH, add the following to the
connectivity
section of theresource.json
file."connectivity": { "protocol": "ssh", "ip": "
rasp-pi-ip-address
", "auth": { "method": "pki", "credentials": { "user": "root", "privKeyPath": "location-of-private-key
" } } }
-
-
FreeRTOS device setup
In your device.json
file, set the BLE
feature to
Yes
. If you are starting with a device.json
file from
before Bluetooth tests were available, you need to add the feature for BLE to the
features
array:
{ ... "features": [ { "name": "BLE", "value": "Yes" }, ... }
Run the BLE tests
After you have enabled the BLE feature in device.json
, the BLE
tests run when you run devicetester_
without specifying a group-id.[linux | mac |
win_x86-64]
run-suite
If you want to run the BLE tests separately, you can specify the group ID for BLE:
devicetester_
.[linux | mac | win_x86-64]
run-suite
--userdata path-to-userdata
/userdata.json --group-id
FullBLE
For the most reliable performance, place your Raspberry Pi close to the device under test (DUT).
Troubleshoot BLE tests
Make sure you have followed the steps in First test of your microcontroller board. If tests other than BLE are failing, then the problem is most likely not due to the Bluetooth configuration.