Hi guys, I've succesfully developed a client (a.k.a central role) with QT Bluetooth LE SDK to work against some electronics of my own. But now, i need to implement the Peripheral Role with QT and my custom GATT Profile
So far, i've outlined a very small service that will allow to read and write the WPA Config for Linux (to setup the WiFi connection of a Raspberry Pi) using Bluetooth Developer Studio. I've followed the example at the docs to setup discovery of this service. bool BluetoothServer::initialize(std::string mac) { Logger::addLine("BluetoothServer","Initializing with MAC Address: "+mac); // Set mac address macAddress = mac; // Set BaseStation Bluetooth Address QBluetoothAddress address(QString::fromUtf8(macAddress.c_str())); // Create Local Device localDevice = new QBluetoothLocalDevice(address); if (!localDevice->isValid()) { Logger::addLine("BluetoothServer","Local Bluetooh device not available. Aborting"); return false; } // Turn Bluetooth on localDevice->powerOn(); // Make it visible to others localDevice->setHostMode(QBluetoothLocalDevice::HostDiscoverable); QLowEnergyCharacteristicData charDataNetworkSSID; charDataNetworkSSID.setUuid(QBluetoothUuid(QString("{2A9669DE-9AA3-4304-8E06-B122DBC5991B}"))); charDataNetworkSSID.setValue(QByteArray("")); charDataNetworkSSID.setProperties(QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::WriteNoResponse); QLowEnergyCharacteristicData charDataPSK; charDataPSK.setUuid(QBluetoothUuid(QString("{2A963AB9-9AA3-4304-8E06-B122DBC5991B}"))); charDataPSK.setValue(QByteArray("")); charDataPSK.setProperties(QLowEnergyCharacteristic::Read | QLowEnergyCharacteristic::WriteNoResponse); QLowEnergyServiceData serviceData; serviceData.setUuid(QBluetoothUuid(QString("{2A960000-9AA3-4304-8E06-B122DBC5991B}"))); serviceData.setType(QLowEnergyServiceData::ServiceTypePrimary); serviceData.addCharacteristic(charDataNetworkSSID); serviceData.addCharacteristic(charDataPSK); if (!serviceData.isValid()) Logger::addLine("BluetoothServer","LE ServiceData is NOT Valid"); QList<QBluetoothUuid> servicesList;// = QList<QBluetoothUuid>(); servicesList << QBluetoothUuid(QString("{2A960000-9AA3-4304-8E06-B122DBC5991B}")); QLowEnergyAdvertisingData advertisingData; advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral); advertisingData.setIncludePowerLevel(false); advertisingData.setLocalName("GSense"); advertisingData.setServices(servicesList); lowEnergyController = QLowEnergyController::createPeripheral(); lowEnergyService = lowEnergyController->addService(serviceData); lowEnergyController->startAdvertising(QLowEnergyAdvertisingParameters(), advertisingData, advertisingData); Logger::addLine("BluetoothServer","LE Service ready and awaiting connections"); return true; } So, it's advertised. Though, when i use a BLE Scanner from an Android Cellphone and connect to it, it says "Discovering Services" and it does not show up my custom service . It only shows the Generic Attribute, bla bla. So the question is, do you guys have a working example as how to get my service discovered and also provide the callbacks to read and write to my Characteristics?. I'll keep trying with the documentation looking up the QLowEnergyService class and so on, but you might have a properly documented example for the Peripheral Role from start to end. The doc at: http://doc.qt.io/qt-5/qtbluetooth-le-overview.html just addresses the Advertisement of a custom GATT and the examples at http://doc.qt.io/qt-5/qtexamplesandtutorials.html only fully develops the Central Role AFAIK. Thanks in advance. Alan ------------------------------------------------------- *3DGames Argentina* http://www.3dgames.com.ar Libertad 41, 5to Piso - Capital Federal Tel: 4-332-4709
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest