SINTEF-9012 / bglib

Java implementation of the BGAPI binary protocol for Bluegiga BLE112 Bluetooth low energy modules.
37 stars 14 forks source link

Change Device Name #15

Closed MaverickFP closed 9 years ago

MaverickFP commented 9 years ago

Hi, i need to change the name of the device on the fly, is possible? This is my code but dont'work. The name doesnt'change.

String strng = "NewName"; byte[] dati = strng.getBytes(); impl.send_attributes_write(2, 0, dati);

The callback method give me a non-zero value --> error when the app settings the attribute.

MaverickFP commented 9 years ago

this is my complete code

System.out.println( "Connecting BLED112 Dongle..." ); BGAPITransport bgapi = BLED112.connectBLED112(); bgapi.addListener(new BGAPIPacketLogger()); BGAPI impl = new BGAPI(bgapi); impl.addListener(new TestSndRcv());

try { Thread.sleep(500); } catch (InterruptedException ex) { Logger.getLogger(TestSndRcv.class.getName()).log(Level.SEVERE, null, ex); } System.out.println( "Requesting Version Number..." );

String strng = "NewName"; byte[] dati = strng.getBytes()

impl.send_system_hello(); impl.send_gap_set_scan_parameters(10, 250, 1); impl.send_system_address_get();

impl.send_attributes_write(2, 0, dati);

impl.send_gap_set_privacy_flags(0, 0); impl.send_gap_set_adv_parameters(32, 48, 7); impl.send_gap_set_mode(2, 2); impl.send_gap_discover(1);

MaverickFP commented 9 years ago

Change the device name is possible if, in the gatt.xml, the device name GATT characteristic is not defined with const="true".

ffleurey commented 9 years ago

Thanks for posting the solution, I had no idea :-)