App for bluetooth scanning
-
Hello again, I returned Here since I'm still stuck. In this moment I'm trying to create a new bluetooth service (in the box code), where I'll ask for creating an retrieve a list of all connected devices (and I still have not idea on how to do it, I saw this in the documentation, maybe could be useful).
So in this way I can create another service (on the app code) where once retrieved the list will associate to a device a command (and again I still have not idea on how to do it) and send it back to the box to execute it.
Any idea on how I can do it?
Thank you again for all the help. -
Something is not clear, what will run on that box ?
-
Hello again, I returned Here since I'm still stuck. In this moment I'm trying to create a new bluetooth service (in the box code), where I'll ask for creating an retrieve a list of all connected devices (and I still have not idea on how to do it, I saw this in the documentation, maybe could be useful).
So in this way I can create another service (on the app code) where once retrieved the list will associate to a device a command (and again I still have not idea on how to do it) and send it back to the box to execute it.
Any idea on how I can do it?
Thank you again for all the help.@AndreaFurlani I would suggest to take a look at examples. Start with "qtconnectivity" - btscanner.
It does the basics - scans for nearby bluetooth devices etc.
However it is scarcely documented - in code - and assumes some knowledge about bluetooth.
From my experience - do not assume that your "local bluetooth device " is enabled to be used to scan for "remote bluetooth devices".
I have two with different dongles with different "class of service" and the scan results are NOT the same.Same for "remote bluetooth device" - my powered "remote device " with serial USB to bluetooth adapter" can be "found" , my powered remote "boom box" has to be activated to be found.
Beware of running active operating system "bluetooth manager" software - it actually over-rides , takes precedence, of SOME of your code. -
@SGaist The box is connected to some lights and sensors via zigbee or bluetooth. I need a list of all the connected devices to the box
-
@AndreaFurlani I would suggest to take a look at examples. Start with "qtconnectivity" - btscanner.
It does the basics - scans for nearby bluetooth devices etc.
However it is scarcely documented - in code - and assumes some knowledge about bluetooth.
From my experience - do not assume that your "local bluetooth device " is enabled to be used to scan for "remote bluetooth devices".
I have two with different dongles with different "class of service" and the scan results are NOT the same.Same for "remote bluetooth device" - my powered "remote device " with serial USB to bluetooth adapter" can be "found" , my powered remote "boom box" has to be activated to be found.
Beware of running active operating system "bluetooth manager" software - it actually over-rides , takes precedence, of SOME of your code.@AnneRanch thank you for the answer. I already watched all the bluetooth examples in Qt creator but no one of them is useful to understand how to create a new service and in particular how to do the things I need.
-
@AnneRanch thank you for the answer. I already watched all the bluetooth examples in Qt creator but no one of them is useful to understand how to create a new service and in particular how to do the things I need.
@AndreaFurlani said in App for bluetooth scanning:
how to create a new service
Since bluetooth devices have "class of service" be careful using the term.
I am still unclear about your overall task . I think I asked for simple hardware picture before .
Let me make analogy with my project
local bt device (PC) -> bluetooth media communication path -> remote bt device (radio )one on my "services" would be - set the radio frequency
so "my box - radio " would turn on correct frequency and display it on build-in LCD
Are you attempting to do similar tasks via your box ?
-
@SGaist The box is connected to some lights and sensors via zigbee or bluetooth. I need a list of all the connected devices to the box
@AndreaFurlani said in App for bluetooth scanning:
@SGaist The box is connected to some lights and sensors via zigbee or bluetooth. I need a list of all the connected devices to the box
Hence my question what software runs on that box ?
-
Hello I'm back again. I made some progress in writing my code. Now the box starts the advertising without problem.
Here's the code:void bluetoothDevice::start(bool debugMode, bool protocolDebug) { //Personalized Service for connected bluetooth devices list static const QLatin1String serviceUuid("11223344-5566-7788-99aa-bbccddeeff00"); //static const QLatin1String writeListUuid("11223344-5566-7788-99aa-bbccddeeff11"); static const QLatin1String readListUuid("11223344-5566-7788-99aa-bbccddeeff11"); // [Advertising Data] QLowEnergyAdvertisingData advertisingData; advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral); advertisingData.setIncludePowerLevel(true); advertisingData.setLocalName("BOX"); advertisingData.setServices(QList<QBluetoothUuid>() << QBluetoothUuid(serviceUuid)); // [Service Data] QLowEnergyCharacteristicData readList; readList.setUuid(QBluetoothUuid(readListUuid)); readList.setProperties(QLowEnergyCharacteristic::Read); const QLowEnergyDescriptorData clientConfig(QBluetoothUuid::CharacteristicUserDescription,QByteArray(2, 0)); readList.addDescriptor(clientConfig); //writeList.setUuid(QBluetoothUuid(writeListUuid)); //writeList.setProperties(QLowEnergyCharacteristic::Write); QLowEnergyServiceData serviceData; serviceData.setType(QLowEnergyServiceData::ServiceTypePrimary); serviceData.setUuid(QBluetoothUuid(serviceUuid)); serviceData.addCharacteristic(readList); //serviceData.addCharacteristic(writeList); // [Start Advertising] leController.reset(QLowEnergyController::createPeripheral()); service_list.reset(leController->addService(serviceData)); leController->startAdvertising(QLowEnergyAdvertisingParameters(), advertisingData,advertisingData); qCDebug(BLELog) << " Start BLE backend [...] "; ConnectionHandler connectionHandler; DeviceHandler m_deviceHandler; // TODO! Restore debug options. GenericDeviceIf::start(debugMode, protocolDebug); // Initialize reachable state to unreachable. DataModel::getInstance()->setDeviceCategoryReachable(_category, false); _endpoints = DataModel::getInstance() ->getEndpointsListByCategory(dataBaseClasses::ENDPOINT_CATEGORY_BLE); m_deviceHandler.setDevice(nullptr); qDeleteAll(devices); devices.clear(); emit devicesChanged(); qCDebug(BLELog) << "Scanning for devices..."; discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); emit scanningChanged(); // [Retrieving the list of devices] characteristic = service_list->characteristic(QBluetoothUuid(readListUuid)); for (const auto &e: _endpoints){ L.append(QString(e->getMapping()).toUtf8()); } if (L.empty()) qCDebug(BLELog) << "No endpoints loaded in the list"; for (const auto &list: L) { service_list -> writeCharacteristic(characteristic, list) ; } }
In this way I am able to connect to the BOX using an external BLE scanner app on my phone and once connected I would like to see the content of "list".
With this code the problem is that I can see only the last MAC address in the list, how can I see the complete content? -
I have been using Bluetooth LE Explorer.
But my Bluetooth is not turning on on windows 10 for 2 days any help.Updated: Glad found the solution here for Bluetooth turning on issue.
-
I have been using BLE suite this app has a primary scanner view option that detects all the available devices using the Android operating system.