Sometimes we look for what will be the best demo for BLE operation between mobile device and peer device. Recently Blinky is one of perfect application, but I suggest one more interesting example between mobile game based on Android and nRF51-DK or nRF52-DK as a controller.
-
Environment
You may know Digital Bird already introduced in our Github, which was created as a part of BBC Make it Digital program with microbit. So this will be a nice game to operate with DK. https://github.com/NordicSemiconductor/Android-Digital-Bird
Requirements
-. Android phone or tablet able to run the game.
-. nRF51 or nRF52 DK.
-. nRF5_SDK 11.0.0 (older one also fine).
-
Base application on peer device(DK side)
To make simpler, I used sample application, blinky ( nRF5_SDK_11.0.0_89a8197\ examples\ble_peripheral\experimental_ble_app_blinky) and minimized to modify the regacy codes.
Here is the step to follow. You don't have to be very knowledgeable about BLE. It's really simple.
Step 1. The most important one is to set service UUID ( 88400001-e95a-844e-c53f-fbec32ed5e54 )both side, so we will set it same in ble_lbs.h as below:
LBS_UUID_BASE {0x54, 0x5E, 0xED, 0x32, 0xEC, 0xFB, 0x3F, 0xC5,0x4E, 0x84, 0x5A, 0xE9, 0x00, 0x00, 0x40, 0x88} LBS_UUID_SERVICE 0x0001 And also set characteristic UUID (88400002-e95a-844e-c53f-fbec32ed5e54 ) as following: LBS_UUID_BUTTON_CHAR 0x0002
The characteristic value should be set with NOTIFY property, but fortunately, it's already set in the legacy codes and the property means it requires CCCD as well.
Step 2. The notification value should be sent when the button is pressed(0x01) and released(0x00), but it is also included in the legacy codes.
-
Build and program the binary to the DK.
-
Enjoy the game with the BLE controller.
To connect each other, RSSI must be higher than -35dBm, so please place the devices close.!
In short, the only things modified from the legacy codes is as following:
-. LBS_UUID_BASE, LBS_UUID_SERVICE, LBS_UUID_BUTTON_CHAR //ble_lbs.h
-. Removing irrelevant characteristic led_char_add(..) and led_desc_add(..) //ble_lbs.c
Everything else is same as it is..
Cheers, Brian