Unable to broadcast GAP Appearance in bluefruit nrf52 using Ibeacon

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
smetron
 
Posts: 1
Joined: Thu Jun 06, 2024 7:12 am

Unable to broadcast GAP Appearance in bluefruit nrf52 using Ibeacon

Post by smetron »

Hi,
I'm trying to broadcast the appearance id using the bluefruit library but its not appearing in the nRF Connect App. I have also setup to ESP32 to show the ibeacon packets. All the information is appearing except the Appearance value

The GAP appearance characteristic is used to specify the external appearance of the device, which can help other devices identify it.

below is the code:

Code: Select all


#include <bluefruit.h>

#define BLE_APPEARANCE_UNKNOWN                     0
#define BLE_APPEARANCE_GENERIC_PHONE               64
#define BLE_APPEARANCE_GENERIC_COMPUTER            128
#define BLE_APPEARANCE_GENERIC_WATCH               192
#define BLE_APPEARANCE_GENERIC_CLOCK               256
#define BLE_APPEARANCE_GENERIC_DISPLAY             320
#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL      384
#define BLE_APPEARANCE_GENERIC_EYE_GLASSES         448
#define BLE_APPEARANCE_GENERIC_TAG                 512
#define BLE_APPEARANCE_GENERIC_KEYRING             576
#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER        640
#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER     704
#define BLE_APPEARANCE_GENERIC_THERMOMETER         768
#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR   832

#define MANUFACTURER_ID 0x0059
// "nRF Connect" app can be used to detect beacon
uint8_t beaconUuid[16] = {
0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78,
0x89, 0x9a, 0xab, 0xbc, 0xcd, 0xde, 0xef, 0xf0
};
// A valid Beacon packet consists of the following information:
// UUID, Major, Minor, RSSI @ 1M
BLEBeacon beacon(beaconUuid, 1, 2, -54);
void setup() {
Serial.begin(115200);
// Uncomment to blocking wait for Serial connection
// while ( !Serial ) delay(10);
Serial.println("Bluefruit52 Beacon Example");
Serial.println("--------------------------\n");
Bluefruit.begin();
Bluefruit.setName("Cap");
Bluefruit.setAppearance(512); // BLE_APPEARANCE_GENERIC_TAG
Bluefruit.Advertising.addAppearance(512);
// off Blue LED for lowest power consumption
Bluefruit.autoConnLed(false);
Bluefruit.setTxPower(0); // Check bluefruit.h for supported values

// Manufacturer ID is required for Manufacturer Specific Data
beacon.setManufacturer(MANUFACTURER_ID);
// Setup the advertising packet
startAdv();
Serial.printf("Broadcasting beacon with MANUFACTURER_ID = 0x%04X\n",
MANUFACTURER_ID);
Serial.println("open your beacon app to test such as: nRF Beacon");
Serial.println("- on Android you may need to change the MANUFACTURER_ID to 0x0059");
Serial.println("- on iOS you may need to change the MANUFACTURER_ID to 0x004C");
// Suspend Loop() to save power, since we didn't have any code there
suspendLoop();
}
void startAdv(void)
{
// Advertising packet
// Set the beacon payload using the BLEBeacon class populated
// earlier in this example
Bluefruit.Advertising.setBeacon(beacon);
// Secondary Scan Response packet (optional)
// Since there is no room for 'Name' in Advertising packet
Bluefruit.ScanResponse.addName();
/* Start Advertising
 * - Enable auto advertising if disconnected
 * - Timeout for fast mode is 30 seconds
 * - Start(timeout) with timeout = 0 will advertise forever (until connected)
 * 
 * Apple Beacon specs
 * - Type: Non-connectable, scannable, undirected
 * - Fixed interval: 100 ms -> fast = slow = 100 ms
 */
//Bluefruit.Advertising.addAppearance(512);
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
//Bluefruit.Advertising.addAppearance();

Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED);
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(160, 160); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds 
}
void loop() {
// loop is already suspended, CPU will not run loop() at all
}
Thanks

User avatar
vincent9874
 
Posts: 1
Joined: Mon Jun 10, 2024 7:45 am

Re: Unable to broadcast GAP Appearance in bluefruit nrf52 using Ibeacon

Post by vincent9874 »

It looks like you’re correctly setting the appearance ID in your code. If it’s not showing up in the nRF Connect App, it could be due to a few reasons:

The app may not support displaying the appearance value.
There might be an issue with the broadcasting of the appearance attribute.
The nRF Connect App may need to be refreshed or restarted to pick up the new attribute.
Make sure your Bluefruit library is up to date and check the app’s documentation to ensure it supports all GAP characteristics. If the problem persists, you might want to reach out to the support forums for the Bluefruit library or the nRF Connect App for more specific troubleshooting.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”