Datasheet
Command Examples
The following code snippets can be used when operating in Command Mode to perform specific tasks.
Heart Rate Monitor Service
The command list below will add a Heart Rate (https://adafru.it/ddB) service to the BLEFriend's attribute table, with two
characteristics:
Heart Rate Measurement (https://adafru.it/ddD)
Body Sensor Location (https://adafru.it/eck)
# Perform a factory reset to make sure we get a clean start
AT+FACTORYRESET
OK
# Add the Heart Rate service entry
AT+GATTADDSERVICE=UUID=0x180D
1
OK
# Add the Heart Rate Measurement characteristic
AT+GATTADDCHAR=UUID=0x2A37, PROPERTIES=0x10, MIN_LEN=2, MAX_LEN=3, VALUE=00-40
1
OK
# Add the Body Sensor Location characteristic
AT+GATTADDCHAR=UUID=0x2A38, PROPERTIES=0x02, MIN_LEN=1, VALUE=3
2
OK
# Create a custom advertising packet that includes the Heart Rate service UUID
AT+GAPSETADVDATA=02-01-06-05-02-0d-18-0a-18
OK
# Reset the device to start advertising with the custom payload
ATZ
OK
# Update the value of the heart rate measurement (set it to 0x004A)
AT+GATTCHAR=1,00-4A
OK
Python Script
The following code performs the same function, but has been placed inside a Python wrapper using
PySerial (https://adafru.it/cLU) to show how you can script actions for the AT parser.
import io
import sys
import serial
import random
from time import sleep
filename = "hrm.py"
© Adafruit Industries https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le Page 150 of 211










