Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/Peripheral/CallbackLED/CallbackLED.ino
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ void blePeripheralDisconnectHandler(BLEDevice central) {
}

void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) {
// unused parameters
(void)central;
(void)characteristic;

// central wrote new value to characteristic, update LED
Serial.print("Characteristic event, written: ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#include <ArduinoBLE.h>


#define PAIR_BUTTON 3 // button for pairing
#define PAIR_BUTTON 3 // button for pairing
#define PAIR_LED 24 // LED used to signal pairing
#define PAIR_LED_ON LOW // Blue LED on Nano BLE has inverted logic
#define PAIR_LED_OFF HIGH // ... so these are inverted as well
#define PAIR_INTERVAL 30000 // interval for pairing after button press in ms

#define CTRL_LED LED_BUILTIN
Expand Down Expand Up @@ -59,13 +60,13 @@ void setup() {
BLE.setDisplayCode([](uint32_t confirmCode){
Serial.println("New device pairing request.");
Serial.print("Confirm code matches pairing device: ");
char code[6];
char code[7];
sprintf(code, "%06d", confirmCode);
Serial.println(code);
});

// Callback to allow accepting or rejecting pairing
BLE.setBinaryConfirmPairing([&acceptOrReject](){
BLE.setBinaryConfirmPairing([](){
Serial.print("Should we confirm pairing? ");
delay(5000);
if(acceptOrReject){
Expand Down Expand Up @@ -176,8 +177,7 @@ void setup() {

BLE.addService(batteryService); // Add the battery service
batteryLevelChar.writeValue(oldBatteryLevel); // set initial value for this characteristic
char* stringCharValue = new char[32];
stringCharValue = "string";
const char* stringCharValue = "string";
stringcharacteristic.writeValue(stringCharValue);
secretValue.writeValue(0);

Expand Down Expand Up @@ -219,9 +219,10 @@ void loop() {
BLE.setPairable(false);
Serial.println("No longer accepting pairing");
}
// Make LED blink while pairing is allowed
digitalWrite(PAIR_LED, (BLE.pairable() ? (millis()%400)<200 : BLE.paired()) ? PAIR_LED_ON : !PAIR_LED_ON);

// Make LED blink while pairing is allowed, steady ON when paired
bool led_status = BLE.pairable() ? (millis()%400)<200 : BLE.paired();
digitalWrite(PAIR_LED, led_status ? PAIR_LED_ON : PAIR_LED_OFF);

// if a central is connected to the peripheral:
if (central && central.connected()) {
Expand Down Expand Up @@ -262,4 +263,4 @@ void updateBatteryLevel() {
batteryLevelChar.writeValue(batteryLevel); // and update the battery level characteristic
oldBatteryLevel = batteryLevel; // save the level for next comparison
}
}
}
2 changes: 1 addition & 1 deletion src/utility/HCIVirtualTransportZephyr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int cyw4343_download_firmware(const struct device *uart) {
}

// Load the firmware image.
for (size_t offset=0; offset < brcm_patch_ram_length;) {
for (int offset=0; offset < brcm_patch_ram_length;) {
uint8_t length = brcm_patchram_buf[offset + 2];
uint16_t opcode = (brcm_patchram_buf[offset + 0]) |
(brcm_patchram_buf[offset + 1] << 8);
Expand Down
Loading