arduino / arduino/ArduinoCore-arc32

Jira 768 CurieBLE: setAppearance does not work

Open
#367 5 comments 0 reactions 0 assignees View on GitHub
Under Review
Dominant language
C
Stars
330
Forks
281
PR merge metrics
No merged PRs in 30d

Description

In v1.0.7 `blePeripheral.setAppearance(appearance);` was function, however in master is does not - the appearance characteristic value is 0. Note: `blePeripheral.setDeviceName(name)` still works.

```arduino
#include

BLEPeripheral blePeripheral; // BLE Peripheral Device (the board you're programming)
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEUnsignedCharCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

const int ledPin = 13; // pin to use for the LED

void setup() {
Serial.begin(9600);

// set LED pin to output mode
pinMode(ledPin, OUTPUT);

// set advertised local name and service UUID:
blePeripheral.setLocalName("LED");
blePeripheral.setDeviceName("LED");
blePeripheral.setAppearance(0x1234);
blePeripheral.setAdvertisedServiceUuid(ledService.uuid());

// add service and characteristic:
blePeripheral.addAttribute(ledService);
blePeripheral.addAttribute(switchCharacteristic);

// set the initial value for the characeristic:
switchCharacteristic.setValue(0);

// begin advertising BLE service:
blePeripheral.begin();

Serial.println("BLE LED Peripheral");
}

void loop() {
// listen for BLE peripherals to connect:
BLECentral central = blePeripheral.central();

// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());

// while the central is still connected to peripheral:
while (central.connected()) {
// if the remote device wrote to the characteristic,
// use the value to control the LED:
if (switchCharacteristic.written()) {
if (switchCharacteristic.value()) { // any value other than 0
Serial.println("LED on");
digitalWrite(ledPin, HIGH); // will turn the LED on
} else { // a 0 value
Serial.println(F("LED off"));
digitalWrite(ledPin, LOW); // will turn the LED off
}
}
}

// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the blePeripheral.setAppearance(0x1234) entry point and compare its behavior between v1.0.7 and master, then inspect how blePeripheral.begin() publishes the appearance value. Reproduce the provided CurieBLE example and verify that the appearance characteristic is no longer 0 while setDeviceName still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.