From 1521b2f10bee729554375198deb079ba7293e95b Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 14 Apr 2014 00:37:40 +0200 Subject: [PATCH] improve testscript --- server/jsonrpc/devicehandler.cpp | 2 ++ tests/scripts/addconfigureddevice.sh | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/jsonrpc/devicehandler.cpp b/server/jsonrpc/devicehandler.cpp index b49c4536..741c5aac 100644 --- a/server/jsonrpc/devicehandler.cpp +++ b/server/jsonrpc/devicehandler.cpp @@ -254,8 +254,10 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms) DeviceId newDeviceId = DeviceId::createDeviceId(); DeviceManager::DeviceError status; if (deviceDescriptorId.isNull()) { + qDebug() << "adding a manual device."; status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceParams, newDeviceId); } else { + qDebug() << "adding a discovered device."; status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceDescriptorId, newDeviceId); } QVariantMap returns; diff --git a/tests/scripts/addconfigureddevice.sh b/tests/scripts/addconfigureddevice.sh index 345ccf51..53eb8a05 100755 --- a/tests/scripts/addconfigureddevice.sh +++ b/tests/scripts/addconfigureddevice.sh @@ -2,11 +2,11 @@ # Creates a Mumbi remote if [ -z $1 ]; then - echo "usage $0 host device" + echo "usage $0 host device [deviceClassId descriptorId]. In case of a discovered device, deviceClassId and descriptorId are mandatory." elif [ $1 == "list" ]; then echo "elroremote elroswitch intertechnoremote wifidetector mock1 mock2 openweathermap" elif [ -z $2 ]; then - echo "usage $0 host device" + echo "usage $0 host device [deviceClassId descriptorId]. In case of a discovered device, deviceClassId and descriptorId are mandatory." else if [ $2 == "elroremote" ]; then # Adds an ELRO remote control on channel 00000 @@ -35,7 +35,13 @@ else elif [ $2 == "openweathermap" ]; then # Adds a openweathermap device (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{985195aa-17ad-4530-88a4-cdd753d747d7}","deviceParams":{"location":""}}}'; sleep 1) | nc $1 1234 + elif [ $2 == "discovered" ]; then + if [ -z $4]; then + echo "usage $0 host device [deviceClassId descriptorId]. In case of a discovered device, deviceClassId and descriptorId are mandatory." + else + (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "'$3'", "deviceDescriptorId": "'$4'"}}'; sleep 1) | nc $1 1234 + fi else - echo "unknown type $2. Possible values are: elroremote, elroswitch, intertechnoremote, wifidetector, mock1, mock2, openweathermap" + echo "unknown type $2. Possible values are: elroremote, elroswitch, intertechnoremote, wifidetector, mock1, mock2, openweathermap, discovered. (In case of discovered, a deviceDescriptorId is required)" fi fi