Add basic structure of first plugin tutorial and continue with docs

This commit is contained in:
Simon Stürz 2018-07-26 15:40:09 +02:00 committed by Michael Zanetti
parent dcd410457d
commit e82efc7021
44 changed files with 1284 additions and 124 deletions

View File

@ -0,0 +1,503 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -0,0 +1,4 @@
# simplebutton
--------------------------------
Description of the plugin...

View File

@ -0,0 +1,5 @@
nymea-plugin-simplebutton (0.0.1) xenial; urgency=medium
* Initial release.
-- Developer Name <developer.name@example.com> Mon, 21 Aug 2017 10:12:00 +0000

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,22 @@
Source: nymea-plugin-simplebutton
Section: utils
Priority: options
Maintainer: Developer Name <developer.name@example.com>
Build-depends: debhelper (>= 9.0.0),
libnymea1-dev,
Standards-Version: 3.9.3
Package: nymea-plugin-simplebutton
Architecture: any
Multi-Arch: same
Section: libs
Depends: ${shlibs:Depends},
${misc:Depends},
Description: nymea.io plugin for simplebutton
The nymea daemon is a plugin based IoT (Internet of Things) server. The
server works like a translator for devices, things and services and
allows them to interact.
With the powerful rule engine you are able to connect any device available
in the system and create individual scenes and behaviors for your environment.
.
This package will install the nymea.io plugin for simplebutton

View File

@ -0,0 +1,14 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ${ProjectName}
Upstream-Contact: Developer Name <developer.name@example.com>
Copyright: 2018, Developer Name
License: LGPL-2.1
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in `/usr/share/common-licenses/LGPL-2.1'.
Files: *
License: LGPL-2.1
Copyright: Developer Name <developer.name@example.com>

View File

@ -0,0 +1 @@
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_devicepluginsimplebutton.so

View File

@ -0,0 +1,25 @@
#!/usr/bin/make -f
# -*- makefile -*-
export DH_VERBOSE=1
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
PREPROCESS_FILES := $(wildcard debian/*.in)
$(PREPROCESS_FILES:.in=): %: %.in
sed 's,/@DEB_HOST_MULTIARCH@,$(DEB_HOST_MULTIARCH:%=/%),g' $< > $@
%:
dh $@ --parallel
override_dh_install: $(PREPROCESS_FILES:.in=)
make -j9 install DESTDIR=debian/tmp AM_UPDATE_INFO_DIR=no INSTALL_ROOT=debian/tmp
dh_install --fail-missing
override_dh_auto_build:
dh_auto_build
make lrelease
override_dh_auto_clean:
dh_auto_clean
rm -rf $(PREPROCESS_FILES:.in=)

View File

@ -0,0 +1 @@
3.0 (native)

View File

@ -0,0 +1,67 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2018 Developer Name <developer.name@example.com> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "devicepluginsimplebutton.h"
#include "plugininfo.h"
DevicePluginSimpleButton::DevicePluginSimpleButton()
{
}
void DevicePluginSimpleButton::init()
{
// Initialize/create objects
}
void DevicePluginSimpleButton::startMonitoringAutoDevices()
{
// Start seaching for devices which can be discovered and added automatically
}
void DevicePluginSimpleButton::postSetupDevice(Device *device)
{
qCDebug(dcSimpleButton()) << "Post setup device" << device->name() << device->params();
// This method will be called once the setup for device is finished
}
void DevicePluginSimpleButton::deviceRemoved(Device *device)
{
qCDebug(dcSimpleButton()) << "Remove device" << device->name() << device->params();
// Clean up all data related to this device
}
DeviceManager::DeviceSetupStatus DevicePluginSimpleButton::setupDevice(Device *device)
{
qCDebug(dcSimpleButton()) << "Setup device" << device->name() << device->params();
return DeviceManager::DeviceSetupStatusSuccess;
}
DeviceManager::DeviceError DevicePluginSimpleButton::executeAction(Device *device, const Action &action)
{
qCDebug(dcSimpleButton()) << "Executing action for device" << device->name() << action.actionTypeId().toString() << action.params();
return DeviceManager::DeviceErrorNoError;
}

View File

@ -0,0 +1,54 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2018 Developer Name <developer.name@example.com> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef DEVICEPLUGINSIMPLEBUTTON_H
#define DEVICEPLUGINSIMPLEBUTTON_H
#include "devicemanager.h"
#include "plugin/deviceplugin.h"
class DevicePluginSimpleButton: public DevicePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "devicepluginsimplebutton.json")
Q_INTERFACES(DevicePlugin)
public:
explicit DevicePluginSimpleButton();
void init() override;
void startMonitoringAutoDevices() override;
void postSetupDevice(Device *device) override;
void deviceRemoved(Device *device) override;
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
private:
private slots:
};
#endif // DEVICEPLUGINSIMPLEBUTTON_H

View File

@ -0,0 +1,39 @@
{
"name": "SimpleButton",
"displayName": "Simple button",
"id": "28c7b102-3ac8-41f6-8dc0-f4787222a186",
"vendors": [
{
"name": "guh",
"displayName": "nymea",
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
"deviceClasses": [
{
"name": "simplebutton",
"displayName": "Simple button",
"id": "c16ba02d-c982-4b45-8ca2-1945d94d8e66",
"deviceIcon": "None",
"setupMethod": "JustAdd",
"createMethods": ["User"],
"interfaces": [ ],
"basicTags": [ ],
"paramTypes": [
],
"stateTypes":[
],
"actionTypes":[
],
"eventTypes":[
]
}
]
}
]
}

View File

@ -0,0 +1,14 @@
include(/usr/include/nymea/plugin.pri)
TARGET = $$qtLibraryTarget(nymea_devicepluginsimplebutton)
message(============================================)
message("Qt version: $$[QT_VERSION]")
message("Building $$deviceplugin$${TARGET}.so")
SOURCES += \
devicepluginsimplebutton.cpp
HEADERS += \
devicepluginsimplebutton.h

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
</TS>

View File

@ -4,5 +4,7 @@
\brief This is the list of nymea hardware resources.
Here you can find the list of hardware resources available in for plugin development.
\annotatedlist hardware
*/

View File

@ -0,0 +1,5 @@
#!/bin/bash
# apt install imagemagick
convert -delay 300 -loop 0 simplebutton-tutorial-* simplebutton-tutorial.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 KiB

View File

@ -1,6 +1,6 @@
/*!
\example template
\title 1. Plugin wizard
\title 1. The plugin wizard
\ingroup tutorials
\brief Explanation of the Qt Creator plugin wizard template
@ -80,17 +80,139 @@
\section1 Walk trough
Starting with the new created project you can find following files in you project:
Starting with the new created project you can find following files in you project:
\section2 template.pro
\section3 template.pro
\quotefile template/template.pro
This is the generated project files of your plugin. If you need additional qt modules or external libraries in your project
you can include them normaly using i.e. \tt{QT += network} or \tt{INCLUDEPATH += /path/to/includes} and \tt{LIBS += -lfoo}
like in any other Qt project.
\section2 deviceplugintemplate.json
\quotefile template/template.pro
\quotefromfile template/template.pro
Here you can find the device plugin interface describibg the vendors, devices and plugin information.
A detailed description of each section can be found in the \l{The plugin JSON File} section.
\list
\quotefile template/deviceplugintemplate.json
\li In the first line you can see the gloabl nymea plugin include, where all the nymea plugin related
configrations and setting for your plugin project get included.
\printline include(
\li The next line defines the library file name of your plugin. If you change the plugin name, this line has to be updated to.
\printline TARGET
\li The next section is just for debugging the project configuration and showing you the project name and Qt Version you are building with.
\printuntil message("Building
\li The \tt{SOURCES} and \tt{HEADERS} section shows the included source code files for your project.
\printuntil
\endlist
\section3 deviceplugintemplate.json
Here you can find the device plugin interface describing the vendors, devices and plugin information.
A detailed description of each section can be found in the \l{The plugin JSON File} section.
\quotefile template/deviceplugintemplate.json
\quotefromfile template/deviceplugintemplate.json
In the first section you can find the plugin specific properties. The id will be set to zero and must be changed with an actual uuid.
The zero uuid is creaed by the plugin template in order to indicate that this field has to be updated.
\printuntil "vendors"
In the vendors section you can see the vendor specific properties. There can be multiple vendors defined in one plugin,
each with its own device classes. The uuid of the vendor guh is known, and therefore already filled out. You have to update
the vendor uuid, name and id with your plugin information.
\printuntil "deviceClasses"
Here you can see the default created deviceclass, showing you the basic structure of a device class.
\printuntil }
\section3 deviceplugintemplate.h
The main header file shows you the basic structure of your DevicePlugin template. The header file start with the license header
containing the copyright information passed during the wizard.
\code
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2018 Developer Name <developer.name@example.com> *
* *
* This file is part of nymea. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
\endcode
The main class has the name \tt{DevicePluginExample}. The device plugin class inherts from the DevicePlugin class and must implement
the pure virtual methods in order build correctly.
\quotefromfile template/deviceplugintemplate.h
\skipto DevicePluginExample
\printuntil };
\section3 deviceplugintemplate.cpp
The implementation of each method can be found in the corresponding \tt{cpp} file.
As you can see, the plugin includes in the cpp file the \tt{plugininfo.h} file, which will be generated during build time
from the \tt{nymea-generateplugininfo} tool. This tool translates the \l{deviceplugintemplate.json} into a c++ header file
containing all uuid definitions, tranlations strings and the debug catergory definition.
\quotefromfile template/deviceplugintemplate.cpp
\skipto #include
\printline plugininfo
The main entry point of the plugin is the \l{DevicePlugin::init()}{init()} method. This method will be called from the DeviceManager once all plugins are
loaded and the initialization phase starts for you all plugins. Here you can start creating your objects in initialize
whatever you need. This method can be seen like a constructor.
\skipto init
\printuntil }
The \l{DevicePlugin::startMonitoringAutoDevices()}{startMonitoringAutoDevices} method will be called from the DeviceManager once all devices are set
up and the plugin can start for searching device which appear automatically if your plugin supports such device types.
\skipto startMonitoringAutoDevices
\printuntil }
The \l{DevicePlugin::postSetupDevice()}{postSetupDevice} method will be called from the DeviceManager once the setup of a device has finished successfully.
Here is a good point to initialize the states of the device.
\skipto postSetupDevice
\printuntil }
The \l{DevicePlugin::deviceRemoved()}{deviceRemoved} method will be called from the DeviceManager once a device is about to be removed from the system.
Here is a good place to clean up everything releated to the device which will be removed.
\skipto deviceRemoved
\printuntil }
When the user wants to add a new device from this plugin, the \l{DevicePlugin::setupDevice()}{setupDevice()} method will be called.
Here you can initialize Objects and set up everything you need for your device.
\skipto setupDevice
\printuntil }
When the user wants to execute an Action of a Device from this DevicePlugin, the \l{DevicePlugin::executeAction()}{executeAction} method will be called.
Here you can perform the actual execution of the custom call for your Device.
\skipto executeAction
\printuntil }
*/

View File

@ -0,0 +1,29 @@
/*!
\example simplebutton
\title 2. Your very first plugin
\ingroup tutorials
\brief A simple button example for showing the basic concepts of a \l{DevicePlugin}.
This is a nice example for showing the very basic concept of the nymea plugin mechanism.
Lets say we want to create a Button device, called \tt{Simple button}, which has a \tt{press} \l{Action} and
emits an \l{Event} called \tt{pressed} when someone executes the \tt{press} Action.
Based on this Event we can create a rule and we have a virtual button which can
be connected to any Action available in the entire system.
\section1 Create the plugin structure
Assuming you have read \l{1. The plugin wizard} {The plugin wizard} tutorial and you have installed
all \l{Set up the build environment}{build dependencies} we start to create a new plugin project.
In this image sequence you can see how this example was created.
\image simplebutton-tutorial.gif
\section1 Define the plugin properties
*/

View File

@ -2,13 +2,32 @@
\page write-plugins.html
\title Write your own plugin
Welcome to the device plugin documentation!
Writing your own plugin for the nymea system is easier than it looks like. Here you can find an overview of all information
you need for building the connection to a device or service. Developing a new plugin provides you automatically with the
full power of all nymea function like the RuleEngine, LogEngine and brings immeadiatly a client. You don't have to take care
about the client management and any other functionality which should make the development straight forward and you can
concentrate on your plugin and the content is should cover.
If you are a beginner, and want to start from scratch with the plugin development check out the \l{Plugin tutorials} and
start with the very first tutotial.
If you need to interact with a HardwareResource, you can check out the \l{Hardware Resources} documentation.
\section1 Overview
\list
\li \l{Set up the build environment}
\li \l{Getting started}
\li \l{The plugin JSON File}
\li \l{Hardware Resources}
\li \l{CreateMethods and SetupMethods}
\li \l{Testing your plugin}
\li \l{Plugin tutorials}
\endlist
\section1 Tutorials
\annotatedlist tutorials
*/

View File

@ -40,7 +40,7 @@ class BluetoothLowEnergyDeviceImplementation : public BluetoothLowEnergyDevice
friend class BluetoothLowEnergyManagerImplementation;
public:
explicit BluetoothLowEnergyDeviceImplementation(const QBluetoothDeviceInfo &deviceInfo, const QLowEnergyController::RemoteAddressType &addressType = QLowEnergyController::PublicAddress, QObject *parent = 0);
explicit BluetoothLowEnergyDeviceImplementation(const QBluetoothDeviceInfo &deviceInfo, const QLowEnergyController::RemoteAddressType &addressType = QLowEnergyController::PublicAddress, QObject *parent = nullptr);
QString name() const override;
QBluetoothAddress address() const override;

View File

@ -21,7 +21,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class QtAvahiService
\class nymeaserver::QtAvahiService
\brief Allows to publish an avahi service to the network.
\inmodule core
@ -56,7 +56,7 @@
namespace nymeaserver {
/*! Constructs a new \l{QtAvahiService} with the given \a parent. */
/*! Constructs a new QtAvahiService with the given \a parent. */
QtAvahiService::QtAvahiService(QObject *parent) :
QObject(parent),
d_ptr(new QtAvahiServicePrivate),

View File

@ -21,21 +21,13 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class QtAvahiServiceBrowserImplementation
\class nymeaserver::QtAvahiServiceBrowserImplementation
\brief Allows to browse avahi services in the local network.
\ingroup hardware
\inmodule libnymea
*/
/*! \fn void QtAvahiServiceBrowserImplementation::serviceEntryAdded(const AvahiServiceEntry &entry);
This signal will be emitted when a new \a entry was added to the current entry list.
*/
/*! \fn void QtAvahiServiceBrowserImplementation::serviceEntryRemoved(const AvahiServiceEntry &entry);
This signal will be emitted when a new \a entry was removed from the current entry list.
*/
#include "qtavahiservicebrowserimplementation.h"
#include "qtavahiservicebrowserimplementation_p.h"
#include "loggingcategories.h"

View File

@ -44,7 +44,7 @@ class QtAvahiServiceBrowserImplementation : public QtAvahiServiceBrowser
public:
explicit QtAvahiServiceBrowserImplementation(QObject *parent = nullptr);
~QtAvahiServiceBrowserImplementation();
~QtAvahiServiceBrowserImplementation() override;
QList<AvahiServiceEntry> serviceEntries() const override;

View File

@ -21,7 +21,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class NetworkAccessManagerImpl
\class nymeaserver::NetworkAccessManagerImpl
\brief Allows to send network requests and receive replies.
\ingroup hardware

View File

@ -21,7 +21,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class UpnpDiscoveryImplementation
\class nymeaserver::UpnpDiscoveryImplementation
\brief Allows to detect UPnP devices in the network.
\ingroup hardware
@ -35,12 +35,6 @@
\sa UpnpDevice, UpnpDeviceDescriptor
*/
/*!
\fn UpnpDiscoveryImplementation::upnpNotify(const QByteArray &notifyMessage)
This signal will be emitted when a UPnP NOTIFY message \a notifyMessage will be recognized.
\sa DevicePlugin::upnpNotifyReceived()
*/
#include "nymeasettings.h"
#include "loggingcategories.h"

View File

@ -21,7 +21,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class Radio433Brennenstuhl
\class nymeaserver::Radio433Brennenstuhl
\brief The Radio433 class helps to interact with the 433 MHz receiver and transmitter.
\ingroup hardware

View File

@ -137,7 +137,10 @@ bool WirelessAccessPoint::isProtected() const
return m_isProtected;
}
/*! Returns the security flags of this \l{WirelessAccessPoint}. \sa WirelessAccessPoint::ApSecurityModes */
/*! Returns the security flags of this \l{WirelessAccessPoint}.
\sa ApSecurityModes
*/
WirelessAccessPoint::ApSecurityModes WirelessAccessPoint::securityFlags() const
{
return m_securityFlags;

View File

@ -62,7 +62,7 @@
*/
/*! \fn void Coap::replyFinished(CoapReply *reply);
This signal is emitted when a \a reply is finished.
This signal is emitted when the given \a reply is finished.
*/
/*! \fn void Coap::notificationReceived(const CoapObserveResource &resource, const int &notificationNumber, const QByteArray &payload);
@ -79,7 +79,7 @@ Q_LOGGING_CATEGORY(dcCoap, "Coap")
/*! Constructs a Coap access manager with the given \a parent and \a port. */
Coap::Coap(QObject *parent, const quint16 &port) :
QObject(parent),
m_reply(0)
m_reply(nullptr)
{
m_socket = new QUdpSocket(this);

View File

@ -50,7 +50,7 @@ class LIBNYMEA_EXPORT Coap : public QObject
Q_OBJECT
public:
Coap(QObject *parent = 0, const quint16 &port = 5683);
Coap(QObject *parent = nullptr, const quint16 &port = 5683);
CoapReply *ping(const CoapRequest &request);
CoapReply *get(const CoapRequest &request);

View File

@ -20,8 +20,70 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class BluetoothDiscoveryReply
\brief The BluetoothDiscoveryReply class contains the result and interaction of a discovery request done with the BluetoothLowEnergyManager.
\ingroup hardware
\inmodule libnymea
\sa BluetoothLowEnergyManager
*/
/*! \fn BluetoothDiscoveryReply::~BluetoothDiscoveryReply();
The virtual destructor of the BluetoothDiscoveryReply.
*/
/*! \enum BluetoothDiscoveryReply::BluetoothDiscoveryReplyError
This enum represents the possible errors of a BluetoothDiscoveryReply.
\value BluetoothDiscoveryReplyErrorNoError
No error occured. Everything is fine.
\value BluetoothDiscoveryReplyErrorNotAvailable
The discovery could not be performed because there is no Bluetooth hardware available.
\value BluetoothDiscoveryReplyErrorNotEnabled
The discovery could not be performed because there is no Bluetooth hardware resource in nymea is disabled.
\value BluetoothDiscoveryReplyErrorBusy
The resource is currently busy.
*/
/*! \fn bool BluetoothDiscoveryReply::isFinished() const;
Returns true if this discovery replay is finished.
\sa finished, discoveredDevices
*/
/*! \fn bool BluetoothDiscoveryReply::finished();
This signal will be emitted whenever the discovery for this BluetoothDiscoveryReply is finished.
You can get the result of the discovery from discoveredDevices();
\sa isFinished, discoveredDevices
*/
/*! \fn void BluetoothDiscoveryReply::errorOccurred(const BluetoothDiscoveryReplyError &error);
This signal will be emitted whenever an \a error occured.
\sa error, BluetoothDiscoveryReplyError
*/
/*! \fn QList<QBluetoothDeviceInfo> BluetoothDiscoveryReply::discoveredDevices() const;
Returns the list of discovered \l{https://doc.qt.io/qt-5/qbluetoothdeviceinfo.html}{QBluetoothDeviceInfo}.
\sa isFinished, discoveredDevices
*/
/*! \fn BluetoothDiscoveryReplyError BluetoothDiscoveryReply::error() const;
Returns the current error of this BluetoothDiscoveryReply.
\sa BluetoothDiscoveryReplyError
*/
#include "bluetoothdiscoveryreply.h"
/*! Constructs a new BluetoothDiscoveryReply with the given \a parent. */
BluetoothDiscoveryReply::BluetoothDiscoveryReply(QObject *parent) :
QObject(parent)
{

View File

@ -20,8 +20,110 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class BluetoothLowEnergyDevice
\brief The class represent a physical Bluetooth LE device.
\ingroup hardware
\inmodule libnymea
\sa BluetoothLowEnergyManager
*/
/*! \fn BluetoothLowEnergyDevice::~BluetoothLowEnergyDevice();
The virtual destructor of the BluetoothLowEnergyDevice.
*/
/*! \fn QString BluetoothLowEnergyDevice::name() const;
Returns the advertise name of this BluetoothLowEnergyDevice.
*/
/*! \fn QBluetoothAddress BluetoothLowEnergyDevice::address() const;
Returns the bluetooth adderss of this BluetoothLowEnergyDevice.
*/
/*! \fn void BluetoothLowEnergyDevice::connectDevice();
Start connecting to this BluetoothLowEnergyDevice.
\sa stateChanged, disconnectDevice
*/
/*! \fn void BluetoothLowEnergyDevice::disconnectDevice();
Start disconnecting from this BluetoothLowEnergyDevice.
\sa stateChanged, connectDevice
*/
/*! \fn bool BluetoothLowEnergyDevice::autoConnecting() const;
Returns true, if this BluetoothLowEnergyDevice is reconnecting by it self when disconnected.
\sa autoConnectingChanged
*/
/*! \fn void BluetoothLowEnergyDevice::setAutoConnecting(const bool &autoConnecting);
Sets the reconnecting behaviour of this BluetoothLowEnergyDevice. If the \a autoConnecting is true,
the BluetoothLowEnergyDevice will reconnect by it self on disconnected.
\sa autoConnectingChanged
*/
/*! \fn bool BluetoothLowEnergyDevice::connected() const;
Returns true, if this BluetoothLowEnergyDevice is currently connected.
\sa connectedChanged
*/
/*! \fn bool BluetoothLowEnergyDevice::discovered() const;
Returns true, if all services of this BluetoothLowEnergyDevice have been discovered.
\sa serviceUuids
*/
/*! \fn QList<QBluetoothUuid> BluetoothLowEnergyDevice::serviceUuids() const;
Returns the list of service uuids from this BluetoothLowEnergyDevice. The list contains only data,
if the device has been discovered.
\sa discovered
*/
/*! \fn QLowEnergyController *BluetoothLowEnergyDevice::controller() const;
Returns the \l{http://doc.qt.io/qt-5/qlowenergycontroller.html}{QLowEnergyController} object of this BluetoothLowEnergyDevice
in order to provide the full Qt Bluetooth LE functionality.
*/
/*! \fn void BluetoothLowEnergyDevice::connectedChanged(const bool &connected);
This signal will be emitted whenever the \a connected state of this BluetoothLowEnergyDevice changed.
\sa connected, connectDevice, disconnectDevice
*/
/*! \fn void BluetoothLowEnergyDevice::autoConnectingChanged(const bool &autoConnecting);
This signal will be emitted whenever the \a autoConnecting state of this BluetoothLowEnergyDevice changed.
\sa autoConnecting, setAutoConnecting
*/
/*! \fn void BluetoothLowEnergyDevice::stateChanged(const QLowEnergyController::ControllerState &state);
This signal will be emitted whenever the \a state of this BluetoothLowEnergyDevice changed.
*/
/*! \fn void BluetoothLowEnergyDevice::errorOccurred(const QLowEnergyController::Error &error);
This signal will be emitted whenever an \a error occured.
*/
/*! \fn void BluetoothLowEnergyDevice::servicesDiscoveryFinished();
This signal will be emitted whenever the service discovery for this BluetoothLowEnergyDevice is finished.
\sa discovered, serviceUuids
*/
#include "bluetoothlowenergydevice.h"
/*! Constructs a new BluetoothLowEnergyDevice with the given \a parent. */
BluetoothLowEnergyDevice::BluetoothLowEnergyDevice(QObject *parent) :
QObject(parent)
{

View File

@ -36,7 +36,7 @@ class LIBNYMEA_EXPORT BluetoothLowEnergyDevice : public QObject
Q_OBJECT
public:
explicit BluetoothLowEnergyDevice(QObject *parent = 0);
explicit BluetoothLowEnergyDevice(QObject *parent = nullptr);
virtual ~BluetoothLowEnergyDevice() = default;
virtual QString name() const = 0;

View File

@ -20,14 +20,47 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class BluetoothLowEnergyManager
\brief The BluetoothLowEnergyManager class helps to interact with Bluetooth LE devices.
\ingroup hardware
\inmodule libnymea
\sa HardwareResource
*/
/*! \fn BluetoothLowEnergyManager::~BluetoothLowEnergyManager();
The virtual destructor of the BluetoothLowEnergyManager.
*/
/*! \fn BluetoothDiscoveryReply *BluetoothLowEnergyManager::discoverDevices(int interval = 5000);
This method starts a Bluetooth discovery process running for \a interval milli seconds. Returns a BluetoothDiscoveryReply object
which will emits the \l{BluetoothDiscoveryReply::finished()}{finished()} signal when the
\l{BluetoothDiscoveryReply::discoveredDevices()}{discoveredDevices()} list is ready.
*/
/*! \fn BluetoothLowEnergyDevice *BluetoothLowEnergyManager::registerDevice(const QBluetoothDeviceInfo &deviceInfo, const QLowEnergyController::RemoteAddressType &addressType = QLowEnergyController::RandomAddress);
This method should be used to register a bluetooth device in your DevicePlugin. Returns a new BluetoothLowEnergyDevice object with the given \a deviceInfo and \a addressType.
*/
/*! \fn void BluetoothLowEnergyManager::unregisterDevice(BluetoothLowEnergyDevice *bluetoothDevice);
This method should be used to unregister the given \a bluetoothDevice in your DevicePlugin if you don't need it any more.
*/
#include "bluetoothlowenergymanager.h"
#include "loggingcategories.h"
/*! Constructs a \l{BluetoothLowEnergyManager} with the given \a parent. */
BluetoothLowEnergyManager::BluetoothLowEnergyManager(QObject *parent) :
HardwareResource("Bluetooth LE manager", parent)
{
}
/*! This method enables / disables this hardwareresource for all plugins. This method is available on the D-Bus. This can be usefull if a Bluetooth LE server
needs access to the hardware. By disabling the bluetooth support, nymea will not allow to use the hardware until it gets reenabled.
*/
void BluetoothLowEnergyManager::EnableBluetooth(bool enabled)
{
setEnabled(enabled);

View File

@ -20,9 +20,44 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class Pwm
\brief The class represent a pulse wide modulation file system interface.
\ingroup hardware
\inmodule libnymea
This class provides a convenient access to the linux kernel PWM (pulse wide modulation) file system.
By default, this class will check in the system path \tt{/sys/class/pwm/} for any PWM chips.
You can find the kernel documentation \l{https://www.kernel.org/doc/Documentation/pwm.txt}{here}.
This class assumes a file system format where each hardware PWM chip has his own filepath.
\code
/sys/class/pwm/pwmchip0
/sys/class/pwm/pwmchip1
\endcode
The number \tt{pwmchip0} represents the chipNumber.
*/
/*! \enum Pwm::Polarity
\value PolarityNormal
Normal polarity. This is the default value.
\value PolarityInversed
Inversed polarity.
\value PolarityInvalid
The current polarity value is invalid.
*/
#include "pwm.h"
#include "loggingcategories.h"
/*! Constructs a new Pwm interface for the given \a chipNumber (\tt{/sys/class/pwm/pwmchip<chipNumber>}) with the given \a parent. */
Pwm::Pwm(int chipNumber, QObject *parent) :
QObject(parent),
m_chipNumber(chipNumber),
@ -32,17 +67,20 @@ Pwm::Pwm(int chipNumber, QObject *parent) :
m_pwmDirectory = QDir("/sys/class/pwm/pwmchip" + QString::number(chipNumber) + "/");
}
/*! Destructor for this Pwm interface. */
Pwm::~Pwm()
{
unexportPwm();
}
/*! Returns true, if the path \tt{/sys/class/pwm} exists and is not empty. */
bool Pwm::isAvailable()
{
QDir pwmDirectory("/sys/class/pwm");
return pwmDirectory.exists() && !pwmDirectory.entryList().isEmpty();
}
/*! Returns true, if this Pwm interface has been exported successfully. */
bool Pwm::exportPwm()
{
QFile exportFile(m_pwmDirectory.path() + "/export");
@ -57,6 +95,7 @@ bool Pwm::exportPwm()
return true;
}
/*! Returns true, if this Pwm interface has been enabled successfully. */
bool Pwm::enable()
{
QFile enableFile(m_pwmDirectory.path() + "/pwm0/enable");
@ -71,6 +110,7 @@ bool Pwm::enable()
return true;
}
/*! Returns true, if this Pwm interface has been disabled successfully. */
bool Pwm::disable()
{
QFile enableFile(m_pwmDirectory.path() + "/pwm0/enable");
@ -85,6 +125,7 @@ bool Pwm::disable()
return true;
}
/*! Returns true, if this Pwm interface is enabled. */
bool Pwm::isEnabled()
{
QFile enableFile(m_pwmDirectory.path() + "/pwm0/enable");
@ -103,11 +144,16 @@ bool Pwm::isEnabled()
return false;
}
/*! Returns the chip number of this \l{Pwm}.
The chip number indicates which file path will be used: \tt{/sys/class/pwm/pwmchip<chipNumber>}.
*/
int Pwm::chipNumber()
{
return m_chipNumber;
}
/*! Returns the period of this PWM. */
long Pwm::period()
{
// period = active + inactive time
@ -125,6 +171,7 @@ long Pwm::period()
return m_period;
}
/*! Returns true, if the period of this Pwm has been set to \a nanoSeconds successfully. */
bool Pwm::setPeriod(long nanoSeconds)
{
// the current duty cycle can not be greater than the period
@ -144,11 +191,13 @@ bool Pwm::setPeriod(long nanoSeconds)
return true;
}
/*! Returns the frequency [kHz] of the Pwm. */
double Pwm::frequency()
{
return (100000000.0 / (period() * 1000));
}
/*! Returns true, if the frequency [kHz] of this Pwm has been set successfully to the given \a kHz. */
bool Pwm::setFrequency(double kHz)
{
// p = 1 / f
@ -156,7 +205,7 @@ bool Pwm::setFrequency(double kHz)
return setPeriod(nanoSeconds);
}
// active time
/*! Returns the duty cycle [ns] of the Pwm. The duty cycle is the active time of one period. */
long Pwm::dutyCycle()
{
QFile dutyCycleFile(m_pwmDirectory.path() + "/pwm0/duty_cycle");
@ -173,6 +222,7 @@ long Pwm::dutyCycle()
return m_dutyCycle;
}
/*! Returns true, if the duty cycle [ns] of the Pwm has been set successfully to the given \a nanoSeconds. The duty cycle is the active time of one period. */
bool Pwm::setDutyCycle(long nanoSeconds)
{
// can not be greater than period or negative
@ -193,6 +243,7 @@ bool Pwm::setDutyCycle(long nanoSeconds)
return true;
}
/*! Returns the Polarity of this Pwm. */
Pwm::Polarity Pwm::polarity()
{
QFile polarityFile(m_pwmDirectory.path() + "/pwm0/polarity");
@ -215,6 +266,7 @@ Pwm::Polarity Pwm::polarity()
return PolarityInvalid;
}
/*! Returns true, if the polarity of this Pwm has been set to \a polarity successfully. */
bool Pwm::setPolarity(Pwm::Polarity polarity)
{
if (polarity == Pwm::PolarityInvalid)
@ -250,17 +302,20 @@ bool Pwm::setPolarity(Pwm::Polarity polarity)
return true;
}
/*! Returns the current percentage of this Pwm. */
int Pwm::percentage()
{
return (int)(dutyCycle() * (100.0 / period()) + 0.5);
}
/*! Returns true, if the percentage of this Pwm has been set to \a percentage successfully. */
bool Pwm::setPercentage(int percentage)
{
long nanoSeconds = period() * (percentage / 100.0);
return setDutyCycle(nanoSeconds);
}
/*! Returns true, if this Pwm interface has been unexported successfully. */
bool Pwm::unexportPwm()
{
QFile unexportFile(m_pwmDirectory.path() + "/unexport");

View File

@ -31,64 +31,55 @@
*/
/*!
\fn void DevicePlugin::devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &devices);
This signal is emitted when the discovery of a \a deviceClassId of this DevicePlugin is finished. The \a devices parameter describes the
list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}.
\sa discoverDevices()
/*! \fn void DevicePlugin::devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &devices);
This signal is emitted when the discovery of a \a deviceClassId of this DevicePlugin is finished. The \a devices parameter describes the
list of \l{DeviceDescriptor}{DeviceDescriptors} of all discovered \l{Device}{Devices}.
\sa discoverDevices()
*/
/*!
\fn void DevicePlugin::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceSetupStatus status);
This signal is emitted when the pairing of a \a pairingTransactionId is finished.
The \a status of the will be described as \l{DeviceManager::DeviceError}{DeviceError}.
\sa confirmPairing()
/*! \fn void DevicePlugin::pairingFinished(const PairingTransactionId &pairingTransactionId, DeviceManager::DeviceSetupStatus status);
This signal is emitted when the pairing of a \a pairingTransactionId is finished.
The \a status of the will be described as \l{DeviceManager::DeviceError}{DeviceError}.
\sa confirmPairing()
*/
/*!
\fn void DevicePlugin::deviceSetupFinished(Device *device, DeviceManager::DeviceSetupStatus status);
This signal is emitted when the setup of a \a device in this DevicePlugin is finished. The \a status parameter describes the
\l{DeviceManager::DeviceError}{DeviceError} that occurred.
/*! \fn void DevicePlugin::deviceSetupFinished(Device *device, DeviceManager::DeviceSetupStatus status);
This signal is emitted when the setup of a \a device in this DevicePlugin is finished. The \a status parameter describes the
\l{DeviceManager::DeviceError}{DeviceError} that occurred.
*/
/*!
\fn void DevicePlugin::configValueChanged(const ParamTypeId &paramTypeId, const QVariant &value);
This signal is emitted when the \l{Param} with a certain \a paramTypeId of a \l{Device} configuration changed the \a value.
/*! \fn void DevicePlugin::configValueChanged(const ParamTypeId &paramTypeId, const QVariant &value);
This signal is emitted when the \l{Param} with a certain \a paramTypeId of a \l{Device} configuration changed the \a value.
*/
/*!
\fn void DevicePlugin::actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status)
This signal is to be emitted when you previously have returned \l{DeviceManager}{DeviceErrorAsync}
in a call of executeAction(). The \a id refers to the executed \l{Action}. The \a status of the \l{Action}
execution will be described as \l{DeviceManager::DeviceError}{DeviceError}.
/*! \fn void DevicePlugin::actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status)
This signal is to be emitted when you previously have returned \l{DeviceManager}{DeviceErrorAsync}
in a call of executeAction(). The \a id refers to the executed \l{Action}. The \a status of the \l{Action}
execution will be described as \l{DeviceManager::DeviceError}{DeviceError}.
*/
/*!
\fn void DevicePlugin::autoDevicesAppeared(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &deviceDescriptors)
This signal is emitted when a new \l{Device} of certain \a deviceClassId appeared. The description of the \l{Device}{Devices}
will be in \a deviceDescriptors. This signal can only emitted from devices with the \l{DeviceClass}{CreateMethodAuto}.
/*! \fn void DevicePlugin::autoDevicesAppeared(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &deviceDescriptors)
This signal is emitted when a new \l{Device} of certain \a deviceClassId appeared. The description of the \l{Device}{Devices}
will be in \a deviceDescriptors. This signal can only emitted from devices with the \l{DeviceClass}{CreateMethodAuto}.
*/
/*!
\fn void DevicePlugin::autoDeviceDisappeared(const DeviceId &id)
Emit this signal when a device with the given \a id and which was created by \l{DevicePlugin::autoDevicesAppeared} has been removed from the system.
Be careful with this, as this will completely remove the device from the system and with it all the associated rules. Only
emit this if you are sure that a device will never come back. This signal should not be emitted for child auto devices
when the parent who created them is removed. The system will automatically remove all child devices in such a case.
/*! \fn void DevicePlugin::autoDeviceDisappeared(const DeviceId &id)
Emit this signal when a device with the given \a id and which was created by \l{DevicePlugin::autoDevicesAppeared} has been removed from the system.
Be careful with this, as this will completely remove the device from the system and with it all the associated rules. Only
emit this if you are sure that a device will never come back. This signal should not be emitted for child auto devices
when the parent who created them is removed. The system will automatically remove all child devices in such a case.
*/
/*!
\fn void DevicePlugin::emitEvent(const Event &event)
To produce a new event in the system, create a new \l{Event} and emit it with \a event.
Usually events are emitted in response to incoming data or other other events happening. Find a configured
\l{Device} from the \l{DeviceManager} and get its \l{EventType}{EventTypes}, then
create a \l{Event} complying to that \l{EventType} and emit it here.
/*! \fn void DevicePlugin::emitEvent(const Event &event)
To produce a new event in the system, create a new \l{Event} and emit it with \a event.
Usually events are emitted in response to incoming data or other other events happening. Find a configured
\l{Device} from the \l{DeviceManager} and get its \l{EventType}{EventTypes}, then
create a \l{Event} complying to that \l{EventType} and emit it here.
*/
/*!
\fn void DevicePlugin::init()
This will be called after constructing the DevicePlugin. Override this to do any
initialisation work you need to do.
/*! \fn void DevicePlugin::init()
This will be called after constructing the DevicePlugin. Override this to do any
initialisation work you need to do.
*/
#include "deviceplugin.h"
@ -189,12 +180,12 @@ bool DevicePlugin::setLocale(const QLocale &locale)
}
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
This will be called at startup, after the configured devices have been loaded.
This is the earliest time you should start emitting autoDevicesAppeared(). If you
are monitoring some hardware/service for devices to appear, start monitoring now.
If you are building the devices based on a static list, you may emit
autoDevicesAppeard() in here.
*/
This will be called at startup, after the configured devices have been loaded.
This is the earliest time you should start emitting autoDevicesAppeared(). If you
are monitoring some hardware/service for devices to appear, start monitoring now.
If you are building the devices based on a static list, you may emit
autoDevicesAppeard() in here.
*/
void DevicePlugin::startMonitoringAutoDevices()
{
@ -204,7 +195,8 @@ void DevicePlugin::startMonitoringAutoDevices()
This will be called to discover Devices for the given \a deviceClassId with the given \a params. This will always
be an async operation. Return \l{DeviceManager}{DeviceErrorAsync} or \l{DeviceManager}{DeviceErrorNoError}
if the discovery has been started successfully. Return an appropriate error otherwise.
Once devices are discovered, emit devicesDiscovered(). */
Once devices are discovered, emit devicesDiscovered().
*/
DeviceManager::DeviceError DevicePlugin::discoverDevices(const DeviceClassId &deviceClassId, const ParamList &params)
{
Q_UNUSED(deviceClassId)
@ -232,15 +224,17 @@ void DevicePlugin::postSetupDevice(Device *device)
}
/*! This will be called when a \a device removed. The plugin has the chance to do some teardown.
* The device is still valid during this call, but already removed from the system.
* The device will be deleted as soon as this method returns.*/
The device is still valid during this call, but already removed from the system.
The device will be deleted as soon as this method returns.
*/
void DevicePlugin::deviceRemoved(Device *device)
{
Q_UNUSED(device)
}
/*! This method will be called for \l{Device}{Devices} with the \l{DeviceClass::SetupMethodDisplayPin} right after the paring request
* with the given \a pairingTransactionId for the given \a deviceDescriptor.*/
with the given \a pairingTransactionId for the given \a deviceDescriptor.
*/
DeviceManager::DeviceError DevicePlugin::displayPin(const PairingTransactionId &pairingTransactionId, const DeviceDescriptor &deviceDescriptor)
{
Q_UNUSED(pairingTransactionId)
@ -252,8 +246,9 @@ DeviceManager::DeviceError DevicePlugin::displayPin(const PairingTransactionId &
}
/*! Confirms the pairing of a \a deviceClassId with the given \a pairingTransactionId and \a params.
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. The optional paramerter
* \a secret contains for example the pin for \l{Device}{Devices} with the setup method \l{DeviceClass::SetupMethodDisplayPin}.*/
Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. The optional paramerter
\a secret contains for example the pin for \l{Device}{Devices} with the setup method \l{DeviceClass::SetupMethodDisplayPin}.
*/
DeviceManager::DeviceSetupStatus DevicePlugin::confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList &params, const QString &secret = QString())
{
Q_UNUSED(pairingTransactionId)
@ -266,15 +261,15 @@ DeviceManager::DeviceSetupStatus DevicePlugin::confirmPairing(const PairingTrans
}
/*! This will be called to actually execute actions on the hardware. The \{Device} and
* the \{Action} are contained in the \a device and \a action parameters.
* Return the appropriate \l{DeviceManager::DeviceError}{DeviceError}.
*
* It is possible to execute actions asynchronously. You never should do anything blocking for
* a long time (e.g. wait on a network reply from the internet) but instead return
* DeviceManager::DeviceErrorAsync and continue processing in an async manner. Once
* you have the reply ready, emit actionExecutionFinished() with the appropriate parameters.
*
* \sa actionExecutionFinished()
the \{Action} are contained in the \a device and \a action parameters.
Return the appropriate \l{DeviceManager::DeviceError}{DeviceError}.
It is possible to execute actions asynchronously. You never should do anything blocking for
a long time (e.g. wait on a network reply from the internet) but instead return
DeviceManager::DeviceErrorAsync and continue processing in an async manner. Once
you have the reply ready, emit actionExecutionFinished() with the appropriate parameters.
\sa actionExecutionFinished()
*/
DeviceManager::DeviceError DevicePlugin::executeAction(Device *device, const Action &action)
{
@ -397,23 +392,20 @@ QPair<QStringList, QStringList> DevicePlugin::verifyFields(const QStringList &po
return QPair<QStringList, QStringList>(missingFields, unknownFields);
}
/*!
Returns a map containing the plugin configuration.
When implementing a new plugin, override this and fill in the empty configuration if your plugin requires any.
*/
/*! Returns a map containing the plugin configuration.
When implementing a new plugin, override this and fill in the empty configuration if your plugin requires any.
*/
ParamList DevicePlugin::configuration() const
{
return m_config;
}
/*!
Use this to retrieve the values for your parameters. Values might not be set
at the time when your plugin is loaded, but will be set soon after. Listen to
configurationValueChanged() to know when something changes.
When implementing a new plugin, specify in configurationDescription() what you want to see here.
Returns the config value of a \l{Param} with the given \a paramTypeId of this DevicePlugin.
*/
/*! Use this to retrieve the values for your parameters. Values might not be set
at the time when your plugin is loaded, but will be set soon after. Listen to
configurationValueChanged() to know when something changes.
When implementing a new plugin, specify in configurationDescription() what you want to see here.
Returns the config value of a \l{Param} with the given \a paramTypeId of this DevicePlugin.
*/
QVariant DevicePlugin::configValue(const ParamTypeId &paramTypeId) const
{
return m_config.paramValue(paramTypeId);
@ -465,11 +457,9 @@ DeviceManager::DeviceError DevicePlugin::setConfigValue(const ParamTypeId &param
return DeviceManager::DeviceErrorNoError;
}
/*!
Returns a pointer to the \l{DeviceManager}.
When implementing a plugin, use this to find the \l{Device}{Devices} you need.
*/
/*! Returns a pointer to the \l{DeviceManager}.
When implementing a plugin, use this to find the \l{Device}{Devices} you need.
*/
DeviceManager *DevicePlugin::deviceManager() const
{
return m_deviceManager;
@ -498,10 +488,9 @@ HardwareManager *DevicePlugin::hardwareManager() const
return m_deviceManager->hardwareManager();
}
/*!
Find a certain device from myDevices() by its \a params. All parameters must
match or the device will not be found. Be prepared for nullptrs.
*/
/*! Find a certain device from myDevices() by its \a params. All parameters must
match or the device will not be found. Be prepared for nullptrs.
*/
Device *DevicePlugin::findDeviceByParams(const ParamList &params) const
{
foreach (Device *device, myDevices()) {

View File

@ -42,7 +42,8 @@ INSTALLS += translations
QMAKE_EXTRA_TARGETS += licensecheck doc test lupdate lrelease
# Show doc files in project tree
OTHER_FILES += doc/*.qdoc*
OTHER_FILES += doc/*.qdoc* \
doc/tutorials/*.qdoc*
# Inform about nymea build
message(============================================)

View File

@ -36,8 +36,6 @@
and \l{Vendor}{Vendors} of this \l{DevicePlugin}.
For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}.
\quotefile plugins/mock/devicepluginmock.json
*/
#include "devicepluginmock.h"