Bluetooth LE : Address Type - bluetooth-lowenergy

I am working on the iBeacon technology and I can't find any answer to a particular point concerning the address type.
I found the documenation (bluetooth specification) explaining what are the address types but I can't seem to find how to chose between the two types (public and random).
Here is an example where I found it (it is a sniffed packet transmitted by an iBeacon on a Raspberry PI) :
http://i.stack.imgur.com/QF5gf.png
and http://i.stack.imgur.com/NHY6x.png (sorry I can't post images yet because of my reputation)
Let's try to ask questions and make it more specific :
Since a public address has to be valid, might it be that there is a command to generate a random one (yet correct in formatting the address) to assign it to the concerned device?
If the above is true : what would be the command? and how do you roll back (to the primary public address)?
Or is there a "switch" that allows to chose between the (valid) public address or to generate a random one?
Thank you.

Here's a command that looks pretty much like what you want. See here for details.
Set Static Address Command
==========================
Command Code: 0x002B
Controller Index: <controller id>
Command Parameters: Address (6 Octets)
Return Parameters:
This command allows for setting the static random address. It is
only supported on controllers with LE support. The static random
address is suppose to be valid for the lifetime of the
controller or at least until the next power cycle. To ensure
such behavior, setting of the address is limited to when the
controller is powered off.
The special BDADDR_ANY address (00:00:00:00:00:00) can be used
to disable the static address.
When a controller has a public address (which is required for
all dual-mode controllers), this address is not used. Only when
the controller information reports BDADDR_ANY (00:00:00:00:00:00),
it is required to configure a static address first.
If privacy mode is enabled and the controller is single mode
LE only without a public address, the static random address is
used as identity address.
This command generates a Command Complete event on success or a
Command Status event on failure.
Possible errors: Rejected
Not Supported
Invalid Parameters
Invalid Index
It looks to me like the privacy features of BlueZ are under current active development and may not be complete yet. See this commit from 2014/02/18. If you want to try this with the latest updates, you will have to compile BlueZ from source.

Related

Can I use wildcard on info-plist for Bonjour services

My apps using bonjour service to conversation with each other via local network.
I am facing a problem on Xcode12 with OS14 device.
A device publish a service with server type name depends on self device IP address
(example: 192.168.33.20 -> _1921683320._tcp)
B device searching a service with service type depends on A device IP address
(example: _1921683320._tcp)
According to apple document..From OS14~
https://developer.apple.com/documentation/multipeerconnectivity
Important
Apps that use the local network must provide a usage string in their Info.plist with the key NSLocalNetworkUsageDescription. Apps that use Bonjour must also declare the services they browse, using the NSBonjourServices key.
because my service type name is named by local network ip, it is changeable base on local network setting, so I am thinking about to using wildcard to define the service type name.
example: _*._tcp
but seems wildcard is not available on this definition.(I tried it)
I am also thinking about changing the naming method on A device
(example: 192.168.33.20 -> _20._tcp)
and add _1.tcp ~ _255.tcp to info-plist
But if I changed the naming method, B device could not find A device until version up.
Any idea for this problem? Please help.
I'm currently working through the same issue - Bonjour service name is dynamically created based off the iPad name to form a local mesh network. The conclusion that I have came to is com.apple.developer.networking.multicast is required for this to function without completely overhauling how all that logic is done. (More info here)
You will have to request permission from apple by filling out a form here. Let me know if this works for you!
The thing I am finding is, you "might" not be able to use a wildcard, but you can put multiple entries in the plist:
Item 0 _multicastapp0-p._tcp
Item 1 _multicastapp1-p._tcp
Item 2 _multicastapp2-p._tcp
Item 3 _multicastapp3-p._tcp
etc
Item N _multicastappN-p._tcp
So for some reason if you are trying to have multiple "Groups" of 8 or have a device have it's own "collection" i.e. be a server and have 3 devices connect to that, you can.
I haven't "fully" tested but I am going to be doing this in my apps, I did test using multiple keys tho, but not fully, no errors...

Confused about health checking protocol

I have read below doc, source code and issue:
https://github.com/grpc/grpc/blob/master/doc/health-checking.md
https://github.com/grpc/grpc-node/blob/master/packages/grpc-health-check/test/health_test.js
https://github.com/grpc/grpc/issues/10428
I provide an example and try to explain:
// Import package
let health = require('grpc-health-check');
// Define service status map. Key is the service name, value is the corresponding status.
// By convention, the empty string "" key represents that status of the entire server.
const statusMap = {
"ServiceFoo": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.SERVING,
"ServiceBar": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.NOT_SERVING,
"": proto.grpc.health.v1.HealthCheckResponse.ServingStatus.NOT_SERVING,
};
// Construct the service implementation
let healthImpl = new health.Implementation(statusMap);
// Add the service and implementation to your pre-existing gRPC-node server
server.addService(health.service, healthImpl);
I am not clear about the following points:
Does the service name in statusMap need to be the same as the service name in the protocol buffers file? Or the service name can be arbitrarily specified. If so, how does the service name map to the service defined in the protocol buffers?
From the health checking protocol:
The server should register all the services manually and set the individual status
Why do we need to register manually? If the service code can be generated, why doesn't grpc help us automatically register the service name in statusMap? (Imagine setting the status of 100 services one by one)
The service status is hard code and cannot be changed at application runtime. If my service is unavailable at runtime for some reason such as misconfiguration, downstream service is not available, but the status of the service is always serving(because it's hard code), if so, what is the meaning of the health check?
For RESTful API, we can provide a /health-check or /ping API to check that the entire server is running normally.
Regarding the service names, the first linked document says this:
The suggested format of service name is package_names.ServiceName, such as grpc.health.v1.Health.
This does correspond to the package names and service name defined in the Protobuf definition.
The services need to be registered "manually" because the status is determined at the application level, which the grpc library does not know about, and a registered service name is only meaningful along with the corresponding status. In addition, the naming format mentioned above is just a convention; the health check service user is not constrained to it, and the actual services on the server are not constrained to use the standard /package_names.ServiceName/MethodName method naming scheme either.
Regarding the third point, the service status should not be hardcoded, and can be changed at runtime. The HealthImplementation class used in the code in the question has a setStatus method that can be used to update the status.
Also, as mentioned in a comment in the code in the question,
By convention, the empty string "" key represents that status of the entire server.
That can be used as the equivalent of the /health-check or /ping REST APIs.

No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/NetworkManager/ActiveConnection/

I start my qt application in the user's .profile file (not root) to make the app start on boot. Sometimes when my application start, it reports an warning as below:
"No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/NetworkManager/ActiveConnection/1"
I searched on google but did not find a explanation.
It seems my app is still working fine, but I want to locate the problem.
The application is running on ubuntu and using Qt5.
Thanks in advance.
Edit
I tried to debug dbus based on Eligijus Pupeikis's help with running:
gdbus introspect --system \
--dest org.freedesktop.NetworkManager \
--object-path /org/freedesktop/NetworkManager/ActiveConnection
it returns:
node /org/freedesktop/NetworkManager/ActiveConnection {
node 0 {
};
};
So, this means there is no such object just as the error message said, right?
And also, this gns3 team member says this problem is about Qt and Ubuntu.
Does this mean I don't need to solve it? I not familiar with the relationship between dbus and qt.
Most likely there is no such object "/org/freedesktop/NetworkManager/ActiveConnection/1" and because of that it can't find 'org.freedesktop.DBus.Properties' interface.
From documentation org.freedesktop.NetworkManager.Connection.Active :
Objects that implement the Connection.Active interface represent an attempt to connect to a network using the details provided by a Connection object. The Connection.Active object tracks the life-cycle of the connection attempt and if successful indicates whether the connected network is the "default" or preferred network for access. NetworkManager has the concept of connections, which can be thought of as settings, a profile or a configuration that can be applied on a networking device. Such settings-connections are exposed as D-Bus object and the active-connection expresses this relationship between device and settings-connection. At any time a settings-connection can only be activated on one device and vice versa. However, during activation and deactivation multiple active-connections can reference the same device or settings-connection as they are waiting to be activated or to be deactivated.
You can't know that that ActiveConnection object with specifically index 1 exists so you need to check by reading ActiveConnections property from /org/freedesktop/NetworkManager object's org.freedesktop.NetworkManager interface.
To have better visualize and understand how it looks I suggest D-Bus debugger. If you are using Gnome check out D-Feet.

Stonestreet One's Bluetopia how do you request a MTU change?

Or more specifically how do you request an MTU change when operating at the "Platform Manager" level?
More details
I'm using the sample program LinuxGATM_CLT which acts as a GATT client and it uses the Bluetopia Platform Manager Framework.
I'm using TI's WL183xMOD WiLink hardware which uses Bluetopia (previously owned by Stonestreet One).
The API call exists
The function exists, but seems to be at stack layer lower than the PM:
~/src/ti_bluetopia/ $ grep GATT_Exchange_MTU_Request ./BluetopiaPM/Bluetopia/include/GATTAPI.h
BTPSAPI_DECLARATION int BTPSAPI GATT_Exchange_MTU_Request(unsigned int BluetoothStackID, unsigned int ConnectionID, Word_t RequestedMTU, GATT_Client_Event_Callback_t ClientEventCallback, unsigned long CallbackParameter);
But its not callable from the "Platform Manager" level
Everything within BluetopiaPM/sample/LinuxGATM/LinuxGATM_CLT.c uses GATM functions from BluetopiaPM/include/client/GATMAPI.h
It feels like the GATT_Exchange_MTU_Request() function has not been exposed at the PM level. Its hard to dig deeper into how the PM works because they only ship binaries (doesn't seem to be open-source). For example the only match is the GATTAPI.h header file and a binary library file:
~/src/ti_bluetopia/ $ grep -ri GATT_Initialize ./
Binary file ./BluetopiaPM/Bluetopia/lib/libSS1BTGAT.a matches
I feel like the solution is to find methods to report my current Platform Manager BluetoothStackID, ConnectionID, and callback parameters so that I can call the GATT_Exchange_MTU_Request() function directly.
In short, the workaround is to get an earlier version of Stonestreet One's Bluetopia, before they created the "Platform Manager". These earlier versions (suchas 4.012 and 4.013) don't have the advantage of the Platform Manager, but they do allow you to have more control, operating at a lower level where you can call:
GATT_Initialize() and
GATT_Exchange_MTU_Request()
One good example is 4.013's SPPLEDemo.c which calls the above-mentioned methods.

setting static IP for wifi connection in QT

I am trying to create a QT based application that scan and connect WiFi networks. I am using this example as a reference code.
Is it possible to assign static IP for the WiFi connection using QNetworkConfiguration or any related class ?
How to authenticate the networks that are password protected ?
thanks in advance......
I have created a net work session using the below code set..
void BearerMonitor::createNewSessionFromQml(QString ssid)
{
QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations();
while (!allConfigurations.isEmpty()) {
QNetworkConfiguration config = allConfigurations.takeFirst();
if(config.name()==ssid)
createSessionFor(config);
}
}
SessionWidget::SessionWidget(const QNetworkConfiguration &config, QObject *parent):QObject(parent)
{
session = new QNetworkSession(config, this);
session->open();
}
No you can't. At least not with just Qt APIs.
Please read this and in particular this. QNetworkConfiguration is just a facility to manage network configurations. Editing such configurations is demanded to native code / OS interactions. From the second link:
Note that the QNetworkConfiguration object only provides limited information about the configuration details themselves. It's main purpose is to act as a configuration identifier through which link layer connections can be created, destroyed and monitored.
Even the "start/stop network interfaces" claim is not entirely true since such a feature is available only in certain OSs (not the mobile ones). See the "Platform capabilities" section of the second link for more details about that.
The same reasoning applies to the password question. Once a network is registed in the OS with the corresponding password (because of native code or the user physically registering it) a new configuration is available to the NetworkConfigurationManager, granted that the list of configurations is updated via updateConfigurations(). The new configuration contains the password but you can't edit it from Qt APIs.
Native code is the only solution, as said. Still, Apple does not want you to mess up with WiFi programatically since private APIs for that cannot be used in iOS > 5.1 (the oldest version supported by Qt as for Qt 5.4).

Resources