简体   繁体   中英

How to change BLE device name from iOS?

I want to change BLE device name within the iOS app.

Currently I have done these things:

  1. Scanned
  2. Connected to the BLE which I want to change
  3. Discovered it's services & characteristics

But then to change it's name I am not sure, what I can do? I have checked other questions but which doesn't guarantees to help.

It requires to pass a new name with a "name" parameter to the device.

Currently, I am doing this thing sure it;sa crap:

[peripheral writeValue:@"new name of the device" forCharacteristic:[peripheral.services firstObject] type:CBCharacteristicWriteWithResponse];

I am lacking with knowledge:

here we're not passing any parameter, did we?

Please help.

You should refer the document or check with the manufacturer if they allow overriding the peripheral name. If allowed, then at what location.

You need to read the documentation for writeValue because that isn't even close to what the actual parameters are supposed to be.

  1. Value is supposed to be NSData, not a string. Call dataUsingEncoding: on your string and pass in the correct encoding value (likely ascii or utf8: check your device documentation).
    1. Characteristic is a CBCharacteristic but you are passing in a CBService

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM