5 Samples to Develop with LinkIt 7697 BLE Functions

(The original Chinese version of this article was written by K.C. Chang and published on MakerPRO)
LinkIt 7697 is a MediaTek MT7697 SOC-based development board, which not only supports Wi-Fi and BLE connectivity, but also supports Arduino development boards and peripheral libraries. The support considerably simplifies the development process. (For source code, please refer to Arduino Add-On for LinkIt SDK v4.)
This article will demonstrate how to utilize Arduino IDE to develop LinkIt 7697 BLE functions.
Preparation
Before starting the development, please refer to the article to know more about the development environment preparation.
Sample Codes
The Arduino libraries of LinkIt streamline the development process. This article will illustrate how to use the functions through the samples. After the installation of the extension of LinkIt 7697 in Arduino IDE, users can get the samples by clicking on Arduino IDE’s menu, File, Examples and LBLE successively. The following will merely introduce some of the samples and provide the link to full source code. Let’s see what we can develop with LinkIt 7697 and a cellphone.
iBeacon (Apple)
iBeacon is a protocol developed by Apple. iBeacon-compatible hardware devices broadcast identifiers to nearby portable devices like smartphones and tablets, enabling them to perform corresponding actions. iBeacon is usually used for push notifications and indoor positioning.
Executing this example will enable LinkIt 7697 to become an iBeacon advertiser:
#include #include void setup() { Serial.begin(9600); LBLE.begin(); while (!LBLE.ready()) { delay(100); } Serial.println("BLE ready"); LBLEAdvertisementData beaconData LBLEUuid uuid("E2C56DB5-DFFB-48D2-B060-D0F5A71096E0"); beaconData.configAsIBeacon(uuid, 01, 02, -40); LBLEPeripheral.advertise(beaconData); } void loop() { delay(3000); }
Full Source Code
Search with smartphone apps after the sample is executed (Here we use iBeacon & Eddystone Scanner)

It connects! You can find the signal strength as the picture shows above, and figure out the approximate distance between your smartphone and beacon.
Eddystone (Google)
Eddystone is a BLE profile issued by Google in 2015, which can be used in many beacon applications. Executing this example will enable LinkIt 7697 to become an Eddystone URL advertiser. (The source code is similar to the foresaid iBeacon)
... LBLEAdvertisementData beaconData; beaconData.configAsEddystoneURL(EDDY_HTTPS, "makerpro.cc", EDDY_URL_NONE); LBLEPeripheral.advertiseAsBeacon(beaconData); ...
Full Source Code
Search with smartphone apps after the sample is executed:

As you can see, the beacon data include URL. The distance become more precise.
BLE Peripheral
There are two parts in BLE: the central and the peripheral.
The peripheral facilitates the central to find it by broadcasting. After the connection between the peripheral and the central work, the central can extract data from the peripheral and control it. This sample enables LinkIt 7697 to become a BLE peripheral. We use a smartphone as the central to control the flicker of LED on development board. (The following omits and modifies some source code for easier control on smartphones.)
LBLEService ledService("19B10010-E8F2-537E-4F6C-D104768A1214"); LBLECharacteristicInt switchCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214", LBLE_READ | LBLE_WRITE); void setup() { ... LBLEAdvertisementData advertisement; advertisement.configAsConnectableDevice("BLE LED"); ledService.addAttribute(switchCharacteristic); LBLEPeripheral.setName("BLE LED"); LBLEPeripheral.addService(ledService); LBLEPeripheral.begin(); LBLEPeripheral.advertise(advertisement); } void loop() { delay(100); if (switchCharacteristic.isWritten()) { const char value = switchCharacteristic.getValue(); switch (value) { case 0x31: digitalWrite(LED_BUILTIN, HIGH); break; case 0x30: digitalWrite(LED_BUILTIN, LOW); break; default: ... } } }
Full Source Code
After the sample is executed, search with smartphone apps, connect with each other, and then control the flicker of the LED.
Turn on the LED through smartphones:

Turn off the LED through smartphones:

Scan Peripherals
BLE Central can work as a management hub to scan nearby peripherals. We firstly used a smartphone app to simulate BLE Peripheral. (Here we used BLE Peripheral Simulator.) This is a body thermometer transmission device:

#include #include void setup() { ... LBLE.begin(); while (!LBLE.ready()) { delay(10); } LBLECentral.scan(); ... // list advertisements found. for (int i = 0; i < LBLECentral.getPeripheralCount(); ++i) { printDeviceInfo(i); } LBLECentral.stopScan(); } void loop() { // do nothing } void printDeviceInfo(int i) { ... const String name = LBLECentral.getName(i); ... const String manu = LBLECentral.getManufacturer(i); ... }

Then we found the device we simulated with smartphone.
Connect to Peripheral
(Here is the follow-up of the former sample.) After scanning, you can connect with the devices you have found, and then execute this sample:
LBLEClient client; ... void loop() { ... client.connect(serverAddress); ... const int serviceCount = client.getServiceCount(); Serial.println("available services = "); for(int i = 0; i < serviceCount; ++i) { Serial.print("\t - "); const String serviceName = client.getServiceName(i); if(serviceName.length()) { Serial.print("["); Serial.print(serviceName); Serial.print("] "); } Serial.println(client.getServiceUuid(i)); } ... }

Connect with the peripheral, get relevant information, and then you can execute further tasks.
Conclusion
Based on the aforementioned samples, we can regard LinkIt 7697 as:
• iBeacon or Eddystone
• BLE Peripheral
• BLE Central
With LinkIt 7697’s Arduino libraries, the development process has been simplified. What would you also like to do with different combinations for some interesting and practical functions? Let’s do it on your own and become a professional maker.
More articles about LinkIt 7697: LINKIT 7697 VS ESP 32: WHO WILL WIN?
Way cool! Some very valid points! I appreciate you penning
this post and also the rest of the site is also really good.
Hi there, glad you enjoy our content! We share the latest technologies in various industries from time to time. Join us so that you won’t miss out on anything! https://www.techdesign.com/user/signup.