Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add new BLEStringCharacateristic type #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
agdl merged 1 commit into arduino-libraries:master from sandeepmistry:string-characteristic
Dec 17, 2018

Conversation

Copy link
Contributor

@sandeepmistry sandeepmistry commented Dec 14, 2018

Resolves #4.

Example usage sketch:

#include <ArduinoBLE.h>
BLEService stringService("19B10000-0001-537E-4F6C-D104768A1214"); // BLE String Service
BLEStringCharacteristic stringCharacteristic("19B10001-0001-537E-4F6C-D104768A1214", BLERead | BLEWrite, 512);
void setup() {
 Serial.begin(9600);
 while (!Serial);
 // begin initialization
 if (!BLE.begin()) {
 Serial.println("starting BLE failed!");
 while (1);
 }
 // set advertised local name and service UUID:
 BLE.setLocalName("String");
 BLE.setAdvertisedService(stringService);
 // add the characteristic to the service
 stringService.addCharacteristic(stringCharacteristic);
 // add service
 BLE.addService(stringService);
 // set the initial value for the characeristic:
 stringCharacteristic.writeValue("hello");
 // start advertising
 BLE.advertise();
 Serial.println("BLE String Peripheral");
}
void loop() {
 // listen for BLE peripherals to connect:
 BLEDevice central = BLE.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 (stringCharacteristic.written()) {
 Serial.println("stringCharacteristic written, new value = ");
 String value = stringCharacteristic.value();
 Serial.println(value);
 }
 }
 // when the central disconnects, print it out:
 Serial.print(F("Disconnected from central: "));
 Serial.println(central.address());
 }
}

sabas1080, agdl, oleghein, and DionNam reacted with thumbs up emoji sabas1080 and oleghein reacted with heart emoji
@agdl agdl merged commit 7d8b9ee into arduino-libraries:master Dec 17, 2018
Copy link

This seems to not be documented here yet

mmaciej2 pushed a commit to mmaciej2/ArduinoBLE that referenced this pull request Jan 22, 2022
Copy link
Contributor

per1234 commented Feb 2, 2024

This seems to not be documented here yet

The deficiency is now tracked here: #349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@agdl agdl Awaiting requested review from agdl

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

BLEStringCharacteristic

AltStyle によって変換されたページ (->オリジナル) /