GeorgeIoak
1st March 2017, 19:51
I am more of a hardware person than software so I'm looking for some help. I am modifying the lowenergyscanner example project so I can write to a custom characteristic. The example project is able to find our device (I am currently running this on Mac OS), find the services, and then if I select our custom service it is able to find all of the characteristics.
I've searched and found some posts on the internet but I have not been successful in writing to our device. In device.cpp I have added:
//GI new Code
// Write to motor
const QLowEnergyCharacteristic link = service->characteristic(QBluetoothUuid(Device_UUID_Motor_Ch aracteristic));
if (service->state() == QLowEnergyService::ServiceDiscovered){
service->QLowEnergyService::writeCharacteristic(link,QByteA rray::fromHex("01501000"),QLowEnergyService::WriteWithoutResponse);
}
//End GI Code
In device.h I added the following constant. I tried both with and without the {}
const QString Device_UUID_Motor_Characteristic = "{00010002-0000-1000-8000-00805F9B0421}";
I am able to debug the app and depending on where this code is placed it will execute but it does not activate the motor (the code sequence will activate the motor and then stop it after a short period)
For now I just want to write 0x01 0x50 0x10 0x00 to the Motor characteristic which has a UUID of 00010002-0000-1000-8000-00805F9B0421 and is part of our custom service which has a UUID of "00010000-0000-1000-8000-00805F9B0421"
I have been able to use BLE apps on a mobile phone and successfully written this to our board but I have not been successful with this Qt.
Ideally once I have performed this I would like to modify the app to directly connect to our board using our board name and then issue this command so I can verify that the board is working.
Thanks in advance for your help.
George
I've searched and found some posts on the internet but I have not been successful in writing to our device. In device.cpp I have added:
//GI new Code
// Write to motor
const QLowEnergyCharacteristic link = service->characteristic(QBluetoothUuid(Device_UUID_Motor_Ch aracteristic));
if (service->state() == QLowEnergyService::ServiceDiscovered){
service->QLowEnergyService::writeCharacteristic(link,QByteA rray::fromHex("01501000"),QLowEnergyService::WriteWithoutResponse);
}
//End GI Code
In device.h I added the following constant. I tried both with and without the {}
const QString Device_UUID_Motor_Characteristic = "{00010002-0000-1000-8000-00805F9B0421}";
I am able to debug the app and depending on where this code is placed it will execute but it does not activate the motor (the code sequence will activate the motor and then stop it after a short period)
For now I just want to write 0x01 0x50 0x10 0x00 to the Motor characteristic which has a UUID of 00010002-0000-1000-8000-00805F9B0421 and is part of our custom service which has a UUID of "00010000-0000-1000-8000-00805F9B0421"
I have been able to use BLE apps on a mobile phone and successfully written this to our board but I have not been successful with this Qt.
Ideally once I have performed this I would like to modify the app to directly connect to our board using our board name and then issue this command so I can verify that the board is working.
Thanks in advance for your help.
George