Simplified code.
--snip--snip--
#if 0
++ -g -std=c++11 -fPIC -o qtdbus_test qtdbus_test.cpp $(pkg-config --cflags
--libs Qt5DBus)
exec ./qtdbus_test
#endif
#include <iostream>
#include <QtDBus/QtDBus>
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
typedef QMap<QString, QMap<QString, QVariant>> Connection;
Q_DECLARE_METATYPE(Connection);
int main (int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDBusRegisterMetaType<Connection>();
QDBusConnection oSysbus = QDBusConnection::systemBus();
QDBusInterface oNmI(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_SERVICE, oSysbus);
QDBusObjectPath oDeviceP("/org/freedesktop/NetworkManager/Devices/0");
std::string sMode("adhoc");
std::string sSsid("toaster");
QDBusObjectPath oAccessPointP("/");
QDBusInterface oDeviceI(NM_DBUS_SERVICE, oDeviceP.path(),
"org.freedesktop.NetworkManager.Device.Wireless", oSysbus);
::Connection oConn;
oConn["802-11-wireless"]["mode"] = QString::fromStdString(sMode);
oConn["802-11-wireless"]["ssid"] = QByteArray::fromStdString(sSsid);
oConn["802-11-wireless"]["security"] = QString("802-11-wireless-security");
QByteArray addr; addr[0] = 0xa0; addr[1] = 0x21; addr[2] = 0xb7; addr[3] =
0x4a; addr[4] = 0x9b; addr[5] = 0x80;
oConn["802-11-wireless"]["mac-address"] = addr;
//oDeviceI.property("HwAddress");
oConn["connection"]["id"] = QString("Hotspot");
oConn["connection"]["autoconnect"] = QVariant(false);
oConn["connection"]["type"] = QString("802-11-wireless");
oConn["ipv4"]["method"] = QString("shared");
oConn["ipv4"]["addresses"] = QList<QVariant>();
oConn["ipv4"]["dns"] = QList<QVariant>();
oConn["ipv4"]["routes"] = QList<QVariant>();
oConn["802-11-wireless-security"]["wep-key-type"] = QVariant((unsigned)1);
oConn["802-11-wireless-security"]["wep-key0"] = QString("87c77b7552");
oConn["802-11-wireless-security"]["key-mgmt"] = QString("none");
QDBusReply<QDBusObjectPath> oResult = oNmI.call("AddAndActivateConnection",
QVariant::fromValue(oConn),
QVariant::fromValue(oDeviceP),
QVariant::fromValue(oAccessPointP));
if (! oResult.isValid()) {
std::cout << "err: " << __LINE__ << " " <<
oResult.error().message().toStdString() << std::endl;
} else {
std::cout << "AddAndActiveConnection-> " <<
oResult.value().path().toStdString() << std::endl;
exit(0);
}
exit (1);
}
--snip--snip--
STÉPHANE BOUCHER
Consultant software
D-BOX Technologies Inc. | A. 2172 de la Province, Longueuil, QC J4G 1R7 CANADA
| T. 450-442-3003 | D. | W. d-box.com
-----Message d'origine-----
De : networkmanager-list [mailto:[email protected]] De la
part de Stéphane Boucher
Envoyé : October 18, 2016 2:13 PM
À : Dan Williams <[email protected]>; [email protected]
Objet : RE: Problem activating hotspot
(Apologies for the top post... blame it on outlook)
I added lines starting with # to indicate which call failed, and which
succeeded.
I'll try to get a code snippet.
signal time=1476802044.025068 sender=org.freedesktop.DBus -> destination=:1.224
serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=NameAcquired
string ":1.224"
signal time=1476802044.025104 sender=org.freedesktop.DBus -> destination=:1.224
serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus;
member=NameLost
string ":1.224"
method call time=1476802047.121780 sender=:1.225 ->
destination=org.freedesktop.NetworkManager serial=5
path=/org/freedesktop/NetworkManager; interface=org.freedesktop.NetworkManager;
member=GetAllDevices # FIRST CALL (my app) - THIS FAILED method call
time=1476802047.132799 sender=:1.225 ->
destination=org.freedesktop.NetworkManager serial=15
path=/org/freedesktop/NetworkManager; interface=org.freedesktop.NetworkManager;
member=AddAndActivateConnection
array [
dict entry(
string "802-11-wireless"
array [
dict entry(
string "mac-address"
variant array of bytes [
a0 21 b7 4a 9b 80
]
)
dict entry(
string "mode"
variant string "adhoc"
)
dict entry(
string "security"
variant string "802-11-wireless-security"
)
dict entry(
string "ssid"
variant array of bytes "toaster"
)
]
)
dict entry(
string "802-11-wireless-security"
array [
dict entry(
string "key-mgmt"
variant string "none"
)
dict entry(
string "wep-key-type"
variant uint32 1
)
dict entry(
string "wep-key0"
variant string "87c77b7552"
)
]
)
dict entry(
string "connection"
array [
dict entry(
string "autoconnect"
variant boolean false
)
dict entry(
string "id"
variant string "Hotspot"
)
dict entry(
string "type"
variant string "802-11-wireless"
)
]
)
dict entry(
string "ipv4"
array [
dict entry(
string "addresses"
variant array [
]
)
dict entry(
string "dns"
variant array [
]
)
dict entry(
string "method"
variant string "shared"
)
dict entry(
string "routes"
variant array [
]
)
]
)
]
object path "/org/freedesktop/NetworkManager/Devices/0"
object path "/"
method call time=1476802047.211788 sender=:1.226 -> destination=:1.207
serial=240 path=/org/freedesktop/NetworkManager;
interface=org.freedesktop.NetworkManager; member=GetPermissions method call
time=1476802047.288394 sender=:1.227 -> destination=:1.207 serial=240
path=/org/freedesktop/NetworkManager; interface=org.freedesktop.NetworkManager;
member=GetPermissions method call time=1476802056.956319 sender=:1.228 ->
destination=org.freedesktop.NetworkManager serial=322
path=/org/freedesktop/NetworkManager; interface=org.freedesktop.NetworkManager;
member=GetPermissions # SECOND CALL (gnome applet) - THIS WORKED method call
time=1476802062.780997 sender=:1.228 ->
destination=org.freedesktop.NetworkManager serial=337
path=/org/freedesktop/NetworkManager; interface=org.freedesktop.NetworkManager;
member=AddAndActivateConnection
array [
dict entry(
string "802-11-wireless"
array [
dict entry(
string "security"
variant string "802-11-wireless-security"
)
dict entry(
string "ssid"
variant array of bytes "toaster"
)
dict entry(
string "mode"
variant string "adhoc"
)
dict entry(
string "mac-address"
variant array of bytes [
a0 21 b7 4a 9b 80
]
)
]
)
dict entry(
string "connection"
array [
dict entry(
string "id"
variant string "Hotspot"
)
dict entry(
string "autoconnect"
variant boolean false
)
dict entry(
string "type"
variant string "802-11-wireless"
)
]
)
dict entry(
string "ipv4"
array [
dict entry(
string "addresses"
variant array [
]
)
dict entry(
string "dns"
variant array [
]
)
dict entry(
string "method"
variant string "shared"
)
dict entry(
string "routes"
variant array [
]
)
]
)
dict entry(
string "802-11-wireless-security"
array [
dict entry(
string "wep-key-type"
variant uint32 1
)
dict entry(
string "wep-key0"
variant string "68a7ff97a0"
)
dict entry(
string "key-mgmt"
variant string "none"
)
]
)
]
object path "/org/freedesktop/NetworkManager/Devices/0"
object path "/"
STÉPHANE BOUCHER
Consultant software
D-BOX Technologies Inc. | A. 2172 de la Province, Longueuil, QC J4G 1R7 CANADA
| T. 450-442-3003 | D. | W. d-box.com
AVIS : Ce courriel contient des renseignements confidentiels. Si vous n'êtes
pas le véritable destinataire, la diffusion ou l'usage de ce courriel, des
renseignements qu'il contient ou des documents qui lui sont joints pourrait
être illégal. Il est donc strictement interdit de les diffuser ou de les
utiliser. Si vous avez reçu ce courriel par erreur, nous vous saurions gré d’en
aviser l'expéditeur immédiatement et de le supprimer sans le lire, l'imprimer,
le sauvegarder ou le diffuser. Nous vous remercions de votre aimable
collaboration.
NOTICE: This e-mail contains confidential information. If you are not the
intended recipient, any disclosure or other use of this e-mail or the
information contained herein or attached hereto may be unlawful and is strictly
prohibited. If you have received this e-mail in error, please notify the sender
immediately and delete this e-mail without reading, printing, copying or
forwarding it to anyone. Thank you for your kind cooperation.
-----Message d'origine-----
De : Dan Williams [mailto:[email protected]] Envoyé : October 18, 2016 2:00 PM À
: Stéphane Boucher <[email protected]>; [email protected] Objet :
Re: Problem activating hotspot
On Tue, 2016-10-18 at 15:26 +0000, Stéphane Boucher wrote:
> I’m on Ubuntu 16.04.1.
>
> I’m using QDBus to interact with NetworkManager.
>
> At the time I do all of the following, there’s no existing
> /org/freedesktop/NetworkManager/Settings/?? For the Hotspot.
>
> When I call AddAndActivateConnection, I get the error: “A 'wireless'
> setting is required if no AP path was given.”
This would indicate the partial connection dict you're sending to
NetworkManager as part of the AddAndActivateConnection call doesn't have all
the required properties.
What NM needs here is either the object path to an existing AP that it can pull
the SSID and security settings from, or you need to specify those manually
(which you must do here because you're doing a hotspot).
Apparently it's not getting that from the D-Bus method call, or there's a bug
in the code...
Can you share sanitized/condensed code that shows how you're calling
AddAndActivate?
_______________________________________________
networkmanager-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/networkmanager-list
_______________________________________________
networkmanager-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/networkmanager-list