Compare commits
No commits in common. "master" and "light-2.0" have entirely different histories.
801 changed files with 8563 additions and 95885 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,7 +0,0 @@
|
|||
build/
|
||||
qtcreator-build/
|
||||
Doxyfile
|
||||
html/
|
||||
latex/
|
||||
CMakeLists.txt.user
|
||||
*.pyc
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "telldus-gui/3rdparty/qt-components-desktop"]
|
||||
path = telldus-gui/3rdparty/qt-components-desktop
|
||||
url = http://git.telldus.com/qt-components-desktop.git
|
|
@ -1,35 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TellStick.NET")]
|
||||
[assembly: AssemblyDescription("A managed .NET wrapper class library for the TellStick native DLL")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Eyedealistic / Levén Labs (http://labs.leven.se)")]
|
||||
[assembly: AssemblyProduct("TellStick.NET")]
|
||||
[assembly: AssemblyCopyright("Created by Mikael Levén in 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("24411992-c766-4eb8-b7ac-c002f0d7d5ad")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("0.1.0.*")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
102
3rdparty/tellstick.net/TellStick.NET.csproj
vendored
102
3rdparty/tellstick.net/TellStick.NET.csproj
vendored
|
@ -1,102 +0,0 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{700E41E9-ADB6-4D5A-B9EB-B6560C1C0D3F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TellStick</RootNamespace>
|
||||
<AssemblyName>TellStick.NET</AssemblyName>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>none</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DocumentationFile>bin\x86\Release\TellStick.NET.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>none</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DocumentationFile>bin\x64\Release\TellStick.NET.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TellStick.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
318
3rdparty/tellstick.net/TellStick.cs
vendored
318
3rdparty/tellstick.net/TellStick.cs
vendored
|
@ -1,318 +0,0 @@
|
|||
/* -------------------------------------------------------------------------------
|
||||
* TellStick.NET
|
||||
* -------------------------------------------------------------------------------
|
||||
* Created by Mikael Levén (http://labs.leven.se)
|
||||
*
|
||||
* This piece of code is licensed as open source and can be freely used and
|
||||
* redistributed in any type of project, both commercial and non-commercial,
|
||||
* as long as this licensing policy is not altered. This means that any alterations
|
||||
* of this code must also be licensed as open source and therefore cannot be
|
||||
* protected or patented in any way. However, any software based on this code may
|
||||
* still be copyrighted (and/or patented) and sold as propritary software as long as
|
||||
* this code (and any alterations of it) can be freely used and modified by others.
|
||||
*
|
||||
* Altough the code is licensed as open source you don't need to republish any
|
||||
* changes made back to the community (it will be much appreciated tough).
|
||||
*
|
||||
* The code comes without any kind of warrantys and the author cannot be held
|
||||
* responsible for any kind of damage this software may (or may not) cause, no matter
|
||||
* if it's direct or indirect damage.
|
||||
*
|
||||
* Please note:
|
||||
* All TellStick core functionality is developed by Telldus Technologies
|
||||
* and as of now (2007-12-14) that code is also licensed as open source. This may
|
||||
* however change in the future and I suggest that you check there website
|
||||
* to make sure the licensing terms are still the same: http://www.telldus.se/
|
||||
* The documentation and example code for Tellstic is available at their Wiki:
|
||||
* http://www.telldus.se/wiki/
|
||||
*
|
||||
* -------------------------------------------------------------------------------
|
||||
* Description:
|
||||
* TellStick.NET is a Microsoft .NET wrapper for the native TellStick DLL.
|
||||
* The wrapper also adds some functionality to make it easier to work with
|
||||
* TellStick devices.
|
||||
*
|
||||
* Author: Mikael Levén
|
||||
* Created: 2007-12-14
|
||||
*
|
||||
* Dependencies:
|
||||
* This library depends on the native DLL for TellStick. To be able to actually
|
||||
* switch lights on and off you also need the driver to be installed as well
|
||||
* as an TellStick USB device.
|
||||
*
|
||||
* Revisions:
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// TellStick.NET is a Microsoft .NET wrapper for the native TellStick DLL.
|
||||
/// The wrapper also adds some functionality to make it easier to work with TellStick devices.
|
||||
/// </summary>
|
||||
public sealed class TellStick
|
||||
{
|
||||
private TellStick()
|
||||
{ }
|
||||
|
||||
|
||||
#region TellStick native DLL imports class
|
||||
public sealed class Native
|
||||
{
|
||||
private Native()
|
||||
{ }
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern int devAddDevice();
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devTurnOn(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devTurnOff(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern int devGetNumberOfDevices();
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern string devGetName(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devSetName(int intDeviceId, string chNewName);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern string devGetVendor(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devSetVendor(int intDeviceId, string chNewName);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern string devGetModel(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devSetModel(int intDeviceId, string chNewName);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern int[] devGetArguments(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devSetArguments(int intDeviceId, int[] intArguments, int intNumberOfArguments);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern int devAddDeviceWithArguments(string strVendor, int[] intArguments, int intNumberOfArguments);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern bool devRemoveDevice(int intDeviceId);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
public static extern int devGetDeviceId(int intDeviceIndex);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of devices registered
|
||||
/// </summary>
|
||||
/// <returns>Returns the number of devices as an integer</returns>
|
||||
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
|
||||
public static int GetNumberOfDevices()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.devGetNumberOfDevices();
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
{
|
||||
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique idetifier of the device
|
||||
/// </summary>
|
||||
/// <param name="deviceIndex">Index number of the device to get ID for</param>
|
||||
/// <returns>Returns the unique identifier as an integer</returns>
|
||||
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
|
||||
public static int GetDeviceId(int deviceIndex)
|
||||
{
|
||||
// Retrieve and return the device unqiue identifier from the native method
|
||||
try
|
||||
{
|
||||
return Native.devGetDeviceId(deviceIndex);
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
{
|
||||
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user defined name of the device
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Device unqiue identification</param>
|
||||
/// <returns>Returns the user defined device name as a string</returns>
|
||||
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
|
||||
public static string GetName(int deviceId)
|
||||
{
|
||||
// Retrieve and return the device name from the native method
|
||||
try
|
||||
{
|
||||
return Native.devGetName(deviceId);
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
{
|
||||
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Turns on the selected device
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Device unqiue identification</param>
|
||||
/// <returns>Returns true if the device was succesfully turned on</returns>
|
||||
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
|
||||
public static bool TurnOn(int deviceId)
|
||||
{
|
||||
// Send "on" signal
|
||||
try
|
||||
{
|
||||
return Native.devTurnOn(deviceId);
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
{
|
||||
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns off the selected device
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Device unqiue identification</param>
|
||||
/// <returns>Returns true if the device was succesfully turned off</returns>
|
||||
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
|
||||
public static bool TurnOff(int deviceId)
|
||||
{
|
||||
// Send "off" signal
|
||||
try
|
||||
{
|
||||
return Native.devTurnOff(deviceId);
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
{
|
||||
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vendors name
|
||||
/// </summary>
|
||||
/// <param name="deviceId"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
|
||||
public static string GetVendor(int deviceId)
|
||||
{
|
||||
// Retrieve and return the vendor from the native method
|
||||
try
|
||||
{
|
||||
return Native.devGetVendor(deviceId);
|
||||
}
|
||||
catch (System.DllNotFoundException ex)
|
||||
{
|
||||
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region "Support classes"
|
||||
|
||||
public abstract class TellStickException : System.Exception
|
||||
{
|
||||
public TellStickException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public TellStickException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public TellStickException(string message, System.Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class UnmanagedException : TellStickException
|
||||
{
|
||||
public UnmanagedException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public UnmanagedException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public UnmanagedException(string message, System.Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ModuleNotFoundException : TellStickException
|
||||
{
|
||||
public ModuleNotFoundException()
|
||||
: base("Could not find TellStick software. Please make sure it's installed before you run this application!")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ModuleNotFoundException(string message)
|
||||
: base(message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ModuleNotFoundException(string message, System.Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
674
3rdparty/tellstickcontroller/License
vendored
674
3rdparty/tellstickcontroller/License
vendored
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state 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 program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
181
3rdparty/tellstickcontroller/Readme
vendored
181
3rdparty/tellstickcontroller/Readme
vendored
|
@ -1,181 +0,0 @@
|
|||
This Readme explains how to use tellstickControllerTdtool and
|
||||
tellstickControllerRfcmd programs to control a tellstick.
|
||||
|
||||
The tellstickController shell script can be used as a wrapper help
|
||||
for old users.
|
||||
|
||||
The two configuration files can also be used as a starting point on
|
||||
how to control receiver devices when running tellstickController in
|
||||
daemon mode.
|
||||
|
||||
tellstickControllerTdtool.conf shows how the configuration file can
|
||||
be written when using tdtool. Remember that tellstick.conf needs to
|
||||
be used for actual confiuration of receiver devices.
|
||||
|
||||
tellstickControllerRfcmd.conf shows how the configuration file can
|
||||
be written when using rfcmd.
|
||||
|
||||
The example directory contains a number of shell scripts that can be
|
||||
used as a starting point for how to use tellstickController.
|
||||
|
||||
######################################################################
|
||||
|
||||
NAME
|
||||
tellstickControllerTdtool
|
||||
|
||||
SYNOPSIS
|
||||
tellstickControllerTdtool [options]
|
||||
|
||||
DESCRIPTION
|
||||
tellstickController is used for controlling wireless recevier devices from
|
||||
a TellStick transmitter. This version uses the tdtool software to perform
|
||||
the actual device control. tellstickController can be used for manual
|
||||
control of devices, or used as a daemon that is controlled by a number of
|
||||
configuration file rules.
|
||||
Devices and groups can be accessed by either name or id.
|
||||
States can be set to ON, OFF or an integer between 0-255 for dimmer.
|
||||
|
||||
-h, --help Show this help text.
|
||||
-v, --verbose Show extra information.
|
||||
-d, --daemon Starts in daemon mode.
|
||||
-f, --file F Set configfile to file F.
|
||||
-c, --check Check content of configuration file.
|
||||
-t, --test Test mode, no real devices will used.
|
||||
-a, --aliases List of aliases for devices/groups.
|
||||
-l, --list List states for all devices/groups.
|
||||
-s, --set D S Set device D to state S
|
||||
-g, --get D Get state for device/group D.
|
||||
-w, --swapfirst G Swap states for group G based on first device state.
|
||||
-x, --swap D Swap state for device/group D.
|
||||
|
||||
EXAMPLES
|
||||
tellstickControllerTdtool -l
|
||||
tellstickControllerTdtool --set device_alias on
|
||||
tellstickControllerTdtool --swap device_alias
|
||||
tellstickControllerTdtool -d -f myConfigFile.conf
|
||||
|
||||
DEPENDENCIES
|
||||
The following Perl modules needs to be installed:
|
||||
DateTime and DateTime::Event::Sunrise
|
||||
|
||||
FILES
|
||||
tellstickController.conf
|
||||
tellstickController.log
|
||||
tellstickController.pid
|
||||
|
||||
CONFIGURATION
|
||||
The configuration file consists of a number of settings 'Set', a number of
|
||||
group aliases 'Group', and a number of device rules 'Rules'.
|
||||
|
||||
The settings controls sunrise/sunset, logfile, pidfile, etc.
|
||||
|
||||
The groups configures a list of devices and a delay time.
|
||||
|
||||
The rules can be written as a string containing two parts.
|
||||
The first part is optional and ends with an '/'. It can contain one or more
|
||||
of these keywords 'Weekend', 'Workweek', 'Monday', 'Tuesday', 'Wednesday',
|
||||
'Thursday', 'Friday', 'Saturday' and 'Sunday'. A specified date like
|
||||
'2008-03-18', '2008-03-##', '####-03-##' or '####-##-15' is also allowed.
|
||||
The second part is mandatory and is either a expression or the keyword 'No'.
|
||||
The expression can contain a micture of these keywords 'Sunrise', 'Sunset',
|
||||
'Random(HH:MM)', 'HH:MM' and 'Dimmer(HH:MM,startlevel,stoplevel,steplevel)'.
|
||||
A Dimmer can be controlled to change dim level from startlevel to stoplevel
|
||||
by adding/subtracting steplevel value every HH:MM time period.
|
||||
|
||||
Example rule: Weekend/07:15
|
||||
Example rule: Monday+Sunday/07:15
|
||||
Example rule: 2008-03-##/12:10
|
||||
Example rule: 07:15+Random(02:00)
|
||||
Example rule: Sunset-00:30
|
||||
Example rule: Workweek/07:00+Dimmer(00:01,5,255,25)
|
||||
|
||||
AUTHOR
|
||||
Original version written by Rickard Andersson
|
||||
|
||||
LICENSE
|
||||
Copyright (C) 2008-2010 Rickard Andersson. Version 2.0.0
|
||||
This program comes with ABSOLUTELY NO WARRANTY.
|
||||
This is free software, and you are welcome to redistribute it under certain
|
||||
conditions; See license file for details.
|
||||
|
||||
######################################################################
|
||||
|
||||
NAME
|
||||
tellstickControllerRfcmd
|
||||
|
||||
SYNOPSIS
|
||||
tellstickControllerRfcmd [options]
|
||||
|
||||
DESCRIPTION
|
||||
tellstickController is used for controlling wireless recevier devices from
|
||||
a TellStick transmitter. This version uses the rfcmd software to perform
|
||||
the actual device control. tellstickController can be used for manual
|
||||
control of devices, or used as a daemon that is controlled by a number of
|
||||
configuration file rules.
|
||||
A small database is used for keeping track of device states between every
|
||||
execution of tellstickController.
|
||||
|
||||
-h, --help Show this help text.
|
||||
-v, --verbose Show extra information.
|
||||
-d, --daemon Starts in daemon mode.
|
||||
-f, --file F Set configfile to file F.
|
||||
-c, --check Check content of configuration file.
|
||||
-t, --test Test mode, no real devices will used.
|
||||
-a, --aliases List of aliases for devices/groups.
|
||||
-l, --list List states for all devices/groups.
|
||||
-s, --set D S Set device D to state S.
|
||||
-g, --get D Get state for device/group D.
|
||||
-w, --swapfirst G Swap states for group G based on first device state.
|
||||
-x, --swap D Swap state for device/group D.
|
||||
|
||||
EXAMPLES
|
||||
tellstickControllerRfcmd -l
|
||||
tellstickControllerRfcmd --set device_alias on
|
||||
tellstickControllerRfcmd --swap device_alias
|
||||
tellstickControllerRfcmd -d -f myConfigFile.conf
|
||||
|
||||
DEPENDENCIES
|
||||
The following Perl modules needs to be installed:
|
||||
DB_File, DateTime and DateTime::Event::Sunrise
|
||||
|
||||
FILES
|
||||
tellstickController.conf
|
||||
tellstickController.db
|
||||
tellstickController.log
|
||||
tellstickController.pid
|
||||
|
||||
CONFIGURATION
|
||||
The configuration file consists of a number of settings 'Set', a number of
|
||||
device aliases 'Alias', and a number of device rules 'Rules'.
|
||||
|
||||
The settings controls sunrise/sunset, logfile, pidfile, etc.
|
||||
|
||||
The aliases configures device name, channel, code, etc.
|
||||
|
||||
The groups configures a list of devices and a delay time.
|
||||
|
||||
The rules can be written as a string containing two parts.
|
||||
The first part is optional and ends with an '/'. It can contain one or more
|
||||
of these keywords 'Weekend', 'Workweek', 'Monday', 'Tuesday', 'Wednesday',
|
||||
'Thursday', 'Friday', 'Saturday' and 'Sunday'. A specified date like
|
||||
'2008-03-18', '2008-03-##', '####-03-##' or '####-##-15' is also allowed.
|
||||
The second part is mandatory and is either a expression or the keyword 'No'.
|
||||
The expression can contain a micture of these keywords 'Sunrise', 'Sunset',
|
||||
'Random(HH:MM)' and 'HH:MM'.
|
||||
|
||||
Example rule: Weekend/07:15
|
||||
Example rule: Monday+Sunday/07:15
|
||||
Example rule: 2008-03-##/12:10
|
||||
Example rule: 07:15+Random(02:00)
|
||||
Example rule: Sunset-00:30
|
||||
|
||||
AUTHOR
|
||||
Original version written by Rickard Andersson
|
||||
|
||||
LICENSE
|
||||
Copyright (C) 2008-2010 Rickard Andersson. Version 2.0.0
|
||||
This program comes with ABSOLUTELY NO WARRANTY.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; See license file for details.
|
||||
|
||||
######################################################################
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Power off every device that control light sources.
|
||||
#
|
||||
|
||||
tellstickController --set bedroom_mythtv_leds off
|
||||
tellstickController --set bedroom_window off
|
||||
tellstickController --set kitchen_cabinets off
|
||||
tellstickController --set livingroom_cabinets off
|
||||
tellstickController --set livingroom_mythtv_leds off
|
||||
tellstickController --set livingroom_uplight off
|
||||
tellstickController --set livingroom_wall_north off
|
||||
tellstickController --set livingroom_wall_east off
|
||||
tellstickController --set livingroom_window off
|
||||
tellstickController --set study_window off
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Power off bedroom MythTV, turn off backlight leds.
|
||||
#
|
||||
|
||||
tellstickController --set bedroom_mythtv_power off
|
||||
tellstickController --set bedroom_mythtv_leds off
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Power on every device that control light sources.
|
||||
#
|
||||
|
||||
tellstickController --set bedroom_mythtv_leds on
|
||||
tellstickController --set bedroom_window on
|
||||
tellstickController --set kitchen_cabinets on
|
||||
tellstickController --set livingroom_cabinets on
|
||||
tellstickController --set livingroom_mythtv_leds on
|
||||
tellstickController --set livingroom_uplight on
|
||||
tellstickController --set livingroom_wall_north on
|
||||
tellstickController --set livingroom_wall_east on
|
||||
tellstickController --set Livingroom_window on
|
||||
tellstickController --set study_window on
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Power on bedroom MythTV, turn on backlight leds and turn off window lamp.
|
||||
#
|
||||
|
||||
tellstickController --set bedroom_mythtv_power on
|
||||
tellstickController --set bedroom_mythtv_leds on
|
||||
tellstickController --set bedroom_window off
|
||||
tellstickController --set bedroom_bed off
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Swaps livingroom tv mode on/off
|
||||
#
|
||||
|
||||
led_status=`tellstickController --get livingroom_mythtv_leds`
|
||||
#echo $led_status
|
||||
|
||||
if [ "$led_status" != "on" ]; then
|
||||
# echo on
|
||||
tellstickController --set livingroom_cabinets on
|
||||
tellstickController --set livingroom_mythtv_leds on
|
||||
tellstickController --set livingroom_uplight off
|
||||
tellstickController --set livingroom_wall_north on
|
||||
tellstickController --set livingroom_wall_east off
|
||||
tellstickController --set Livingroom_window on
|
||||
else
|
||||
# echo off
|
||||
tellstickController --set livingroom_cabinets on
|
||||
tellstickController --set livingroom_mythtv_leds off
|
||||
tellstickController --set livingroom_uplight off
|
||||
tellstickController --set livingroom_wall_north on
|
||||
tellstickController --set livingroom_wall_east on
|
||||
tellstickController --set Livingroom_window on
|
||||
fi
|
||||
|
||||
exit
|
|
@ -1,96 +0,0 @@
|
|||
################################################################################
|
||||
#
|
||||
# Configuration file for tellstickController
|
||||
#
|
||||
# Copyright (C) 2008 Rickard Andersson (ran42ran@gmail.com)
|
||||
# Version: 1.4
|
||||
#
|
||||
################################################################################
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# List of location settings.
|
||||
#
|
||||
# Usage example:
|
||||
# Set Key Value
|
||||
# Set Timezone Europe/Stockholm
|
||||
#
|
||||
#
|
||||
Set Timezone Europe/Stockholm
|
||||
Set Latitude 58.24
|
||||
Set Longitude 15.31
|
||||
Set dbfile /var/lib/tellstickController.db
|
||||
Set pidfile /var/run/tellstickController.pid
|
||||
Set logfile /var/log/tellstickController.log
|
||||
|
||||
|
||||
# Aliases for recevier devices.
|
||||
#
|
||||
# Usage example:
|
||||
# Alias Name Sender Dimmer Protocol Housecode Channel
|
||||
# Alias BedroomWindow /dev/tellstick0 yes Nexa A 1
|
||||
# Alias device42 /dev/tellstick1 No Waveman B 3
|
||||
# or
|
||||
# Usage example:
|
||||
# Alias Name Sender Dimmer Protocol Channel
|
||||
# Alias MythTv_Backlight /dev/ttyUSB0 No Sartano 000000001
|
||||
#
|
||||
#
|
||||
Alias Bedroom_window /dev/tellstick0 No Nexa G 10
|
||||
Alias Bedroom_mythtv_power /dev/tellstick0 No Nexa G 6
|
||||
Alias Bedroom_mythtv_leds /dev/tellstick0 No Nexa G 7
|
||||
Alias Kitchen_cabinets /dev/tellstick0 No Nexa G 2
|
||||
Alias Kitchen_window /dev/tellstick0 No Nexa G 11
|
||||
Alias Livingroom_cabinets /dev/tellstick0 No Nexa G 3
|
||||
Alias Livingroom_wall_north /dev/tellstick0 No Nexa G 4
|
||||
Alias Livingroom_wall_east /dev/tellstick0 No Nexa G 9
|
||||
Alias Livingroom_uplight /dev/tellstick0 Yes Nexa G 5
|
||||
Alias Livingroom_mythtv_leds /dev/tellstick0 No Nexa G 8
|
||||
Alias Livingroom_window /dev/tellstick0 No Nexa G 1
|
||||
Alias Study_window /dev/tellstick0 No Nexa G 12
|
||||
|
||||
|
||||
# Group aliases uses for handling a group of aliases
|
||||
#
|
||||
# Usage examples:
|
||||
# Group Name Delay List of Aliases
|
||||
# Group Livingroom_walls 60 Livingroom_wall_north Livingroom_wall_east
|
||||
# Group Kitchen 5 Kitchen_cabinets Kitchen_window
|
||||
#
|
||||
#
|
||||
Group Christmas_lights 20 Bedroom_window Kitchen_window Study_window
|
||||
Group Background_lights 60 Kitchen_cabinets Livingroom_window Livingroom_wall_east Livingroom_wall_north
|
||||
Group All_lights 10 Bedroom_mythtv_leds Bedroom_window Kitchen_cabinets Kitchen_window Livingroom_cabinets Livingroom_mythtv_leds Livingroom_uplight Livingroom_wall_north Livingroom_wall_east Livingroom_window Study_window
|
||||
|
||||
|
||||
# Timer rules for reciever devices.
|
||||
#
|
||||
# Usage examples:
|
||||
# Rule Alias DeviceOn DeviceOff
|
||||
# Rule BedroomWindow Sunrise Sunrise+01:30
|
||||
# Rule BedroomWindow 18:33 23:10+Random(00:45)
|
||||
# Rule MythTv_Backlight Weekend/20:00 Weekend/Sunset
|
||||
#
|
||||
#
|
||||
Rule Background_lights Workweek/Sunset+Random(01:00) Workweek/00:00+Random(00:30)
|
||||
Rule Background_lights Weekend/Sunset-Random(00:30) Weekend/00:45+Random(00:30)
|
||||
|
||||
Rule Christmas_lights 07:00+Random(00:30) 09:00+Random(00:30)
|
||||
Rule Christmas_lights 14:30+Random(00:30) 00:30+Random(00:30)
|
||||
|
||||
Rule Kitchen_cabinets Sunrise-01:30 Sunrise+01:00
|
||||
|
||||
Rule All_lights No 02:00
|
142
3rdparty/tellstickcontroller/tellstick.conf
vendored
142
3rdparty/tellstickcontroller/tellstick.conf
vendored
|
@ -1,142 +0,0 @@
|
|||
deviceNode = "/dev/tellstick0"
|
||||
|
||||
device {
|
||||
id = 1
|
||||
name = "Bedroom_bed"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100010"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 2
|
||||
name = "Bedroom_window"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100020"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 3
|
||||
name = "Bedroom_mythtv_leds"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100030"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 4
|
||||
name = "Study_window"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100040"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 5
|
||||
name = "Kitchen_cabinets"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100050"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 6
|
||||
name = "Bedroom_dimmer"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-dimmer"
|
||||
parameters {
|
||||
house = "100060"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 7
|
||||
name = "Livingroom_cabinets"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100070"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 8
|
||||
name = "Livingroom_wall_north"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100080"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 9
|
||||
name = "Test"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100090"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 10
|
||||
name = "Livingroom_window"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100100"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 11
|
||||
name = "Kitchen_window"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100110"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 12
|
||||
name = "Livingroom_wall_east"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100120"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 13
|
||||
name = "Livingroom_mythtv_leds"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-switch"
|
||||
parameters {
|
||||
house = "100130"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
||||
device {
|
||||
id = 14
|
||||
name = "Livingroom_uplight"
|
||||
protocol = "arctech"
|
||||
model = "selflearning-dimmer"
|
||||
parameters {
|
||||
house = "100140"
|
||||
unit = "1"
|
||||
}
|
||||
}
|
58
3rdparty/tellstickcontroller/tellstickController
vendored
58
3rdparty/tellstickcontroller/tellstickController
vendored
|
@ -1,58 +0,0 @@
|
|||
#!/bin/sh
|
||||
######################################################################
|
||||
#
|
||||
# Wrapper script that can be used to select which tellstickController
|
||||
# program to run
|
||||
#
|
||||
# Copyright (C) 2008-2010 Rickard Andersson (ran42ran@gmail.com)
|
||||
# Version 2.0.0
|
||||
#
|
||||
######################################################################
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
######################################################################
|
||||
#
|
||||
# How to run tellstickController with tdtool
|
||||
# tellstickController --tdtool --list
|
||||
#
|
||||
# How to run tellstickController with rfcmd
|
||||
# tellstickController --rdfcmd --list
|
||||
#
|
||||
# How to run tellstickController with default program (tdtool or rfcmd)
|
||||
# tellstickController --list
|
||||
#
|
||||
|
||||
|
||||
case "$1" in
|
||||
--tdtool)
|
||||
shift
|
||||
tellstickControllerTdtool $@
|
||||
exit $?
|
||||
;;
|
||||
--rfcmd)
|
||||
shift
|
||||
tellstickControllerRfcmd $@
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
#
|
||||
# Uncomment your choice of default program below
|
||||
#
|
||||
|
||||
# tellstickControllerRfcmd $@
|
||||
tellstickControllerTdtool $@
|
||||
|
||||
exit $?
|
|
@ -1,85 +0,0 @@
|
|||
################################################################################
|
||||
#
|
||||
# Configuration file for tellstickController
|
||||
#
|
||||
# Copyright (C) 2008-2010 Rickard Andersson (ran42ran@gmail.com)
|
||||
# Version: 2.0.0
|
||||
#
|
||||
################################################################################
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# List of location settings.
|
||||
#
|
||||
# Usage example:
|
||||
# Set Key Value
|
||||
#
|
||||
# Set Timezone Europe/Stockholm
|
||||
#
|
||||
Set Timezone Europe/Stockholm
|
||||
Set Altitude -0.833
|
||||
Set Latitude 58.24
|
||||
Set Longitude 15.31
|
||||
Set dbfile /var/lib/tellstickController.db
|
||||
Set pidfile /var/run/tellstickController.pid
|
||||
Set logfile /var/log/tellstickController.log
|
||||
|
||||
|
||||
# Aliases for recevier devices.
|
||||
#
|
||||
# Usage example:
|
||||
# Alias Name Sender Dimmer Protocol Housecode Channel
|
||||
#
|
||||
# Alias BedroomWindow /dev/tellstick0 yes Nexa A 1
|
||||
# Alias device42 /dev/tellstick1 No Waveman B 3
|
||||
#
|
||||
# or
|
||||
#
|
||||
# Usage example:
|
||||
# Alias Name Sender Dimmer Protocol Channel
|
||||
#
|
||||
# Alias MythTv_Backlight /dev/ttyUSB0 No Sartano 000000001
|
||||
#
|
||||
Alias device1 /dev/tellstick No Nexa A 1
|
||||
Alias device2 /dev/tellstick No Nexa A 2
|
||||
|
||||
|
||||
# Groups used for handling a list of aliases.
|
||||
#
|
||||
# Usage examples:
|
||||
# Group Name Delay Aliases
|
||||
# Group Livingroom_walls 60 Livingroom_wall_north Livingroom_wall_east
|
||||
# Group Kitchen 5 Kitchen_cabinets Kitchen_window
|
||||
#
|
||||
Group allDevices 10 Device1 Device2
|
||||
|
||||
|
||||
# Timer rules for reciever devices.
|
||||
#
|
||||
# Usage examples:
|
||||
# Rule Alias DeviceOn DeviceOff
|
||||
#
|
||||
# Rule BedroomWindow Sunrise Sunrise+01:30
|
||||
# Rule BedroomWindow 18:33 23:10+Random(00:45)
|
||||
# Rule MythTv_Backlight Weekend/20:00 Weekend/Sunset
|
||||
# Rule device42 2008-03-##/18:45 2008-03-##/22:11
|
||||
# Rule device42 No 02:00
|
||||
#
|
||||
Rule device1 weekend/sunrise weekend/08:45
|
||||
Rule device1 sunset+00:15 23:30+Random(00:20)
|
||||
Rule device2 Workweek/07:00+Dimmer(00:02,0,200,25) weekend/08:45
|
||||
Rule allDevices 16:45 23:45
|
||||
|
1083
3rdparty/tellstickcontroller/tellstickControllerRfcmd
vendored
1083
3rdparty/tellstickcontroller/tellstickControllerRfcmd
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,108 +0,0 @@
|
|||
################################################################################
|
||||
#
|
||||
# Configuration file for tellstickController
|
||||
#
|
||||
# Copyright (C) 2008 Rickard Andersson (ran42ran@gmail.com)
|
||||
# Version: 1.4
|
||||
#
|
||||
################################################################################
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# List of location settings.
|
||||
#
|
||||
# Usage example:
|
||||
# Set Key Value
|
||||
# Set Timezone Europe/Stockholm
|
||||
#
|
||||
#
|
||||
Set Timezone Europe/Stockholm
|
||||
Set Altitude -0.833
|
||||
Set Latitude 58.24
|
||||
Set Longitude 15.31
|
||||
Set dbfile /var/lib/tellstickController.db
|
||||
Set pidfile /var/run/tellstickController.pid
|
||||
Set logfile /var/log/tellstickController.log
|
||||
set progrsm /usr/bin/rfcmd
|
||||
|
||||
|
||||
# Aliases for recevier devices.
|
||||
#
|
||||
# Usage example:
|
||||
# Alias Name Sender Dimmer Protocol Housecode Channel
|
||||
# Alias BedroomWindow /dev/tellstick0 yes Nexa A 1
|
||||
# Alias device42 /dev/tellstick1 No Waveman B 3
|
||||
# or
|
||||
# Usage example:
|
||||
# Alias Name Sender Dimmer Protocol Channel
|
||||
# Alias MythTv_Backlight /dev/ttyUSB0 No Sartano 000000001
|
||||
#
|
||||
#
|
||||
Alias Bedroom_bed /dev/tellstick0 No Nexa G 11
|
||||
Alias Bedroom_window /dev/tellstick0 No Nexa G 10
|
||||
Alias Bedroom_mythtv_power /dev/tellstick0 No Nexa G 6
|
||||
Alias Bedroom_mythtv_leds /dev/tellstick0 No Nexa G 7
|
||||
Alias Kitchen_cabinets /dev/tellstick0 No Nexa G 2
|
||||
Alias Kitchen_window /dev/tellstick0 No Nexa G 12
|
||||
Alias Livingroom_cabinets /dev/tellstick0 No Nexa G 3
|
||||
Alias Livingroom_wall_north /dev/tellstick0 No Nexa G 4
|
||||
Alias Livingroom_wall_east /dev/tellstick0 No Nexa G 9
|
||||
Alias Livingroom_uplight /dev/tellstick0 Yes Nexa G 5
|
||||
Alias Livingroom_mythtv_leds /dev/tellstick0 No Nexa G 8
|
||||
Alias Livingroom_window /dev/tellstick0 No Nexa G 1
|
||||
Alias Study_window /dev/tellstick0 No Nexa G 13
|
||||
|
||||
|
||||
# Group aliases uses for handling a group of aliases
|
||||
#
|
||||
# Usage examples:
|
||||
# Group Name Delay List of Aliases
|
||||
# Group Livingroom_walls 60 Livingroom_wall_north Livingroom_wall_east
|
||||
# Group Kitchen 5 Kitchen_cabinets Kitchen_window
|
||||
#
|
||||
#
|
||||
Group Normal_lights 120 Bedroom_window Kitchen_cabinets Kitchen_window Livingroom_window Livingroom_wall_east Study_window
|
||||
Group Extra_lights 180 Livingroom_cabinets Livingroom_uplight Livingroom_wall_north
|
||||
Group All_lights 10 Bedroom_mythtv_leds Bedroom_window Bedroom_bed Kitchen_cabinets Kitchen_window Livingroom_cabinets Livingroom_mythtv_leds Livingroom_uplight Livingroom_wall_north Livingroom_wall_east Livingroom_window Study_window
|
||||
Group Christmas_lights 60 Bedroom_window Kitchen_window Study_window
|
||||
|
||||
|
||||
# Timer rules for reciever devices.
|
||||
#
|
||||
# Usage examples:
|
||||
# Rule Alias DeviceOn DeviceOff
|
||||
# Rule BedroomWindow Sunrise Sunrise+01:30
|
||||
# Rule BedroomWindow 18:33 23:10+Random(00:45)
|
||||
# Rule MythTv_Backlight Weekend/20:00 Weekend/Sunset
|
||||
#
|
||||
#
|
||||
Rule Normal_lights Workweek/Sunset-01:00+Random(00:50) Workweek/00:01+Random(00:50)
|
||||
Rule Normal_lights Weekend/Sunset-01:00+Random(00:50) Weekend/00:01+Random(00:50)
|
||||
|
||||
Rule Extra_lights No 00:15+Random(00:30)
|
||||
|
||||
Rule All_lights No 02:00
|
||||
Rule All_lights No 03:00
|
||||
|
||||
#Rule Bedroom_window Workweek/07:30 Workweek/08:30
|
||||
|
||||
#Rule Christmas_lights 07:00+Random(00:15) 10:00+Random(00:30)
|
||||
#Rule Christmas_lights 15:00+Random(00:30) 00:30+Random(00:15)
|
||||
|
||||
#Rule Livingroom_cabinets 18:55+Random(01:00) 21:55+Random(01:00)
|
||||
#Rule Livingroom_wall_north 19:55+Random(01:00) 20:55+Random(01:00)
|
||||
#Rule Bedroom_bed 20:55+Random(01:00) 22:55+Random(01:00)
|
||||
|
1133
3rdparty/tellstickcontroller/tellstickControllerTdtool
vendored
1133
3rdparty/tellstickcontroller/tellstickControllerTdtool
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,89 +0,0 @@
|
|||
################################################################################
|
||||
#
|
||||
# Configuration file for tellstickController
|
||||
#
|
||||
# Copyright (C) 2008-2010 Rickard Andersson (ran42ran@gmail.com)
|
||||
# Version: 2.0
|
||||
#
|
||||
################################################################################
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# List of location settings
|
||||
#
|
||||
# Usage example:
|
||||
# Set Key Value
|
||||
# Set Timezone Europe/Stockholm
|
||||
#
|
||||
#
|
||||
Set Timezone Europe/Stockholm
|
||||
Set Altitude -0.833
|
||||
Set Latitude 58.24
|
||||
Set Longitude 15.31
|
||||
|
||||
Set pidfile /var/run/tellstickController.pid
|
||||
Set logfile /var/log/tellstickController.log
|
||||
Set program /usr/bin/tdtool
|
||||
|
||||
|
||||
# Group aliases uses for handling a group of devices
|
||||
#
|
||||
# Usage examples:
|
||||
# Group Name Delay List of devices
|
||||
# Group Livingroom_walls 60 Livingroom_wall_north Livingroom_wall_east
|
||||
# Group Kitchen 5 Kitchen_cabinets Kitchen_window
|
||||
#
|
||||
#
|
||||
Group Normal_lights 120 Bedroom_window Kitchen_cabinets Kitchen_window Livingroom_window Livingroom_wall_east Study_window
|
||||
|
||||
Group Extra_lights 180 Livingroom_cabinets Livingroom_uplight Livingroom_wall_north
|
||||
|
||||
Group All_lights 10 Bedroom_mythtv_leds Bedroom_window Bedroom_bed Kitchen_cabinets Kitchen_window Livingroom_cabinets Livingroom_mythtv_leds Livingroom_uplight Livingroom_wall_north Livingroom_wall_east Livingroom_window Study_window
|
||||
|
||||
#Group Christmas_lights 60 Bedroom_window Kitchen_window Study_window
|
||||
|
||||
#Group dimmers 60 testDimmer test
|
||||
|
||||
|
||||
# Timer rules for devices
|
||||
#
|
||||
# Usage examples:
|
||||
# Rule Alias DeviceOn DeviceOff
|
||||
# Rule LivingroomWindow Sunrise Sunrise+01:30
|
||||
# Rule LivingroomWindow 18:33 23:10+Random(00:45)
|
||||
# Rule MythTv_Backlight Weekend/20:00 Weekend/Sunset
|
||||
# Rule BedroomDimmer 07:00+Dimmer(00:01,5,255,25) 08:00
|
||||
#
|
||||
#
|
||||
Rule Normal_lights Workweek/Sunset-01:00+Random(00:50) Workweek/00:01+Random(00:50)
|
||||
Rule Normal_lights Weekend/Sunset-01:00+Random(00:50) Weekend/00:01+Random(00:50)
|
||||
|
||||
Rule Extra_lights No 00:15+Random(00:30)
|
||||
|
||||
Rule All_lights No 02:00
|
||||
Rule All_lights No 03:00
|
||||
|
||||
#Rule Bedroom_window Workweek/07:30 Workweek/08:30
|
||||
|
||||
#Rule Christmas_lights 07:00+Random(00:15) 10:00+Random(00:30)
|
||||
#Rule Christmas_lights 15:00+Random(00:30) 00:30+Random(00:15)
|
||||
|
||||
#Rule Livingroom_cabinets 18:55+Random(01:00) 21:55+Random(01:00)
|
||||
#Rule Livingroom_wall_north 19:55+Random(01:00) 20:55+Random(01:00)
|
||||
#Rule Bedroom_bed 20:55+Random(01:00) 22:55+Random(01:00)
|
||||
|
||||
#Rule testDimmer 22:00+Dimmer(00:01,5,255,50) Sunrise+Dimmer(00:01,5,250,25)
|
||||
#Rule dimmers No 23:00+Dimmer(00:01,250,0,50)
|
674
3rdparty/tellstickd/LICENSE
vendored
674
3rdparty/tellstickd/LICENSE
vendored
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state 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 program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
46
3rdparty/tellstickd/README
vendored
46
3rdparty/tellstickd/README
vendored
|
@ -1,46 +0,0 @@
|
|||
General
|
||||
=================
|
||||
This software is intended for controlling remote switch devices with rfcmd.
|
||||
|
||||
Dependencies
|
||||
=================
|
||||
For this script to run you need perl and the following perl-modules:
|
||||
DateTime
|
||||
DateTime::Event::Sunrise
|
||||
|
||||
|
||||
Installation
|
||||
=================
|
||||
0. Install rfcmd and necessary perl modules (on a typical Fedora/Centos/RHEL with the necessary repos installed, this should do it for you: yum install perl-DateTime perl-DateTime-Event-Sunrise).
|
||||
|
||||
1. Copy the file tellstickd-version/tellstickd to /usr/local/bin/ (or anywhere else depending on your wishes).
|
||||
|
||||
2. Copy the file tellstickd-version/tellstickd.conf to /etc/ (or anywhere else depending on your wishes).
|
||||
|
||||
3. Copy the suitable init script found under tellstickd-version/init_script to /etc/rc.d/init.d, this way you can control the script as any other service, easily make it start at boot (with chkconfig --level 35 tellstickd on). The file init_script/tellstickd is a Redhat type script whereas init_script/tellstickd.debian not unexpectedly should work on Debian type systems.
|
||||
4. Remember to make the perl-script and init-script executable. As root chmod 755 /usr/local/bin/tellstickd /etc/rc.d/init.d/tellstickd
|
||||
|
||||
Configuration
|
||||
=================
|
||||
1. In tellstickd.conf:
|
||||
a. Set appropriate coordinates and timezone to suit your geographical location (further information: http://search.cpan.org/dist/DateTime-Event-Sunrise/lib/DateTime/Event/Sunrise.pm).
|
||||
b. Specifiy the rfcmd-binary location. Default: /usr/local/bin/rfcmd
|
||||
c. Specify the tellstick device name. Default: /dev/tellstick
|
||||
d. Specify the location of the logfile.
|
||||
e. Add device configurations. Multiple definitions for each device are possible (avoid having on and off times of multiple definitions overlapping each other).
|
||||
|
||||
2. If you would like this script to start at boot-time, on a RHEL/Centos/Fedora system, execute the following command chkconfig --level 35 tellstickd on
|
||||
|
||||
|
||||
Licensing
|
||||
=================
|
||||
This software is freely distributable under the GNU General Public License,
|
||||
the full content of the license is included in the file LICENSE.
|
||||
Bug reports are welcome, but even more appreciated are patches with the solution to the problem.
|
||||
|
||||
Authors
|
||||
=================
|
||||
Magnus Juntti
|
||||
mjuntti@gmail.com
|
||||
|
||||
Anders Betnér
|
84
3rdparty/tellstickd/init_script/tellstickd
vendored
84
3rdparty/tellstickd/init_script/tellstickd
vendored
|
@ -1,84 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Init file for tellstickd remote light switch daemon
|
||||
#
|
||||
# Written by Magnus Juntti
|
||||
#
|
||||
# chkconfig: 35 54 46
|
||||
# description: tellstickd remote light switch daemon
|
||||
#
|
||||
# processname: tellstickd
|
||||
# config: /etc/tellstickd.conf
|
||||
# pidfile: /var/run/tellstick
|
||||
|
||||
source /etc/rc.d/init.d/functions
|
||||
|
||||
EXECUTABLE="/usr/bin/tellstickd"
|
||||
CONFIG_FILE="/etc/tellstickd.conf"
|
||||
OPTIONS=""
|
||||
|
||||
[ -x $EXECUTABLE ] || exit 1
|
||||
[ -r $CONFIG_FILE ] || exit 1
|
||||
|
||||
RETVAL=0
|
||||
prog="tellstickd"
|
||||
desc="remote switch daemon"
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $desc ($prog): "
|
||||
daemon --user root $prog --daemon --config $CONFIG_FILE $OPTIONS
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Shutting down $desc ($prog): "
|
||||
killproc $prog
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo -n $"Reloading $desc ($prog): "
|
||||
killproc $prog -HUP
|
||||
RETVAL=$?
|
||||
echo
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
condrestart)
|
||||
[ -e /var/lock/subsys/$prog ] && restart
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
status $prog
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Init file for tellstickd remote light switch daemon
|
||||
#
|
||||
# Written by Magnus Juntti
|
||||
#
|
||||
# chkconfig: 35 54 46
|
||||
# description: tellstickd remote light switch daemon
|
||||
#
|
||||
# processname: tellstickd
|
||||
# config: /etc/tellstickd.conf
|
||||
# pidfile: /var/run/tellstick
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
DAEMON="/usr/local/bin/tellstickd"
|
||||
NAME="tellstickd"
|
||||
CONFIG_FILE="/etc/tellstickd.conf"
|
||||
PID_FILE="/var/run/tellstickd.pid"
|
||||
OPTIONS=""
|
||||
|
||||
[ -x $DAEMON ] || exit 1
|
||||
[ -r $CONFIG_FILE ] || exit 1
|
||||
|
||||
|
||||
RETVAL=0
|
||||
prog="tellstickd"
|
||||
desc="remote switch daemon"
|
||||
|
||||
start() {
|
||||
log_begin_msg "Starting $desc ($prog): "
|
||||
start-stop-daemon --start --quiet --pidfile "$PID_FILE" --name $NAME --exec $DAEMON -- --daemon --config $CONFIG_FILE $OPTIONS
|
||||
log_end_msg $?
|
||||
|
||||
}
|
||||
|
||||
stop() {
|
||||
log_begin_msg "Shutting down $desc ($prog): "
|
||||
start-stop-daemon --stop --quiet --pidfile "$PID_FILE" --name $NAME
|
||||
log_end_msg $?
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
restart
|
||||
# the daemon doesn't reacto to sig HUP, so just restart it
|
||||
# log_begin_msg "Reloading $desc ($prog): "
|
||||
# start-stop-daemon --stop --quiet --pidfile "$PID_FILE" --name $NAME --signal 1
|
||||
# log_end_msg $?
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|reload}"
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit 0
|
850
3rdparty/tellstickd/tellstickd
vendored
850
3rdparty/tellstickd/tellstickd
vendored
|
@ -1,850 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use POSIX;
|
||||
use DateTime;
|
||||
use DateTime::Event::Sunrise;
|
||||
use Time::Local;
|
||||
use strict;
|
||||
use sigtrap 'handler', \&daemon_exit, 'normal-signals';
|
||||
|
||||
# The following variables should be adapted to your geographical location and system setup
|
||||
my $LATITUDE = "65.603"; # 65.603N 22.18W -> Luleå, Sweden
|
||||
my $LONGITUDE = "22.18";
|
||||
my $TIMEZONE = "Europe/Stockholm";
|
||||
my $RFCMD = "/usr/local/bin/rfcmd";
|
||||
my $TELLSTICK_DEVICE = "/dev/tellstick";
|
||||
my $CONFIG_FILE = "/etc/tellstickd.conf";
|
||||
my $LOG_FILE = "/var/log/tellstickd";
|
||||
my $pidFile = '/var/run/tellstickd.pid';
|
||||
|
||||
|
||||
# You should not need to go beyond this point (unless you have found a bug or need to improve the functionality).
|
||||
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
|
||||
my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
|
||||
my $NO = 0;
|
||||
my $YES = 1;
|
||||
my @device_cfg;
|
||||
my $conf_file = "";
|
||||
my $make_daemon = $NO;
|
||||
my $simulate = $NO;
|
||||
my $n_rfcmd_calls;
|
||||
my $current_time;
|
||||
my $number_of_rules;
|
||||
my $Day;
|
||||
my $Month;
|
||||
my $Year;
|
||||
my $Minute;
|
||||
my $Hour;
|
||||
my $Second;
|
||||
my $WeekDay;
|
||||
my $DayOfYear;
|
||||
my $IsDST;
|
||||
my $daylightSavings;
|
||||
my $dayOfYear;
|
||||
my $dayOfWeek;
|
||||
my $dayOfMonth;
|
||||
|
||||
my $PROGRAM_NAME = "tellstickd";
|
||||
my $VERSION = "0.6.3";
|
||||
|
||||
# Structure of the configurations to be read;
|
||||
# $device_cfg[$i][0]; # Protocol, only NEXA, WAVEMAN and SARTANO supported so far by rfcmd
|
||||
# $device_cfg[$i][1]; # Housecode A-P
|
||||
# $device_cfg[$i][2]; # Channel 1-3
|
||||
# $device_cfg[$i][3]; # On time
|
||||
# $device_cfg[$i][4]; # Off time
|
||||
# $device_cfg[$i][5]; # Off when bright, 0 = no, 1 = yes
|
||||
# $device_cfg[$i][6]; # Off when bright delay
|
||||
# $device_cfg[$i][7]; # Time in advance when getting dark
|
||||
# $device_cfg[$i][8]; # On time random interval
|
||||
# $device_cfg[$i][9]; # Off time random interval
|
||||
# $device_cfg[$i][10]; # Rule active these days [11234567], 1=monday, ... 7=sunday.
|
||||
# $device_cfg[$i][20]; # Sunrise off time, calculated in this program and stored here
|
||||
# $device_cfg[$i][21]; # Sunset on time, calculated in this program and stored here
|
||||
# $device_cfg[$i][22]; # Switch state, 0 = off, 1 = on
|
||||
# $device_cfg[$i][23]; # Original on time
|
||||
# $device_cfg[$i][24]; # Original off time
|
||||
|
||||
sub daemonize {
|
||||
chdir '/' or die "$PROGRAM_NAME: Can't chdir to /: $!";
|
||||
open STDIN, '/dev/null' or die "$PROGRAM_NAME: Can't read /dev/null: $!";
|
||||
#open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
|
||||
#open STDERR, '>/dev/null' or die "$PROGRAM_NAME: Can't write to /dev/null: $!";
|
||||
defined(my $pid = fork) or die "$PROGRAM_NAME: Can't fork: $!";
|
||||
exit if $pid;
|
||||
setsid or die "$PROGRAM_NAME: Can't start a new session: $!";
|
||||
umask 0;
|
||||
}
|
||||
sub daemon_exit() {
|
||||
# Remove pidfile
|
||||
unlink $pidFile;
|
||||
# Since tellstickd most probably is stuck sleeping just kill ourself
|
||||
kill('TERM', $$);
|
||||
die;
|
||||
}
|
||||
sub get_sunrise_time
|
||||
{
|
||||
my $sunrise_time;
|
||||
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
|
||||
$Year += 1900;
|
||||
|
||||
# Note, localtime returns months 0..11, Datetime->new expects months 1..12.
|
||||
my $dt = DateTime->new( year => $Year, month => $Month+1, day => $Day, time_zone => $TIMEZONE, );
|
||||
my $sunrise = DateTime::Event::Sunrise ->new( longitude => $LONGITUDE, latitude => $LATITUDE, altitude => '-0.833', iteration => '1');
|
||||
|
||||
my $dt1 = $sunrise->sunrise_datetime($dt);
|
||||
|
||||
($sunrise_time) = $dt1->datetime =~ /T(.*)\:/;
|
||||
|
||||
return $sunrise_time
|
||||
}
|
||||
|
||||
sub get_sunset_time
|
||||
{
|
||||
my $sunset_time;
|
||||
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
|
||||
$Year += 1900;
|
||||
|
||||
# Note, localtime returns months 0..11, Datetime->new expects months 1..12.
|
||||
my $dt = DateTime->new( year => $Year, month => $Month+1, day => $Day, time_zone => $TIMEZONE, );
|
||||
my $sunrise = DateTime::Event::Sunrise ->new( longitude => $LONGITUDE, latitude => $LATITUDE, altitude => '-0.833', iteration => '1');
|
||||
|
||||
my $dt2 = $sunrise->sunset_datetime($dt);
|
||||
|
||||
($sunset_time) = $dt2->datetime =~ /T(.*)\:/;
|
||||
|
||||
return $sunset_time;
|
||||
}
|
||||
|
||||
# Checks if $current_time is inbetween argument 1 ($time1) and argument 2 ($time2)
|
||||
sub is_inbetween_times
|
||||
{
|
||||
my $time1 = $_[0];
|
||||
my $time2 = $_[1];
|
||||
my $curr_time = $_[2];
|
||||
|
||||
$curr_time =~ s/://g;
|
||||
$time1 =~ s/://g;
|
||||
$time2 =~ s/://g;
|
||||
$curr_time =~ s/^0*//;
|
||||
$time1 =~ s/^0*//;
|
||||
$time2 =~ s/^0*//;
|
||||
|
||||
# If we pass midnight, the following has to be checked/done
|
||||
if ($time2 <= $time1) {
|
||||
if ($curr_time >= $time1 && $curr_time < 2400 || $curr_time >= 0000 && $curr_time < $time2) {
|
||||
return $YES;
|
||||
}
|
||||
}
|
||||
# The following applies to the most common rules within a day.
|
||||
else {
|
||||
if ($curr_time >= $time1 && $curr_time < $time2) {
|
||||
return $YES;
|
||||
}
|
||||
}
|
||||
|
||||
return $NO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub rfcmd_exec {
|
||||
my $device_id = $_[0];
|
||||
my $action = $_[1];
|
||||
my $RFCMD_OPTIONS;
|
||||
|
||||
if ($device_cfg[$device_id][0] eq "SARTANO") {
|
||||
$RFCMD_OPTIONS = "$TELLSTICK_DEVICE $device_cfg[$device_id][0] $device_cfg[$device_id][1]";
|
||||
}
|
||||
elsif ($device_cfg[$device_id][0] eq "NEXA" || $device_cfg[$device_id][0] eq "WAVEMAN") {
|
||||
$RFCMD_OPTIONS = "$TELLSTICK_DEVICE $device_cfg[$device_id][0] $device_cfg[$device_id][1] $device_cfg[$device_id][2]";
|
||||
}
|
||||
else {
|
||||
die("$PROGRAM_NAME: Device $device_id has an unknown protocol. Only NEXA, WAVEMAN and SARTANO allowed.\n");
|
||||
}
|
||||
|
||||
|
||||
# Action = 1 means turn device on, 0 turn device off
|
||||
if ($action == 1) {
|
||||
# Only turn the device on if it is not already turned on to avoid flashing dimmers.
|
||||
# and check that it is not disabled by on/off time set to -1 in the config file
|
||||
if ($device_cfg[$device_id][22] == 0 && $device_cfg[$device_id][23] != -1) {
|
||||
printf("$PROGRAM_NAME: Time is $current_time. Switching on $device_cfg[$device_id][0] device $device_cfg[$device_id][1]$device_cfg[$device_id][2].\n");
|
||||
if ($simulate == $NO) {
|
||||
`$RFCMD $RFCMD_OPTIONS 1`;
|
||||
}
|
||||
$device_cfg[$device_id][22] = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
elsif ($action == 0) {
|
||||
if ($device_cfg[$device_id][22] == 1 && $device_cfg[$device_id][24] != -1) {
|
||||
printf("$PROGRAM_NAME: Time is $current_time. Switching off $device_cfg[$device_id][0] device $device_cfg[$device_id][1]$device_cfg[$device_id][2].\n");
|
||||
if ($simulate == $NO) {
|
||||
`$RFCMD $RFCMD_OPTIONS 0`;
|
||||
}
|
||||
$device_cfg[$device_id][22] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
# Time format xx:yy for input parameters argument1 has to be positive, argument2 can be positive or negative
|
||||
sub add_time
|
||||
{
|
||||
my $time1 = $_[0];
|
||||
my $time2 = $_[1];
|
||||
my $multiplier = 1;
|
||||
my $hour;
|
||||
my $min;
|
||||
my $time1_hour;
|
||||
my $time1_minute;
|
||||
my $time2_hour;
|
||||
my $time2_minute;
|
||||
my $time1_epoch_seconds;
|
||||
my $time2_offset_seconds;
|
||||
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
|
||||
$Year += 1900;
|
||||
|
||||
(my $sign) = $time2 =~ /^(.*?)[0-9]/;
|
||||
($time1_hour, $time1_minute) = $time1 =~ /(.*)\:(.*)/;
|
||||
# Remove any leading signs
|
||||
$time2 =~ s/^-?//g;
|
||||
($time2_hour, $time2_minute) = $time2 =~ /(.*)\:(.*)/;
|
||||
|
||||
if ($sign eq "-") {
|
||||
$multiplier = -1;
|
||||
}
|
||||
|
||||
$time1_epoch_seconds = timelocal(0,$time1_minute,$time1_hour, $Day, $Month, $Year);
|
||||
$time2_offset_seconds = 3600*$time2_hour + 60*$time2_minute;
|
||||
|
||||
my $result_seconds = $time1_epoch_seconds + $multiplier*$time2_offset_seconds;
|
||||
|
||||
($min,$hour)= (localtime($result_seconds))[1,2];
|
||||
|
||||
return sprintf("%02d:%02d", $hour, $min);
|
||||
}
|
||||
|
||||
# Time format xx:yy for input parameters
|
||||
sub subtract_time
|
||||
{
|
||||
my $time1 = $_[0];
|
||||
my $time2 = $_[1];
|
||||
my $multiplier = 1;
|
||||
my $hour;
|
||||
my $min;
|
||||
my $time1_hour;
|
||||
my $time1_minute;
|
||||
my $time2_hour;
|
||||
my $time2_minute;
|
||||
my $time1_epoch_seconds;
|
||||
my $time2_offset_seconds;
|
||||
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
|
||||
$Year += 1900;
|
||||
|
||||
(my $sign) = $time2 =~ /^(.*?)[0-9]/;
|
||||
($time1_hour, $time1_minute) = $time1 =~ /(.*)\:(.*)/;
|
||||
# Remove any leading signs
|
||||
$time2 =~ s/^-?//g;
|
||||
($time2_hour, $time2_minute) = $time2 =~ /(.*)\:(.*)/;
|
||||
|
||||
if ($sign eq "-") {
|
||||
$multiplier = -1;
|
||||
}
|
||||
|
||||
$time1_epoch_seconds = timelocal(0,$time1_minute,$time1_hour, $Day, $Month, $Year);
|
||||
$time2_offset_seconds = 3600*$time2_hour + 60*$time2_minute;
|
||||
|
||||
my $result_seconds = $time1_epoch_seconds - $multiplier*$time2_offset_seconds;
|
||||
|
||||
($min,$hour)= (localtime($result_seconds))[1,2];
|
||||
|
||||
return sprintf("%02d:%02d", $hour, $min);
|
||||
}
|
||||
|
||||
sub randomize_on
|
||||
{
|
||||
my $device_id = $_[0];
|
||||
|
||||
# If the on- and off times are the same, just return
|
||||
if ($device_cfg[$device_id][23] eq $device_cfg[$device_id][24]) {
|
||||
return;
|
||||
}
|
||||
|
||||
(my $random_hour, my $random_minute) = $device_cfg[$device_id][8] =~ /(.*)\:(.*)/;
|
||||
|
||||
my $rand_res = int(rand(60 * $random_hour + $random_minute));
|
||||
|
||||
my $rand_res_hour = floor($rand_res / 60);
|
||||
my $rand_res_minute = $rand_res - 60*$rand_res_hour;
|
||||
|
||||
# Here we have the random offset in format xx:yy
|
||||
my $random_time = sprintf("%02d:%02d", $rand_res_hour, $rand_res_minute);
|
||||
|
||||
$device_cfg[$device_id][3] = add_time($device_cfg[$device_id][23], $random_time);
|
||||
|
||||
if (is_inbetween_times($device_cfg[$device_id][23], $device_cfg[$device_id][24], $device_cfg[$device_id][3]) == $NO) {
|
||||
randomize_on($device_id);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sub randomize_off
|
||||
{
|
||||
my $device_id = $_[0];
|
||||
|
||||
# If the on- and off times are the same, just return
|
||||
if ($device_cfg[$device_id][23] eq $device_cfg[$device_id][24]) {
|
||||
return;
|
||||
}
|
||||
|
||||
(my $random_hour, my $random_minute) = $device_cfg[$device_id][9] =~ /(.*)\:(.*)/;
|
||||
|
||||
my $rand_res = int(rand(60 * $random_hour + $random_minute));
|
||||
|
||||
my $rand_res_hour = floor($rand_res / 60);
|
||||
my $rand_res_minute = $rand_res - 60*$rand_res_hour;
|
||||
|
||||
# Here we have the random offset in format xx:yy
|
||||
my $random_time = sprintf("%02d:%02d", $rand_res_hour, $rand_res_minute);
|
||||
|
||||
$device_cfg[$device_id][4] = add_time($device_cfg[$device_id][24], $random_time);
|
||||
|
||||
if (is_inbetween_times($device_cfg[$device_id][23], $device_cfg[$device_id][24], $device_cfg[$device_id][4]) == $YES) {
|
||||
randomize_off($device_id);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
# Time format sanity check routine
|
||||
sub is_time_format_correct
|
||||
{
|
||||
my $time = $_[0];
|
||||
(my $hour, my $minute) = $time =~ /^-?(\d\d)\:(\d\d)$/;
|
||||
|
||||
if ($hour && $minute) {
|
||||
if ($hour >= 0 && $hour <= 23 && $minute >= 0 && $minute <= 59) {
|
||||
return $YES;
|
||||
}
|
||||
}
|
||||
|
||||
return $NO;
|
||||
}
|
||||
|
||||
|
||||
# Time format sanity check routine
|
||||
sub is_rule_valid_today
|
||||
{
|
||||
my $device_id = $_[0];
|
||||
my $now = $_[1];
|
||||
my $rule = $device_cfg[$device_id][10];
|
||||
|
||||
(my $week_rule) = $rule =~/^([e|o])/;
|
||||
if ($week_rule) {
|
||||
my $is_odd_week = ($now->week_number % 2);
|
||||
if (($is_odd_week && ($week_rule eq "e")) ||
|
||||
(!$is_odd_week && ($week_rule eq "o"))) {
|
||||
return $NO;
|
||||
}
|
||||
}
|
||||
my $day_of_week = $now->day_of_week;
|
||||
if ($rule =~ /$day_of_week/) {
|
||||
return $YES;
|
||||
}
|
||||
|
||||
return $NO;
|
||||
}
|
||||
|
||||
# Ugly hack, but we have to get the log_file option from the config file
|
||||
# before parsing the config file
|
||||
sub get_config_log_file_param
|
||||
{
|
||||
my $input_file = $_[0];
|
||||
open(CFG_FILE, "<$input_file") or die "$PROGRAM_NAME: Could not access config file: $conf_file\n";
|
||||
|
||||
while ($_ = <CFG_FILE>) {
|
||||
chomp($_);
|
||||
(my $value) = $_ =~ /^log_file\s*=\s*([a-zA-Z0-9_\/\.]*)/;
|
||||
if ($value) {
|
||||
close(CFG_FILE);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
close(CFG_FILE);
|
||||
return $NO;
|
||||
}
|
||||
|
||||
sub read_config
|
||||
{
|
||||
my $input_file = $_[0];
|
||||
my @inrad;
|
||||
my $on_interval_end;
|
||||
my $off_interval_end;
|
||||
|
||||
printf("$PROGRAM_NAME: Reading configuration file $conf_file...\n");
|
||||
|
||||
open(CFG_FILE, "<$input_file") or die "$PROGRAM_NAME: Could not access config file: $conf_file\n";
|
||||
|
||||
my $i = 0;
|
||||
my $conf_row = 0;
|
||||
while ($_ = <CFG_FILE>) {
|
||||
$conf_row++;
|
||||
if ($_ =~ /^[\#|\s|\n]/) {
|
||||
# skip lines beginning with # or space or just a new line
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if ($_ =~ /^[NEXA|WAVEMAN|SARTANO]/ ) {
|
||||
chomp($_);
|
||||
|
||||
@inrad = split /\s+/, $_;
|
||||
$device_cfg[$i][0] = $inrad[0]; # Protocol
|
||||
$device_cfg[$i][1] = $inrad[1]; # Housecode A and channel for NEXA, WAVEMAN, channel for SARTANO.
|
||||
$device_cfg[$i][10] = $inrad[2]; # Rule valid days [[oe]1234567]
|
||||
$device_cfg[$i][22] = 1; # Initial state set to on (1) so that they will be switched off at startup
|
||||
|
||||
|
||||
if ($device_cfg[$i][0] eq "SARTANO") {
|
||||
$device_cfg[$i][2] = "";
|
||||
}
|
||||
elsif ($device_cfg[$i][0] eq "NEXA" || $device_cfg[$i][0] eq "WAVEMAN") {
|
||||
# Put the housecode and channel in the respective fields.
|
||||
(my $house_code,my $channel) = $device_cfg[$i][1] =~ /^([A-P])(\d{1,2})$/;
|
||||
if (!$house_code || !$channel || ($channel < 1) || ($channel > 16)) {
|
||||
die("$PROGRAM_NAME: Housecode/channel out of range error on row $conf_row in configuration file.\n");
|
||||
}
|
||||
$device_cfg[$i][1] = $house_code;
|
||||
$device_cfg[$i][2] = $channel;
|
||||
}
|
||||
else {
|
||||
die("$PROGRAM_NAME: Unsupported protcol: $device_cfg[$i][0]. Only NEXA, WAVEMAN or SARTANO allowed.\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Lets find the on interval and put it into the proper fields, $device_cfg[$i][3]=On time, $device_cfg[$i][8] = On time random interval
|
||||
|
||||
if ($inrad[3] =~ /-/) {
|
||||
($device_cfg[$i][3], $on_interval_end) = $inrad[3] =~ /^(\d?\d:\d\d)-(\d?\d:\d\d)$/;
|
||||
}
|
||||
else {
|
||||
($device_cfg[$i][3]) = $inrad[3] =~ /^(\d?\d:\d\d)$/;
|
||||
$on_interval_end = $device_cfg[$i][3];
|
||||
}
|
||||
|
||||
$device_cfg[$i][8] = subtract_time($on_interval_end, $device_cfg[$i][3]);
|
||||
|
||||
|
||||
|
||||
# Off time = $device_cfg[$i][4], Off time random interval = $device_cfg[$i][9]
|
||||
if ($inrad[4] =~ /-/) {
|
||||
($device_cfg[$i][4], $off_interval_end) = $inrad[4] =~ /^(\d?\d:\d\d)-(\d?\d:\d\d)$/;
|
||||
}
|
||||
else {
|
||||
($device_cfg[$i][4]) = $inrad[4] =~ /^(\d?\d:\d\d)$/;
|
||||
$off_interval_end = $device_cfg[$i][4];
|
||||
}
|
||||
|
||||
$device_cfg[$i][9] = subtract_time($off_interval_end, $device_cfg[$i][4]);
|
||||
|
||||
|
||||
|
||||
# Save the original on and off
|
||||
$device_cfg[$i][23] = $device_cfg[$i][3]; # Original on time is stored here pos 3 will be used for random on times
|
||||
$device_cfg[$i][24] = $device_cfg[$i][4]; # Original off time is stored here pos 4 will be used for random off times
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# $inrad[5] is the off post sunrise value including sign, $inrad[6] is the on pre sunrise value sign,
|
||||
if (length($inrad[5]) > 0 && length($inrad[6]) > 0) {
|
||||
# Found a parameter after off interval, assuming daytime switch off is sought.
|
||||
$device_cfg[$i][5] = 1;
|
||||
|
||||
|
||||
# First the off post sunrise
|
||||
(my $sign, my $minutes) = $inrad[5] =~ /^([-\+]?)(.*?)$/;
|
||||
|
||||
if ($sign eq "+") {
|
||||
$sign = "";
|
||||
}
|
||||
|
||||
(my $hours) = floor($minutes / 60);
|
||||
$minutes = $minutes - $hours * 60;
|
||||
|
||||
$device_cfg[$i][6] = sprintf("%s%02d:%02d", $sign, $hours, $minutes);
|
||||
|
||||
# Then figure on pre sunset out
|
||||
(my $sign, my $minutes) = $inrad[6] =~ /^([-\+]?)(.*?)$/;
|
||||
|
||||
if ($sign eq "+") {
|
||||
$sign = "";
|
||||
}
|
||||
|
||||
(my $hours) = floor($minutes / 60);
|
||||
$minutes = $minutes - $hours * 60;
|
||||
|
||||
$device_cfg[$i][7] = sprintf("%s%02d:%02d", $sign, $hours, $minutes);
|
||||
}
|
||||
else {
|
||||
# If no parameters given after off interval it is assumed that the light will be on daytime
|
||||
$device_cfg[$i][5] = 0;
|
||||
$device_cfg[$i][6] = "00:00";
|
||||
$device_cfg[$i][7] = "00:00";
|
||||
}
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Some sanity checks
|
||||
# If the turn on time is not to be used, this is marked with -1
|
||||
if ($device_cfg[$i][3] != -1) {
|
||||
if (is_time_format_correct($device_cfg[$i][3]) == $NO) {
|
||||
die("$PROGRAM_NAME: Format of turn on time for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] not correct: $device_cfg[$i][3]\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("$PROGRAM_NAME: Noted configuration for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] with no turn on time.\n");
|
||||
}
|
||||
|
||||
# If the turn off time is not to be used, this is marked with -1
|
||||
if ($device_cfg[$i][4] != -1) {
|
||||
if (is_time_format_correct($device_cfg[$i][4]) == $NO) {
|
||||
die("$PROGRAM_NAME: Format of turn off time for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] not correct: $device_cfg[$i][4]\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("$PROGRAM_NAME: Noted configuration for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] with no turn off time.\n");
|
||||
}
|
||||
|
||||
if (is_time_format_correct($device_cfg[$i][6]) == $NO) {
|
||||
die("$PROGRAM_NAME: Format of turn off after sunrise for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] not correct: $device_cfg[$i][6]\n");
|
||||
}
|
||||
|
||||
if (is_time_format_correct($device_cfg[$i][7]) == $NO) {
|
||||
die("$PROGRAM_NAME: Format of turn on before sunset for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] not correct. Exiting.\n");
|
||||
}
|
||||
|
||||
if (is_time_format_correct($device_cfg[$i][8]) == $NO) {
|
||||
die("$PROGRAM_NAME: Format of on interval for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] not correct: $device_cfg[$i][8]\n");
|
||||
}
|
||||
|
||||
if (is_time_format_correct($device_cfg[$i][9]) == $NO) {
|
||||
die("$PROGRAM_NAME: Format of off interval for device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] not correct: $device_cfg[$i][9]\n");
|
||||
}
|
||||
|
||||
if ($device_cfg[$i][10] =~ /^[o|e][^1-7]/) {
|
||||
die("$PROGRAM_NAME: Device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2]: Specified rule validity day out of range: $device_cfg[$i][10]\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("$PROGRAM_NAME: $device_cfg[$i][0] device $device_cfg[$i][1]$device_cfg[$i][2] config:\n");
|
||||
|
||||
printf(" This rule is valid: ");
|
||||
for (my $j = 1 ; $j <= 7 ; $j++) {
|
||||
if ($device_cfg[$i][10] =~ /$j/) {
|
||||
printf(" $weekDays[$j]");
|
||||
}
|
||||
}
|
||||
if ($device_cfg[$i][10] =~ /o/) {
|
||||
printf(" (odd weeks)");
|
||||
}
|
||||
if ($device_cfg[$i][10] =~ /e/) {
|
||||
printf(" (even weeks)");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if ($device_cfg[$i][3] == -1) {
|
||||
printf(" On time: N/A\n");
|
||||
}
|
||||
else {
|
||||
printf(" On time: $device_cfg[$i][3]\n");
|
||||
}
|
||||
|
||||
if ($device_cfg[$i][4] == -1) {
|
||||
printf(" Off time: N/A\n");
|
||||
}
|
||||
else {
|
||||
printf(" Off time: $device_cfg[$i][4]\n");
|
||||
}
|
||||
|
||||
printf(" On time random interval: $device_cfg[$i][8]\n");
|
||||
printf(" Off time random interval: $device_cfg[$i][9]\n");
|
||||
|
||||
if ($device_cfg[$i][5] == $YES) {
|
||||
printf(" Turned off daytime: yes\n");
|
||||
printf(" Off post sunrise: $device_cfg[$i][6]\n");
|
||||
printf(" On pre sunset: $device_cfg[$i][7]\n");
|
||||
}
|
||||
else {
|
||||
printf(" Turned off daytime: no\n");
|
||||
}
|
||||
|
||||
$i++;
|
||||
next;
|
||||
}
|
||||
# Try to get config parameter name and value
|
||||
(my $param, my $value) = $_ =~ /\s*(\w+)\s*=\s*(-?[a-zA-Z0-9_\/\.]*)/;
|
||||
if ($param && $value) {
|
||||
printf("$PROGRAM_NAME: $param = $value\n");
|
||||
if ($param eq 'latitude') {
|
||||
if ($value !~ /^-?[0-9\.]*$/) {
|
||||
die ("$PROGRAM_NAME: Latitude must be a valid number\n");
|
||||
}
|
||||
if ($value < -90 || $value > 90) {
|
||||
die ("$PROGRAM_NAME: Latitude must be between -90 and 90 degrees\n");
|
||||
}
|
||||
$LATITUDE = $value;
|
||||
next;
|
||||
}
|
||||
if ($param eq 'longitude') {
|
||||
if ($value !~ /^-?[0-9\.]*$/) {
|
||||
die ("$PROGRAM_NAME: Longitude must be a valid number\n");
|
||||
}
|
||||
if ($value < -90 || $value > 90) {
|
||||
die ("$PROGRAM_NAME: Longitude must be between -180 and 180 degrees\n");
|
||||
}
|
||||
$LONGITUDE = $value;
|
||||
next;
|
||||
}
|
||||
if ($param eq 'timezone') {
|
||||
if (!DateTime::TimeZone->is_valid_name($value)) {
|
||||
die ("$PROGRAM_NAME: Invalid timezone\n");
|
||||
}
|
||||
$TIMEZONE = $value;
|
||||
next;
|
||||
}
|
||||
if ($param eq 'rfcmd') {
|
||||
$RFCMD = $value;
|
||||
next;
|
||||
}
|
||||
if ($param eq 'tellstick_device') {
|
||||
$TELLSTICK_DEVICE = $value;
|
||||
next;
|
||||
}
|
||||
if ($param eq 'log_file') {
|
||||
$LOG_FILE = $value;
|
||||
next;
|
||||
}
|
||||
if ($param eq 'pid_file') {
|
||||
$pidFile = $value;
|
||||
next;
|
||||
}
|
||||
die ("$PROGRAM_NAME: Unknown config parameter $param = $value\n");
|
||||
}
|
||||
else {
|
||||
die("$PROGRAM_NAME: Unknown config file line $_\n");
|
||||
}
|
||||
}
|
||||
close(CFG_FILE);
|
||||
return $i;
|
||||
}
|
||||
|
||||
sub usageprompt
|
||||
{
|
||||
printf("This program is intended for control of Tellstick remote devices.\n");
|
||||
printf("Version: %s\n", $VERSION);
|
||||
|
||||
printf("\nUsage: %s [options]\n", $PROGRAM_NAME);
|
||||
printf("\nOptions:\n");
|
||||
printf("-c, --config filename Searchpath to configuration file, if not given $CONFIG_FILE is assumed.\n");
|
||||
printf("-d, --daemon Run the program as a daemon and write a logfile.\n");
|
||||
printf("-h, --help Show this message and exit.\n");
|
||||
printf("--simulate Run in foreground, log to console, no actual device operations performed.\n");
|
||||
}
|
||||
|
||||
|
||||
# ############## Main section ######################
|
||||
my $i = -1;
|
||||
|
||||
while ($i < $#ARGV) {
|
||||
if ($i+1 <= $#ARGV) {
|
||||
if ($ARGV[$i+1] =~ /^--config$/ || $ARGV[$i+1] =~ /^-c$/) {
|
||||
$i++;
|
||||
$conf_file = $ARGV[$i+1];
|
||||
}
|
||||
elsif ($ARGV[$i+1] =~ /^-d$/ || $ARGV[$i+1] =~ /^--daemon$/) {
|
||||
$make_daemon = $YES;
|
||||
}
|
||||
elsif ($ARGV[$i+1] =~ /^-h$/ || $ARGV[$i+1] =~ /^--help$/) {
|
||||
usageprompt();
|
||||
exit;
|
||||
}
|
||||
elsif ($ARGV[$i+1] =~ /--simulate/) {
|
||||
$simulate = $YES;
|
||||
}
|
||||
else {
|
||||
die("$PROGRAM_NAME: Unknown input argument: $ARGV[$i+1]\n");
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($#ARGV < 0) {
|
||||
die "Try \"$PROGRAM_NAME --help\" for more information.\n";
|
||||
}
|
||||
|
||||
|
||||
if (length($conf_file) < 1) {
|
||||
$conf_file = $CONFIG_FILE;
|
||||
}
|
||||
$LOG_FILE = get_config_log_file_param($conf_file);
|
||||
|
||||
if ($LOG_FILE && $make_daemon && !$simulate) {
|
||||
open STDOUT, "> $LOG_FILE" or die "$PROGRAM_NAME: Can't write to $LOG_FILE: $!";
|
||||
open STDERR, ">> $LOG_FILE" or die "$PROGRAM_NAME: Can't write to $LOG_FILE: $!";
|
||||
}
|
||||
if (!$LOG_FILE && $make_daemon) {
|
||||
# start a daemon without a log file
|
||||
open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
|
||||
open STDERR, '>/dev/null' or die "$PROGRAM_NAME: Can't write to /dev/null: $!";
|
||||
}
|
||||
# Read the configuration file
|
||||
$number_of_rules = read_config($conf_file);
|
||||
|
||||
if ($number_of_rules < 1) {
|
||||
die("$PROGRAM_NAME: Configuration file has no devices to control, exiting.\n");
|
||||
}
|
||||
else {
|
||||
printf("\n$PROGRAM_NAME: $number_of_rules rule(s) has been read.\n\n");
|
||||
}
|
||||
|
||||
if ($make_daemon == $YES && $simulate == $NO) {
|
||||
&daemonize();
|
||||
open PIDFILE, ">$pidFile" or die "$PROGRAM_NAME: Can't open $pidFile: $!\n";
|
||||
print PIDFILE $$ . "\n";
|
||||
close PIDFILE;
|
||||
}
|
||||
|
||||
|
||||
printf("$PROGRAM_NAME: Starting $PROGRAM_NAME version $VERSION\n");
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Now to the eternal loop
|
||||
my $first_loop = $YES;
|
||||
my $now;
|
||||
while (1) {
|
||||
$n_rfcmd_calls = 0;
|
||||
|
||||
# What is the current time
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime();
|
||||
$Year += 1900;
|
||||
$current_time = sprintf("%02d:%02d", $Hour, $Minute);
|
||||
$now = DateTime->now( time_zone => $TIMEZONE);
|
||||
|
||||
###################################################################################################
|
||||
|
||||
# First, lets set the sunrise and sunset times for the devices that it applies to, once a day, at 00:00.
|
||||
if ($first_loop == $YES || $current_time eq "00:00") {
|
||||
my $sunrise_time = get_sunrise_time();
|
||||
printf("$PROGRAM_NAME: Recalculating sunrise/sunset. Current date: %d-%02d-%02d\n", $Year, $Month + 1, $Day);
|
||||
printf("$PROGRAM_NAME: Time is $current_time. Sunrise today is expected at $sunrise_time\n");
|
||||
|
||||
my $sunset_time = get_sunset_time();
|
||||
printf("$PROGRAM_NAME: Time is $current_time. Sunset today is expected at $sunset_time\n\n");
|
||||
|
||||
for (my $i = 0; $i < $number_of_rules; $i++) {
|
||||
# Initially all devices are switched off to get a known state
|
||||
if ($first_loop == $YES) {
|
||||
rfcmd_exec($i, 0);
|
||||
}
|
||||
|
||||
# Lets set the actual on- and offtimes depending on random interval settings.
|
||||
randomize_on($i);
|
||||
if (is_rule_valid_today($i, $now) == $YES) {
|
||||
printf("$PROGRAM_NAME: Today device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] will be turned on $device_cfg[$i][3]\n");
|
||||
}
|
||||
randomize_off($i);
|
||||
if (is_rule_valid_today($i, $now) == $YES) {
|
||||
printf("$PROGRAM_NAME: Today device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] will be turned off $device_cfg[$i][4]\n");
|
||||
}
|
||||
|
||||
# If the device is supposed to be off daytime, the following applies
|
||||
# Sunrise time + requested offset
|
||||
if ($device_cfg[$i][5] == $YES) {
|
||||
$device_cfg[$i][20] = add_time($sunrise_time, $device_cfg[$i][6]);
|
||||
if (is_rule_valid_today($i, $now) == $YES) {
|
||||
printf("$PROGRAM_NAME: Device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] sunrise off time set to $device_cfg[$i][20].\n");
|
||||
}
|
||||
# Sunset time - requested offset
|
||||
$device_cfg[$i][21] = subtract_time($sunset_time, $device_cfg[$i][7]);
|
||||
if (is_rule_valid_today($i, $now) == $YES) {
|
||||
printf("$PROGRAM_NAME: Device $device_cfg[$i][0] $device_cfg[$i][1]$device_cfg[$i][2] sunset on time set to $device_cfg[$i][21].\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
###################################################################################################
|
||||
|
||||
# Below the required actions are performed for each device
|
||||
for ($i = 0; $i < $number_of_rules; $i++) {
|
||||
|
||||
|
||||
# Lets check if the rule is to be applied today
|
||||
if (is_rule_valid_today($i, $now) == $YES) {
|
||||
|
||||
|
||||
|
||||
# First if we consider daytime off
|
||||
if ($device_cfg[$i][5] == $YES) {
|
||||
if (is_inbetween_times($device_cfg[$i][3], $device_cfg[$i][4], $current_time) == $YES && is_inbetween_times($device_cfg[$i][20], $device_cfg[$i][21], $current_time) == $NO) {
|
||||
rfcmd_exec($i, 1);
|
||||
$n_rfcmd_calls++;
|
||||
}
|
||||
else {
|
||||
rfcmd_exec($i, 0);
|
||||
$n_rfcmd_calls++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Then if daytime off is not considered
|
||||
else {
|
||||
if (is_inbetween_times($device_cfg[$i][3], $device_cfg[$i][4], $current_time) == $YES) {
|
||||
rfcmd_exec($i, 1);
|
||||
$n_rfcmd_calls++;
|
||||
}
|
||||
else {
|
||||
rfcmd_exec($i, 0);
|
||||
$n_rfcmd_calls++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$first_loop = $NO;
|
||||
|
||||
if ($n_rfcmd_calls < 30) {
|
||||
sleep(60 - 2*$n_rfcmd_calls); # Wait a while until next round [seconds]. If rfcmd has been called, reduce this figure by 2 seconds per call.
|
||||
}
|
||||
}
|
60
3rdparty/tellstickd/tellstickd.conf
vendored
60
3rdparty/tellstickd/tellstickd.conf
vendored
|
@ -1,60 +0,0 @@
|
|||
# Tellstickd file for control of remote switches with rfcmd.
|
||||
|
||||
# To be able to calculate sunrise and sunset times tellstickd needs to know your position
|
||||
# Your latitude
|
||||
latitude = 65.603
|
||||
|
||||
# Your longitude
|
||||
longitude = 22.18
|
||||
|
||||
# Your timezone
|
||||
timezone = Europe/Stockholm
|
||||
|
||||
# Where to find the rfcmd command
|
||||
rfcmd = /usr/local/bin/rfcmd
|
||||
|
||||
# The tellstick device name
|
||||
tellstick_device = /dev/tellstick
|
||||
|
||||
# Where to put the log file
|
||||
log_file = /var/log/tellstickd
|
||||
|
||||
# Where to put the pid file
|
||||
pid_file = /var/run/tellstickd.pid
|
||||
|
||||
#
|
||||
#<protocol> <housecode/channel> <valid day(s)> <on time[-end random on time]> <off time[-end random off time]> <off after sunrise in minutes> <on before sunset in minutes>
|
||||
#
|
||||
# In valid day field, days are numbered 1=Monday, 2=Tuesday, ... , 7=Sunday. I.e. 1234567 means that the rule should be active every weekday.
|
||||
# The day fields can be prefixed with "o" or "e" making the rule valid on odd or even weeks. Week numbers are
|
||||
# calculated according to ISO, with the first week of the year being the one containing 4 jan
|
||||
|
||||
# Time format xx:yy where xx is hour and yy is minute
|
||||
# Multiple definitions are possible for each device. Be aware that overlapping rules (overlapping in time) can/will cause troubles.
|
||||
#
|
||||
# Setting <on time> and <off time> the same means that the device will always be switched on.
|
||||
#
|
||||
|
||||
# Sample rules
|
||||
|
||||
|
||||
# The sample rule below will turn on the device between 06:10 and 06:20 and off between 22:00 and 23:00 monday to friday.
|
||||
# The device will be turned off daytime 10 minutes after sunrise and 15 before sunset
|
||||
SARTANO 0000000000 12345 06:10-06:20 22:00-23:00 10 15
|
||||
|
||||
# This device will be turned on between 07:34 and 07:48, turned off between 23:00 and 23:15 (every day of the week).
|
||||
# It will be turned off exactly on sunrise and off exactly on sunset.
|
||||
WAVEMAN P2 1234567 07:34-07:48 23:00-23:15 0 0
|
||||
|
||||
# This device will be turned on 07:00 off between 20:00 and 20:30 and will be on daytime on sundays.
|
||||
NEXA P3 7 07:00 20:00-20:30
|
||||
|
||||
# This device will be turned on 07:00 and off 20:00 on fridays and sundays on evenly numbered weeks
|
||||
NEXA P3 e57 07:00 20:00
|
||||
|
||||
# This device will be turned on 07:00 and off 20:00 on fridays and sundays on oddly numbered weeks
|
||||
NEXA P3 o57 07:00 20:00
|
||||
|
||||
|
||||
|
||||
|
|
@ -2,6 +2,6 @@ telldus-core has been developed by :
|
|||
|
||||
Micke Prag <micke.prag@telldus.se>
|
||||
Fredrik Jacobsson <fredrik.jacobsson@telldus.se>
|
||||
Stefan Persson <stefan.persson@telldus.se>
|
||||
Stefan Persson
|
||||
|
||||
The package is maintained by Micke Prag <micke.prag@telldus.se>
|
60
CMakeLists.txt
Normal file
60
CMakeLists.txt
Normal file
|
@ -0,0 +1,60 @@
|
|||
PROJECT( telldus-core )
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.6.0 )
|
||||
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
|
||||
SET(PACKAGE_VERSION 2.0.2)
|
||||
SET(PACKAGE_SUBVERSION)
|
||||
SET(PACKAGE_SOVERSION 2)
|
||||
|
||||
IF (PACKAGE_SUBVERSION)
|
||||
SET(DISPLAYED_VERSION "${PACKAGE_VERSION}_${PACKAGE_SUBVERSION}")
|
||||
ELSE (PACKAGE_SUBVERSION)
|
||||
SET(DISPLAYED_VERSION ${PACKAGE_VERSION})
|
||||
ENDIF(PACKAGE_SUBVERSION)
|
||||
|
||||
SET(BUILD_LIBTELLDUS-CORE TRUE CACHE BOOL "Build libtelldus-core")
|
||||
SET(SUPPORT_TELLSTICK_DUO FALSE CACHE BOOL "Include support for TellStick Duo")
|
||||
IF (UNIX)
|
||||
SET(SUPPORT_USB FALSE CACHE BOOL "Build support for usb-devices")
|
||||
ELSE (UNIX)
|
||||
SET(SUPPORT_USB TRUE CACHE BOOL "Build support for usb-devices")
|
||||
ENDIF(UNIX)
|
||||
SET(USE_QT_SETTINGS_BACKEND FALSE CACHE BOOL "Use QT as settings backend instead of the native one")
|
||||
|
||||
SET(BUILD_RFCMD TRUE CACHE BOOL "Build rfcmd")
|
||||
SET(BUILD_RFCMD_WITH_LIBFTDI FALSE CACHE BOOL "Enable support for using rfcmd with libftdi (does not need kernel-driver)")
|
||||
SET(BUILD_TDTOOL TRUE CACHE BOOL "Build tdtool")
|
||||
|
||||
SET(GENERATE_MAN FALSE CACHE BOOL "Enable generation of man-files")
|
||||
SET(BRANDING "telldus" CACHE STRING "The brand to use")
|
||||
|
||||
ADD_SUBDIRECTORY(driver)
|
||||
|
||||
if(BUILD_TDTOOL)
|
||||
ADD_SUBDIRECTORY(tdtool)
|
||||
endif(BUILD_TDTOOL)
|
||||
|
||||
if(BUILD_RFCMD)
|
||||
ADD_SUBDIRECTORY(rfcmd)
|
||||
endif(BUILD_RFCMD)
|
||||
|
||||
########## CPack #############
|
||||
SET(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
|
||||
SET(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}${PACKAGE_SUBVERSION}")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
SET(CPACK_PACKAGE_CONTACT "Micke Prag <micke.prag@telldus.se>")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Utilities for a Telldus TellStick")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION "Utilities and driver to control NEXA and other RF remote receivers through a TellStick USB interface")
|
||||
SET(CPACK_PACKAGE_VENDOR "Telldus Technologies AB")
|
||||
SET(CPACK_STRIP_FILES "usr/bin/tdtool;usr/bin/rfcmd")
|
||||
# SET(CPACK_PACKAGE_INSTALL_DIRECTORY "")
|
||||
# SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
#### .deb ####
|
||||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.7-1), libconfuse0 (>=2.6-2), udev")
|
||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "utils")
|
||||
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm")
|
||||
|
||||
INCLUDE(CPack)
|
10
ChangeLog
Normal file
10
ChangeLog
Normal file
|
@ -0,0 +1,10 @@
|
|||
telldus-core 2.0.1 (2009-11-10)
|
||||
|
||||
* Fixed bug when the number of devices is more then 9 on Windows
|
||||
* Provided functions for possible memory leaks in some languages
|
||||
* Better error-reporting when communication with TellStick doesn't work
|
||||
* More friendlier configuration for GAO
|
||||
|
||||
telldus-core 2.0.0 (2009-09-22)
|
||||
|
||||
* Initial release
|
339
LICENSE
Normal file
339
LICENSE
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 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.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, 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 or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
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 give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
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 Program or any portion
|
||||
of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
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 Program, 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 Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) 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; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, 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 executable. However, as a
|
||||
special exception, the source code 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.
|
||||
|
||||
If distribution of executable or 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 counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program 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.
|
||||
|
||||
5. 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 Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program 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 to
|
||||
this License.
|
||||
|
||||
7. 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 Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program 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 Program.
|
||||
|
||||
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.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program 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.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 Program
|
||||
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 Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, 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
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), 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 Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; 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.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
|
@ -10,7 +10,7 @@ INSTALLING Telldus Core
|
|||
On Windows, if you want to install the precompiles binary packages, simply
|
||||
launch the package and follow the instructions in the installation wizard.
|
||||
|
||||
If you have a source package (a .tar.gz file), follow the instruction in the
|
||||
If you have a source package (a .tag.gz file), follow the instruction in the
|
||||
INSTALL file.
|
||||
|
||||
|
||||
|
@ -19,8 +19,8 @@ CONFIGURATION AND TOOLS
|
|||
Once Telldus Core is installed, we suggest that you start by adding the devices
|
||||
you want to control.
|
||||
|
||||
On Windows, this is done by installing TelldusCenter. On Linux it's done by
|
||||
editing the file /etc/tellstick.conf directly, or in TelldusCenter.
|
||||
On Windows, this is done with the tool TelldusSetup. On Linux this is done in
|
||||
the file /etc/tellstick.conf.
|
||||
|
||||
Telldus Core installs the tool tdtool for controlling devices with TellStick.
|
||||
Have a look in the man page for a description how to use it:
|
|
@ -1,36 +0,0 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TelldusNETWrapper")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Telldus Technologies AB")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies AB 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(true)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a66028f7-b342-4dc0-9504-9e07c462ec15")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -1,816 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace TelldusWrapper
|
||||
{
|
||||
public sealed class TelldusNETWrapper //don't allow inheritance
|
||||
{
|
||||
int lastEventID = 0;
|
||||
Dictionary<int, Object> callbackFunctionReferenceList = new Dictionary<int, Object>(); //this prevents errors in "unknown module" due to callback functions being garbage collected since there are no reference to them
|
||||
|
||||
//TODO
|
||||
List<Object> lista = new List<object>();
|
||||
|
||||
//Device methods
|
||||
public const int TELLSTICK_TURNON = 1;
|
||||
public const int TELLSTICK_TURNOFF = 2;
|
||||
public const int TELLSTICK_BELL = 4;
|
||||
public const int TELLSTICK_TOGGLE = 8;
|
||||
public const int TELLSTICK_DIM = 16;
|
||||
public const int TELLSTICK_LEARN = 32;
|
||||
public const int TELLSTICK_EXECUTE = 64;
|
||||
public const int TELLSTICK_UP = 128;
|
||||
public const int TELLSTICK_DOWN = 256;
|
||||
public const int TELLSTICK_STOP = 512;
|
||||
|
||||
//Error codes
|
||||
public const int TELLSTICK_SUCCESS = 0;
|
||||
public const int TELLSTICK_ERROR_NOT_FOUND = -1;
|
||||
public const int TELLSTICK_ERROR_PERMISSION_DENIED = -2;
|
||||
public const int TELLSTICK_ERROR_DEVICE_NOT_FOUND = -3;
|
||||
public const int TELLSTICK_ERROR_METHOD_NOT_SUPPORTED = -4;
|
||||
public const int TELLSTICK_ERROR_COMMUNICATION = -5;
|
||||
public const int TELLSTICK_ERROR_CONNECTING_SERVICE = -6;
|
||||
public const int TELLSTICK_ERROR_UNKNOWN_RESPONSE = -7;
|
||||
public const int TELLSTICK_ERROR_UNKNOWN = -99;
|
||||
|
||||
//Device typedef
|
||||
public const int TELLSTICK_TYPE_DEVICE = 1;
|
||||
public const int TELLSTICK_TYPE_GROUP = 2;
|
||||
public const int TELLSTICK_TYPE_SCENE = 3;
|
||||
|
||||
//Device changes
|
||||
public const int TELLSTICK_DEVICE_ADDED = 1;
|
||||
public const int TELLSTICK_DEVICE_CHANGED = 2;
|
||||
public const int TELLSTICK_DEVICE_REMOVED = 3;
|
||||
public const int TELLSTICK_DEVICE_STATE_CHANGED = 4;
|
||||
|
||||
//Change types
|
||||
public const int TELLSTICK_CHANGE_NAME = 1;
|
||||
public const int TELLSTICK_CHANGE_PROTOCOL = 2;
|
||||
public const int TELLSTICK_CHANGE_MODEL = 3;
|
||||
|
||||
//variables for event callback (e.g. turnon, turnoff)
|
||||
public delegate int EventCallbackFunction(int deviceId, int method, string data, int callbackId, Object obj);
|
||||
private struct DeviceEventFunctionContext
|
||||
{
|
||||
public EventCallbackFunction eventCallbackFunc;
|
||||
public Object context;
|
||||
public int callbackId;
|
||||
}
|
||||
Dictionary<int, DeviceEventFunctionContext> deviceEventList = new Dictionary<int, DeviceEventFunctionContext>();
|
||||
int registeredEventFunctionId = -1;
|
||||
|
||||
//variables for device event callback (e.g. change of name/protocol)
|
||||
public delegate int DeviceChangeEventCallbackFunction(int deviceId, int changeEvent, int changeType, int callbackId, Object obj);
|
||||
private struct DeviceChangeEventFunctionContext
|
||||
{
|
||||
public DeviceChangeEventCallbackFunction changeEventCallbackFunc;
|
||||
public Object context;
|
||||
public int callbackId;
|
||||
}
|
||||
Dictionary<int, DeviceChangeEventFunctionContext> deviceChangeEventList = new Dictionary<int, DeviceChangeEventFunctionContext>();
|
||||
int registeredDeviceChangeEventFunctionId = -1;
|
||||
|
||||
//variables for raw controller listening callback (e.g. Tellstick Duo receives data)
|
||||
public delegate int RawListeningCallbackFunction(string data, int controllerId, int callbackId, Object obj);
|
||||
private struct RawEventFunctionContext
|
||||
{
|
||||
public RawListeningCallbackFunction rawCallbackFunc;
|
||||
public Object context;
|
||||
public int callbackId;
|
||||
}
|
||||
Dictionary<int, RawEventFunctionContext> rawListenerList = new Dictionary<int, RawEventFunctionContext>();
|
||||
int registeredRawListenerFunctionId = -1;
|
||||
|
||||
public TelldusNETWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
~TelldusNETWrapper()
|
||||
{
|
||||
//clean up
|
||||
if (registeredEventFunctionId != -1)
|
||||
{
|
||||
UnmanagedImport.tdUnregisterCallback(registeredEventFunctionId);
|
||||
}
|
||||
if (registeredDeviceChangeEventFunctionId != -1)
|
||||
{
|
||||
UnmanagedImport.tdUnregisterCallback(registeredDeviceChangeEventFunctionId);
|
||||
}
|
||||
if (registeredRawListenerFunctionId != -1)
|
||||
{
|
||||
UnmanagedImport.tdUnregisterCallback(registeredRawListenerFunctionId);
|
||||
}
|
||||
UnmanagedImport.tdClose(); //Close the library and clean up the cache it uses.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Imported functions from TelldusCore.dll
|
||||
/// </summary>
|
||||
private sealed class UnmanagedImport
|
||||
{
|
||||
private UnmanagedImport() { } //cannot instantiate this class
|
||||
|
||||
#region Unmanaged Code
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdGetNumberOfDevices();
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdGetDeviceId(int value);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern char* tdGetName(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern char* tdGetProtocol(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern char* tdGetModel(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern char* tdGetDeviceParameter(int deviceId, char* name, char* defaultValue);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern bool tdSetName(int deviceId, char* name);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern bool tdSetProtocol(int deviceId, char* protocol);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern bool tdSetModel(int deviceId, char* model);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern bool tdSetDeviceParameter(int deviceId, char* name, char* value);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdAddDevice();
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern bool tdRemoveDevice(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdMethods(int deviceId, int methodsSupported);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdTurnOn(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdTurnOff(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdBell(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdDim(int deviceId, char level);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdExecute(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdUp(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdDown(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdStop(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern char* tdGetErrorString(int errorNo);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern void tdClose();
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern void tdInit();
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdRegisterDeviceEvent(Delegate deviceEventFunction, void* context);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdLastSentCommand(int deviceId, int methods);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdGetDeviceType(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdSendRawCommand(char* command, int reserved);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdRegisterRawDeviceEvent(Delegate rawListeningFunction, void* context);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static extern int tdLearn(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern char* tdLastSentValue(int deviceId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern void tdReleaseString(char* value);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdUnregisterCallback(int eventId);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
public static unsafe extern int tdRegisterDeviceChangeEvent(Delegate deviceChangeEventFunction, void* context);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public unsafe delegate void EventFunctionDelegate(int deviceId, int method, char* data, int callbackId, void* context);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public unsafe delegate void DeviceChangeEventFunctionDelegate(int deviceId, int changeEvent, int changeType, int callbackId, void* context);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public unsafe delegate void RawListeningDelegate(char* data, int controllerId, int callbackId, void* context);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Add a new device to the global database of devices. This function must be called first before
|
||||
/// any call to tdSetName(), tdSetProtocol() and similar functions.
|
||||
/// </summary>
|
||||
/// <returns> The device id for the newly created device. If the creation fails it returnes a
|
||||
/// negative value.</returns>
|
||||
public static int tdAddDevice()
|
||||
{
|
||||
return UnmanagedImport.tdAddDevice();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends bell command to devices supporting this.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to sound the bell on</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdBell(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdBell(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close the library and clean up the cache it uses.
|
||||
/// This should be called when the library is not supposed to be used anymore.
|
||||
/// Do not use when this has been instantiated, will be closed in destructor then, only on static methods.
|
||||
/// </summary>
|
||||
public static void tdClose()
|
||||
{
|
||||
UnmanagedImport.tdClose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dims a device.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device id to dim</param>
|
||||
/// <param name="level">The level the device should dim to. This value should be 0-255</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdDim(int deviceId, char level)
|
||||
{
|
||||
return UnmanagedImport.tdDim(deviceId, level);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send "down" command to device.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device id to send the command to</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdDown(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdDown(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Execute a scene action.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to perform the execute action on</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdExecute(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdExecute(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function returns the unique id of a device with a specific index.
|
||||
/// To get all the id numbers you should loop over all the devices, use tdGetNumberOfDevices() to get the number of devices
|
||||
/// </summary>
|
||||
/// <param name="order">Device index</param>
|
||||
/// <returns>Id of device at that position</returns>
|
||||
public static int tdGetDeviceId(int order)
|
||||
{
|
||||
return UnmanagedImport.tdGetDeviceId(order);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a protocol specific device parameter
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The id of the device to query</param>
|
||||
/// <param name="name">The name of the parameter to query</param>
|
||||
/// <param name="defaultValue">A defaultValue to return if the current parameter hasn't previously been set</param>
|
||||
/// <returns>Any protocol specific parameter specified by "name"</returns>
|
||||
public static unsafe string tdGetDeviceParameter(int deviceId, string name, string defaultValue)
|
||||
{
|
||||
return getString(UnmanagedImport.tdGetDeviceParameter(deviceId, stringToChar(name), stringToChar(defaultValue)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns which type the device is
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of the device</param>
|
||||
/// <returns>TELLSTICK_TYPE_DEVICE or TELLSTICK_TYPE_GROUP</returns>
|
||||
public static int tdGetDeviceType(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdGetDeviceType(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a human readable string from an error code returned from a function in telldus-core
|
||||
/// </summary>
|
||||
/// <param name="errorNo">The error code to translate</param>
|
||||
/// <returns>A string ready to show to the user.
|
||||
/// TELLSTICK_SUCCESS
|
||||
/// TELLSTICK_ERROR_NOT_FOUND
|
||||
/// TELLSTICK_ERROR_PERMISSION_DENIED
|
||||
/// TELLSTICK_ERROR_DEVICE_NOT_FOUND
|
||||
/// TELLSTICK_ERROR_METHOD_NOT_SUPPORTED
|
||||
/// TELLSTICK_ERROR_COMMUNICATION
|
||||
/// TELLSTICK_ERROR_CONNECTING_SERVICE
|
||||
/// TELLSTICK_ERROR_UNKNOWN_RESPONSE
|
||||
/// TELLSTICK_ERROR_UNKNOWN
|
||||
/// </returns>
|
||||
public static unsafe string tdGetErrorString(int errorNo)
|
||||
{
|
||||
return getString(UnmanagedImport.tdGetErrorString(errorNo));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query a device for it’s name
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to query</param>
|
||||
/// <returns>The name of the device or an empty string if the device is not found</returns>
|
||||
public static unsafe string tdGetName(int deviceId)
|
||||
{
|
||||
return getString(UnmanagedImport.tdGetName(deviceId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query a device for which methods it supports. By supplying the methods you support
|
||||
/// the library could remap the methods a device support for better fit the application.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to query</param>
|
||||
/// <param name="methodsSupported">Methods that the client application supports</param>
|
||||
/// <returns>Supported (both by client application and by device) method-flags OR'ed into an integer
|
||||
/// TELLSTICK_TURNON
|
||||
/// TELLSTICK_TURNOFF
|
||||
/// TELLSTICK_BELL
|
||||
/// TELLSTICK_TOGGLE
|
||||
/// TELLSTICK_DIM
|
||||
/// TELLSTICK_EXECUTE
|
||||
/// TELLSTICK_UP
|
||||
/// TELLSTICK_DOWN
|
||||
/// TELLSTICK_EXECUTE
|
||||
/// TELLSTICK_LEARN
|
||||
/// </returns>
|
||||
public static int tdMethods(int deviceId, int methodsSupported)
|
||||
{
|
||||
return UnmanagedImport.tdMethods(deviceId, methodsSupported);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query a device for it’s model
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to query</param>
|
||||
/// <returns>The model for a device. Not all protocols use this.</returns>
|
||||
public static unsafe string tdGetModel(int deviceId)
|
||||
{
|
||||
return getString(UnmanagedImport.tdGetModel(deviceId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function returns the number of devices configured
|
||||
/// </summary>
|
||||
/// <returns>The total number of devices configured</returns>
|
||||
public static int tdGetNumberOfDevices()
|
||||
{
|
||||
return UnmanagedImport.tdGetNumberOfDevices();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query a device for it’s protocol
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to query</param>
|
||||
/// <returns>The protocol for a device.</returns>
|
||||
public static unsafe string tdGetProtocol(int deviceId)
|
||||
{
|
||||
return getString(UnmanagedImport.tdGetProtocol(deviceId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last sent command to a specific device
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to query</param>
|
||||
/// <param name="methods">The methods supported by the client. See tdMethods() for more information.</param>
|
||||
/// <returns>The last sent command as integer, for example TELLSTICK_TURNON or TELLSTICK_TURNOFF</returns>
|
||||
public static int tdLastSentCommand(int deviceId, int methods)
|
||||
{
|
||||
return UnmanagedImport.tdLastSentCommand(deviceId, methods);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the last sent command it TELLSTICK_DIM this returns the dimmed value
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to query</param>
|
||||
/// <returns>The the value as a human readable string, for example "128" for 50%</returns>
|
||||
public static unsafe string tdLastSentValue(int deviceId)
|
||||
{
|
||||
return getString(UnmanagedImport.tdLastSentValue(deviceId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a special learn command to some devices that need a special learn-command to be used from TellStick
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to learn</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdLearn(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdLearn(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a callback event function to be called when a device event (e.g. turn on, turn off) occurs
|
||||
/// </summary>
|
||||
/// <param name="eventFunc">Callback function to be called</param>
|
||||
/// <param name="obj">Context object that will be echoed back when function is called. Only the object when the first function is registered will be used. Set to null if not used.</param>
|
||||
/// <returns>Callback event id</returns>
|
||||
public unsafe int tdRegisterDeviceEvent(EventCallbackFunction deviceEventFunc, Object obj)
|
||||
{
|
||||
int returnValue = 0;
|
||||
|
||||
if (deviceEventList.Count == 0)
|
||||
{
|
||||
//first added, register with dll too
|
||||
UnmanagedImport.EventFunctionDelegate deviceEventFunctionDelegate = new UnmanagedImport.EventFunctionDelegate(deviceEventFunction);
|
||||
|
||||
registeredEventFunctionId = UnmanagedImport.tdRegisterDeviceEvent(deviceEventFunctionDelegate, (void*)null); //context here or above?
|
||||
GC.Collect();
|
||||
callbackFunctionReferenceList.Add(registeredEventFunctionId, deviceEventFunctionDelegate);
|
||||
}
|
||||
|
||||
++lastEventID;
|
||||
returnValue = lastEventID;
|
||||
DeviceEventFunctionContext deviceEventFuncContext = new DeviceEventFunctionContext();
|
||||
deviceEventFuncContext.eventCallbackFunc = deviceEventFunc;
|
||||
deviceEventFuncContext.context = obj;
|
||||
deviceEventFuncContext.callbackId = returnValue;
|
||||
deviceEventList.Add(returnValue, deviceEventFuncContext);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a callback device change event function to be called when a device change event (e.g. change of name, device added) occurs
|
||||
/// </summary>
|
||||
/// <param name="deviceEventFunc">Callback function to be called</param>
|
||||
/// <param name="obj">Context object that will be echoed back when function is called. Only the object when the first function is registered will be used. Set to null if not used.</param>
|
||||
/// <returns>Callback event id</returns>
|
||||
public unsafe int tdRegisterDeviceChangeEvent(DeviceChangeEventCallbackFunction deviceChangeEventFunc, Object obj)
|
||||
{
|
||||
int returnValue = 0;
|
||||
if (deviceChangeEventList.Count == 0)
|
||||
{
|
||||
//first added, register with dll too
|
||||
//only the context object of the first event will be registered
|
||||
UnmanagedImport.DeviceChangeEventFunctionDelegate deviceChangeEventFunctionDelegate = new UnmanagedImport.DeviceChangeEventFunctionDelegate(deviceChangeEventFunction);
|
||||
|
||||
registeredDeviceChangeEventFunctionId = UnmanagedImport.tdRegisterDeviceChangeEvent(deviceChangeEventFunctionDelegate, (void*)null);
|
||||
GC.Collect();
|
||||
callbackFunctionReferenceList.Add(registeredDeviceChangeEventFunctionId, deviceChangeEventFunctionDelegate);
|
||||
}
|
||||
++lastEventID;
|
||||
returnValue = lastEventID;
|
||||
DeviceChangeEventFunctionContext deviceChangeEventFuncContext = new DeviceChangeEventFunctionContext();
|
||||
deviceChangeEventFuncContext.changeEventCallbackFunc = deviceChangeEventFunc;
|
||||
deviceChangeEventFuncContext.context = obj;
|
||||
deviceChangeEventFuncContext.callbackId = returnValue;
|
||||
deviceChangeEventList.Add(returnValue, deviceChangeEventFuncContext);
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a callback listening function to be called when a listening event (e.g. data is received with Tellstick Duo) occurs
|
||||
/// </summary>
|
||||
/// <param name="listeningFunc">Callback function to be called</param>
|
||||
/// <param name="obj">Context object that will be echoed back when function is called. Only the object when the first function is registered will be used. Set to null if not used.</param>
|
||||
/// <returns>Callback event id</returns>
|
||||
public unsafe int tdRegisterRawDeviceEvent(RawListeningCallbackFunction listeningFunc, Object obj)
|
||||
{
|
||||
int returnValue = 0;
|
||||
if (rawListenerList.Count == 0)
|
||||
{
|
||||
//first added, register with dll too
|
||||
//only the context object of the first event will be registered
|
||||
UnmanagedImport.RawListeningDelegate listeningFunctionDelegate = new UnmanagedImport.RawListeningDelegate(rawListeningFunction);
|
||||
|
||||
registeredRawListenerFunctionId = UnmanagedImport.tdRegisterRawDeviceEvent(listeningFunctionDelegate, (void*)null);
|
||||
GC.Collect();
|
||||
callbackFunctionReferenceList.Add(registeredRawListenerFunctionId, listeningFunctionDelegate);
|
||||
}
|
||||
++lastEventID;
|
||||
returnValue = lastEventID;
|
||||
RawEventFunctionContext rawEventFuncContext = new RawEventFunctionContext();
|
||||
rawEventFuncContext.rawCallbackFunc = listeningFunc;
|
||||
rawEventFuncContext.context = obj;
|
||||
rawEventFuncContext.callbackId = returnValue;
|
||||
rawListenerList.Add(returnValue, rawEventFuncContext);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a device.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to remove</param>
|
||||
/// <returns>True on success, false otherwise</returns>
|
||||
public static bool tdRemoveDevice(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdRemoveDevice(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a raw command to TellStick. Please read the TellStick protocol definition on how the command should be constructed.
|
||||
/// </summary>
|
||||
/// <param name="command">The command for TellStick in its native format</param>
|
||||
/// <param name="reserved"></param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static unsafe int tdSendRawCommand(string command, int reserved)
|
||||
{
|
||||
char* commandChar = stringToChar(command);
|
||||
int returnValue = UnmanagedImport.tdSendRawCommand(commandChar, reserved);
|
||||
Marshal.FreeHGlobal((IntPtr)commandChar);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new protocol specific parameter. Please see the documentation of the protocols before setting any parameter.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to change</param>
|
||||
/// <param name="name">The name of the parameter to change</param>
|
||||
/// <param name="value">The new value for the parameter</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static unsafe bool tdSetDeviceParameter(int deviceId, string name, string value)
|
||||
{
|
||||
char* nameChar = stringToChar(name);
|
||||
char* valueChar = stringToChar(value);
|
||||
bool returnValue = UnmanagedImport.tdSetDeviceParameter(deviceId, nameChar, valueChar);
|
||||
Marshal.FreeHGlobal((IntPtr)nameChar);
|
||||
Marshal.FreeHGlobal((IntPtr)valueChar);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new model for a device. Which model to set depends on the current protocol.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to change</param>
|
||||
/// <param name="model">The new model</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static unsafe bool tdSetModel(int deviceId, string model)
|
||||
{
|
||||
char* modelChar = stringToChar(model);
|
||||
bool returnValue = UnmanagedImport.tdSetModel(deviceId, modelChar);
|
||||
Marshal.FreeHGlobal((IntPtr)modelChar);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a new name for a device.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to change</param>
|
||||
/// <param name="name">The new name</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static unsafe bool tdSetName(int deviceId, string name)
|
||||
{
|
||||
char* nameChar = stringToChar(name);
|
||||
bool returnValue = UnmanagedImport.tdSetName(deviceId, nameChar);
|
||||
Marshal.FreeHGlobal((IntPtr)nameChar);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This changes the current protocol used by a device. After changing the protocol, setting new parameters is required.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to change</param>
|
||||
/// <param name="protocol">The new protocol to use</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static unsafe bool tdSetProtocol(int deviceId, string protocol)
|
||||
{
|
||||
char* protocolChar = stringToChar(protocol);
|
||||
bool returnValue = UnmanagedImport.tdSetProtocol(deviceId, protocolChar);
|
||||
Marshal.FreeHGlobal((IntPtr)protocolChar);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send "stop" command to device.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device id to stop</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdStop(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdStop(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns a device on.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to turn on</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdTurnOn(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdTurnOn(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns a device off.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of device to turn off</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdTurnOff(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdTurnOff(deviceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregister a callback function. All functions will be unregistered automatically when this objekt is deleted.
|
||||
/// </summary>
|
||||
/// <param name="eventId">Id of callback even to unregister</param>
|
||||
public void unregisterCallback(int eventId)
|
||||
{
|
||||
deviceEventList.Remove(eventId);
|
||||
if (deviceEventList.Count == 0)
|
||||
{
|
||||
//no more events in list
|
||||
UnmanagedImport.tdUnregisterCallback(registeredEventFunctionId);
|
||||
callbackFunctionReferenceList.Remove(registeredEventFunctionId);
|
||||
/*
|
||||
if (eventContextHandle.IsAllocated)
|
||||
{
|
||||
eventContextHandle.Free();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
deviceChangeEventList.Remove(eventId);
|
||||
if (deviceChangeEventList.Count == 0)
|
||||
{
|
||||
//no more events in list
|
||||
UnmanagedImport.tdUnregisterCallback(registeredDeviceChangeEventFunctionId);
|
||||
callbackFunctionReferenceList.Remove(registeredDeviceChangeEventFunctionId);
|
||||
}
|
||||
|
||||
rawListenerList.Remove(eventId);
|
||||
if (rawListenerList.Count == 0)
|
||||
{
|
||||
//no more events in list
|
||||
UnmanagedImport.tdUnregisterCallback(registeredRawListenerFunctionId);
|
||||
callbackFunctionReferenceList.Remove(registeredRawListenerFunctionId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send "up" command to device.
|
||||
/// Make sure the device supports this by calling tdMethods() before any calls to this function.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device id to send the command to</param>
|
||||
/// <returns>Success or error code</returns>
|
||||
public static int tdUp(int deviceId)
|
||||
{
|
||||
return UnmanagedImport.tdUp(deviceId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Convert char* to correctly encoded string, clean up received char*
|
||||
/// </summary>
|
||||
/// <param name="input">Char* to convert</param>
|
||||
/// <returns>Converted string</returns>
|
||||
private static unsafe string getString(char* input)
|
||||
{
|
||||
return getString(input, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert char* to correctly encoded string, clean up of received char* is optional
|
||||
/// </summary>
|
||||
/// <param name="input">Char* to convert</param>
|
||||
/// <param name="release">Clean up char* or not (don't do that if it is still should be used somewhere)</param>
|
||||
/// <returns>Converted string</returns>
|
||||
private static unsafe string getString(char* input, bool release)
|
||||
{
|
||||
string returnString = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.Unicode.GetBytes(new string(input)));
|
||||
|
||||
if (returnString.Contains("\0"))
|
||||
{
|
||||
returnString = returnString.Substring(0, returnString.IndexOf('\0'));
|
||||
}
|
||||
|
||||
if (release)
|
||||
{
|
||||
UnmanagedImport.tdReleaseString(input);
|
||||
}
|
||||
GC.Collect();
|
||||
return returnString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert string to correctly encoded char*
|
||||
/// </summary>
|
||||
/// <param name="input">String to convert</param>
|
||||
/// <returns>Converted char*</returns>
|
||||
private static unsafe char* stringToChar(string input)
|
||||
{
|
||||
input = String.Concat(input, char.MinValue); //add null terminator
|
||||
byte[] inputByte = System.Text.Encoding.UTF8.GetBytes(input);
|
||||
int size = Marshal.SystemDefaultCharSize * inputByte.Length;
|
||||
IntPtr inputPointer = Marshal.AllocHGlobal(size);
|
||||
|
||||
Marshal.Copy(inputByte, 0, inputPointer, inputByte.Length);
|
||||
return (char*)inputPointer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event function wrapper that will call all registered event functions with C#-arguments when
|
||||
/// this event function is called from telldus core, with C++-style arguments. This function will
|
||||
/// be registered with telldus core when the first event callback function is added.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of affected device</param>
|
||||
/// <param name="method">Method that was executed on device</param>
|
||||
/// <param name="data">Optional data that was sent to the method (e.g. dim value)</param>
|
||||
/// <param name="callbackId">Callback event id</param>
|
||||
/// <param name="context">Context (optional)</param>
|
||||
/// <returns>0</returns>
|
||||
private unsafe void deviceEventFunction(int deviceId, int method, char* data, int callbackId, void* context)
|
||||
{
|
||||
foreach (DeviceEventFunctionContext deviceEventFuncContext in deviceEventList.Values)
|
||||
{
|
||||
deviceEventFuncContext.eventCallbackFunc(deviceId, method, getString(data, false), deviceEventFuncContext.callbackId, deviceEventFuncContext.context);
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Event function wrapper that will call all registered device change event functions with C#-arguments when
|
||||
/// this device change event function is called from telldus core, with C++-style arguments. This function will
|
||||
/// be registered with telldus core when the first device change event callback function is added.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">Id of affected device</param>
|
||||
/// <param name="changeEvent">Method that was executed, TELLSTICK_DEVICE_ADDED, TELLSTICK_DEVICE_CHANGED, TELLSTICK_DEVICE_REMOVED, TELLSTICK_DEVICE_STATE_CHANGED</param>
|
||||
/// <param name="changeType">Type of change TELLSTICK_CHANGE_NAME, TELLSTICK_CHANGE_PROTOCOL, TELLSTICK_CHANGE_MODEL</param>
|
||||
/// <param name="callbackId">Callback event id</param>
|
||||
/// <param name="context">Context (optional)</param>
|
||||
/// <returns>0</returns>
|
||||
private unsafe void deviceChangeEventFunction(int deviceId, int changeEvent, int changeType, int callbackId, void* context)
|
||||
{
|
||||
foreach (DeviceChangeEventFunctionContext deviceChangeEventFuncContext in deviceChangeEventList.Values)
|
||||
{
|
||||
deviceChangeEventFuncContext.changeEventCallbackFunc(deviceId, changeEvent, changeType, deviceChangeEventFuncContext.callbackId, deviceChangeEventFuncContext.context);
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event function wrapper that will call all registered listening functions with C#-arguments when
|
||||
/// this listening function is called from telldus core, with C++-style arguments. This function will
|
||||
/// be registered with telldus core when the first listening callback function is added.
|
||||
/// </summary>
|
||||
/// <param name="data">Received data</param>
|
||||
/// <param name="controllerId">Id of receiving controller</param>
|
||||
/// <param name="callbackId">Callback event id</param>
|
||||
/// <param name="context">Context (optional)</param>
|
||||
/// <returns>0</returns>
|
||||
private unsafe void rawListeningFunction(char* data, int controllerId, int callbackId, void* context)
|
||||
{
|
||||
foreach (RawEventFunctionContext rawListeningFuncContext in rawListenerList.Values)
|
||||
{
|
||||
rawListeningFuncContext.rawCallbackFunc(getString(data, false), controllerId, rawListeningFuncContext.callbackId, rawListeningFuncContext.context);
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{675C494F-7D3B-4F6F-AB7A-98BA9E2B2B43}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TelldusNETWrapper</RootNamespace>
|
||||
<AssemblyName>TelldusNETWrapper</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkSubset>
|
||||
</TargetFrameworkSubset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TelldusNETWrapper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TelldusNETWrapper", "TelldusNETWrapper.csproj", "{675C494F-7D3B-4F6F-AB7A-98BA9E2B2B43}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{675C494F-7D3B-4F6F-AB7A-98BA9E2B2B43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{675C494F-7D3B-4F6F-AB7A-98BA9E2B2B43}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{675C494F-7D3B-4F6F-AB7A-98BA9E2B2B43}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{675C494F-7D3B-4F6F-AB7A-98BA9E2B2B43}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Binary file not shown.
|
@ -1,3 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
|
Binary file not shown.
Binary file not shown.
|
@ -1,98 +0,0 @@
|
|||
import java.io.*;
|
||||
|
||||
class test
|
||||
{
|
||||
tellstick TS = new tellstick();
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
int nbrDevices = TS.devGetNumberOfDevices();
|
||||
for (int i = 0; i < nbrDevices; i++) {
|
||||
int id = TS.devGetDeviceId(i);
|
||||
String deviceName = TS.devGetName(id);
|
||||
System.out.println(id + "\t" + deviceName);
|
||||
}
|
||||
|
||||
System.out.print("Enter a device: ");
|
||||
int device = Integer.parseInt(in.readLine());
|
||||
process(device);
|
||||
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void process(int device) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||
int methods = TS.devMethods(device);
|
||||
if ((methods & TS.TELLSTICK_TURNON) > 0) {
|
||||
System.out.println(TS.TELLSTICK_TURNON + "\tTurn on");
|
||||
}
|
||||
if ((methods & TS.TELLSTICK_TURNOFF) > 0) {
|
||||
System.out.println(TS.TELLSTICK_TURNOFF + "\tTurn off");
|
||||
}
|
||||
if ((methods & TS.TELLSTICK_BELL) > 0) {
|
||||
System.out.println(TS.TELLSTICK_BELL + "\tBell");
|
||||
}
|
||||
if ((methods & TS.TELLSTICK_DIM) > 0) {
|
||||
System.out.println(TS.TELLSTICK_DIM + "\tDim");
|
||||
}
|
||||
System.out.println("What do you want to do?");
|
||||
int action = Integer.parseInt(in.readLine());
|
||||
if ( (action & methods) == 0 ) {
|
||||
System.out.println("The device doesn't support this method");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((action & TS.TELLSTICK_TURNON) > 0) {
|
||||
turnOn(device);
|
||||
} else if ((action & TS.TELLSTICK_TURNOFF) > 0) {
|
||||
turnOff(device);
|
||||
} else if ((action & TS.TELLSTICK_BELL) > 0) {
|
||||
bell(device);
|
||||
} else if ((action & TS.TELLSTICK_DIM) > 0) {
|
||||
dim(device);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void turnOn(int device) {
|
||||
System.out.println("Turning on " + TS.devGetName(device));
|
||||
TS.devTurnOn(device);
|
||||
}
|
||||
|
||||
private void turnOff(int device) {
|
||||
System.out.println("Turning off " + TS.devGetName(device));
|
||||
TS.devTurnOff(device);
|
||||
}
|
||||
|
||||
private void bell(int device) {
|
||||
System.out.println("Sending bell to " + TS.devGetName(device));
|
||||
TS.devBell(device);
|
||||
}
|
||||
|
||||
private void dim(int device) {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||
System.out.print("Select level (0-255): ");
|
||||
int level = Integer.parseInt(in.readLine());
|
||||
if (level >= 256 || level < 0) {
|
||||
System.out.println("Out of range");
|
||||
}
|
||||
System.out.println("Dim " + TS.devGetName(device));
|
||||
TS.devDim(device, level);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
test t = new test();
|
||||
t.run();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*tellstick.c*/
|
||||
#include "tellstick.h"
|
||||
#include <stdio.h>
|
||||
#include <TellUsbD101.h>
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_tellstick_devTurnOn(JNIEnv *, jobject, jint intDeviceId)
|
||||
{
|
||||
return (jboolean) devTurnOn( (int)intDeviceId);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_tellstick_devTurnOff(JNIEnv *, jobject, jint intDeviceId)
|
||||
{
|
||||
return (jboolean) devTurnOff( (int)intDeviceId);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_tellstick_devBell(JNIEnv *, jobject, jint intDeviceId)
|
||||
{
|
||||
return (jboolean) devBell( (int)intDeviceId);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_tellstick_devDim(JNIEnv *, jobject, jint intDeviceId, jint level)
|
||||
{
|
||||
return (jboolean) devDim( (int)intDeviceId, (unsigned char) level);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_tellstick_devMethods(JNIEnv *, jobject, jint intDeviceId)
|
||||
{
|
||||
return (jint) devMethods( (int)intDeviceId );
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_tellstick_devGetNumberOfDevices(JNIEnv *, jobject)
|
||||
{
|
||||
return (jint)devGetNumberOfDevices();
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_tellstick_devGetDeviceId(JNIEnv *, jobject, jint intDeviceIndex)
|
||||
{
|
||||
return (jint)devGetDeviceId( (int)intDeviceIndex );
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_tellstick_devGetName(JNIEnv *env, jobject, jint intDeviceId)
|
||||
{
|
||||
const char *name = devGetName( (int)intDeviceId );
|
||||
return env->NewStringUTF(name);
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class tellstick */
|
||||
|
||||
#ifndef _Included_tellstick
|
||||
#define _Included_tellstick
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devTurnOn
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_tellstick_devTurnOn
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devTurnOff
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_tellstick_devTurnOff
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devBell
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_tellstick_devBell
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devDim
|
||||
* Signature: (II)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_tellstick_devDim
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devMethods
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_tellstick_devMethods
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devGetNumberOfDevices
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_tellstick_devGetNumberOfDevices
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devGetDeviceId
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_tellstick_devGetDeviceId
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: tellstick
|
||||
* Method: devGetName
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_tellstick_devGetName
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,27 +0,0 @@
|
|||
//firstJNI.java
|
||||
|
||||
public class tellstick
|
||||
{
|
||||
public final int TELLSTICK_TURNON = 1;
|
||||
public final int TELLSTICK_TURNOFF = 2;
|
||||
public final int TELLSTICK_BELL = 4;
|
||||
public final int TELLSTICK_DIM = 16;
|
||||
|
||||
public native boolean devTurnOn(int intDeviceId);
|
||||
public native boolean devTurnOff(int intDeviceId);
|
||||
public native boolean devBell(int intDeviceId);
|
||||
public native boolean devDim(int intDeviceId, int level);
|
||||
public native int devMethods(int intDeviceId);
|
||||
|
||||
public native int devGetNumberOfDevices();
|
||||
public native int devGetDeviceId(int intDeviceIndex);
|
||||
|
||||
public native String devGetName(int intDeviceId);
|
||||
|
||||
static {
|
||||
System.loadLibrary("tellstickJNI");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
PHP_ARG_ENABLE(telldus, whether to enable Telldus TellStick support,
|
||||
[ --enable-telldus Enable Telldus TellStick support])
|
||||
|
||||
if test "$PHP_TELLDUS" = "yes"; then
|
||||
AC_DEFINE(HAVE_TELLDUS, 1, [Whether you have Telldus TellStick])
|
||||
|
||||
SEARCH_PATH="/usr/local /usr"
|
||||
SEARCH_FOR="/include/telldus-core.h"
|
||||
if test -r $PHP_TELLDUS/; then # path given as parameter
|
||||
TELLDUS_DIR=$PHP_TELLDUS
|
||||
else # search default path list
|
||||
AC_MSG_CHECKING([for telldus files in default path])
|
||||
for i in $SEARCH_PATH ; do
|
||||
if test -r $i/$SEARCH_FOR; then
|
||||
TELLDUS_DIR=$i
|
||||
AC_MSG_RESULT(found in $i)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if test -z "$TELLDUS_DIR"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please reinstall the telldus-core distribution])
|
||||
fi
|
||||
# --enable-telldus -> add include path
|
||||
PHP_ADD_INCLUDE($TELLDUS_DIR/include)
|
||||
# --enable-telldus -> check for lib and symbol presence
|
||||
LIBNAME=telldus-core
|
||||
LIBSYMBOL=tdGetNumberOfDevices
|
||||
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
|
||||
[
|
||||
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $TELLDUS_DIR/lib, TELLDUS_SHARED_LIBADD)
|
||||
AC_DEFINE(HAVE_TELLDUSLIB,1,[ ])
|
||||
],[
|
||||
AC_MSG_ERROR([wrong telldus lib version or lib not found])
|
||||
],[
|
||||
-L$TELLDUS_DIR/lib -lm
|
||||
])
|
||||
PHP_SUBST(TELLDUS_SHARED_LIBADD)
|
||||
|
||||
PHP_NEW_EXTENSION(telldus, telldus.c, $ext_shared)
|
||||
fi
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
if(!extension_loaded('telldus')) {
|
||||
dl('telldus.' . PHP_SHLIB_SUFFIX);
|
||||
}
|
||||
|
||||
$devices = tdGetNumberOfDevices();
|
||||
printf("Devices: %d\n", $devices);
|
||||
|
||||
$allMethods = TELLDUS_TURNON | TELLDUS_TURNOFF | TELLDUS_BELL | TELLDUS_DIM;
|
||||
|
||||
for( $i = 0; $i < $devices; ++$i ) {
|
||||
$id = tdGetDeviceId( $i );
|
||||
$name = utf8_encode(tdGetName( $id ));
|
||||
printf("%s - %s\n", $id, $name);
|
||||
|
||||
$methods = tdMethods( $id, $allMethods );
|
||||
if ($methods & TELLDUS_TURNON) {
|
||||
echo " * TurnOn\n";
|
||||
tdTurnOn( $id );
|
||||
sleep(1);
|
||||
}
|
||||
if ($methods & TELLDUS_TURNOFF) {
|
||||
echo " * TurnOff\n";
|
||||
tdTurnOff( $id );
|
||||
sleep(1);
|
||||
}
|
||||
if ($methods & TELLDUS_BELL) {
|
||||
echo " * Bell\n";
|
||||
tdBell( $id );
|
||||
sleep(1);
|
||||
}
|
||||
if ($methods & TELLDUS_TOGGLE) {
|
||||
echo " * Toggle\n";
|
||||
}
|
||||
if ($methods & TELLDUS_DIM) {
|
||||
echo " * Dim\n";
|
||||
tdDim( $id, 128 );
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#ifndef PHP_TELLDUS_H
|
||||
#define PHP_TELLDUS_H 1
|
||||
|
||||
#define PHP_TELLDUS_VERSION "2.0.2"
|
||||
#define PHP_TELLDUS_EXTNAME "telldus"
|
||||
|
||||
PHP_MINIT_FUNCTION(telldus);
|
||||
PHP_MSHUTDOWN_FUNCTION(telldus);
|
||||
PHP_RINIT_FUNCTION(telldus);
|
||||
|
||||
PHP_FUNCTION(tdInit);
|
||||
PHP_FUNCTION(tdClose);
|
||||
|
||||
PHP_FUNCTION(tdTurnOn);
|
||||
PHP_FUNCTION(tdTurnOff);
|
||||
PHP_FUNCTION(tdBell);
|
||||
PHP_FUNCTION(tdDim);
|
||||
PHP_FUNCTION(tdLearn);
|
||||
PHP_FUNCTION(tdMethods);
|
||||
PHP_FUNCTION(tdLastSentCommand);
|
||||
PHP_FUNCTION(tdLastSentValue);
|
||||
|
||||
PHP_FUNCTION(tdGetNumberOfDevices);
|
||||
PHP_FUNCTION(tdGetDeviceId);
|
||||
PHP_FUNCTION(tdGetDeviceType);
|
||||
|
||||
PHP_FUNCTION(tdGetErrorString);
|
||||
|
||||
PHP_FUNCTION(tdGetName);
|
||||
PHP_FUNCTION(tdSetName);
|
||||
PHP_FUNCTION(tdGetProtocol);
|
||||
PHP_FUNCTION(tdSetProtocol);
|
||||
PHP_FUNCTION(tdGetModel);
|
||||
PHP_FUNCTION(tdSetModel);
|
||||
|
||||
PHP_FUNCTION(tdGetDeviceParameter);
|
||||
PHP_FUNCTION(tdSetDeviceParameter);
|
||||
|
||||
PHP_FUNCTION(tdAddDevice);
|
||||
PHP_FUNCTION(tdRemoveDevice);
|
||||
|
||||
PHP_FUNCTION(tdSendRawCommand);
|
||||
|
||||
extern zend_module_entry telldus_module_entry;
|
||||
#define phpext_telldus_ptr &telldus_module_entry
|
||||
|
||||
#endif
|
|
@ -1,401 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_telldus.h"
|
||||
#include <telldus-core.h>
|
||||
|
||||
|
||||
static function_entry telldus_functions[] = {
|
||||
PHP_FE(tdInit, NULL)
|
||||
PHP_FE(tdClose, NULL)
|
||||
|
||||
PHP_FE(tdTurnOn, NULL)
|
||||
PHP_FE(tdTurnOff, NULL)
|
||||
PHP_FE(tdBell, NULL)
|
||||
PHP_FE(tdDim, NULL)
|
||||
PHP_FE(tdLearn, NULL)
|
||||
PHP_FE(tdMethods, NULL)
|
||||
PHP_FE(tdLastSentCommand, NULL)
|
||||
PHP_FE(tdLastSentValue, NULL)
|
||||
|
||||
PHP_FE(tdGetNumberOfDevices, NULL)
|
||||
PHP_FE(tdGetDeviceId, NULL)
|
||||
PHP_FE(tdGetDeviceType, NULL)
|
||||
|
||||
PHP_FE(tdGetErrorString, NULL)
|
||||
|
||||
PHP_FE(tdGetName, NULL)
|
||||
PHP_FE(tdSetName, NULL)
|
||||
PHP_FE(tdGetProtocol, NULL)
|
||||
PHP_FE(tdSetProtocol, NULL)
|
||||
PHP_FE(tdGetModel, NULL)
|
||||
PHP_FE(tdSetModel, NULL)
|
||||
|
||||
PHP_FE(tdGetDeviceParameter, NULL)
|
||||
PHP_FE(tdSetDeviceParameter, NULL)
|
||||
|
||||
PHP_FE(tdAddDevice, NULL)
|
||||
PHP_FE(tdRemoveDevice, NULL)
|
||||
|
||||
PHP_FE(tdSendRawCommand, NULL)
|
||||
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
zend_module_entry telldus_module_entry = {
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
STANDARD_MODULE_HEADER,
|
||||
#endif
|
||||
PHP_TELLDUS_EXTNAME,
|
||||
telldus_functions,
|
||||
PHP_MINIT(telldus),
|
||||
PHP_MSHUTDOWN(telldus),
|
||||
PHP_RINIT(telldus),
|
||||
NULL,
|
||||
NULL,
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
PHP_TELLDUS_VERSION,
|
||||
#endif
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
#ifdef COMPILE_DL_TELLDUS
|
||||
ZEND_GET_MODULE(telldus)
|
||||
#endif
|
||||
|
||||
|
||||
PHP_RINIT_FUNCTION(telldus)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MINIT_FUNCTION(telldus)
|
||||
{
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_TURNON", TELLSTICK_TURNON, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_TURNOFF", TELLSTICK_TURNOFF, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_BELL", TELLSTICK_BELL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_TOGGLE", TELLSTICK_TOGGLE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_DIM", TELLSTICK_DIM, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_LEARN", TELLSTICK_LEARN, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_SUCCESS", TELLSTICK_SUCCESS, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_NOT_FOUND", TELLSTICK_ERROR_NOT_FOUND, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_PERMISSION_DENIED", TELLSTICK_ERROR_PERMISSION_DENIED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_DEVICE_NOT_FOUND", TELLSTICK_ERROR_DEVICE_NOT_FOUND, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_METHOD_NOT_SUPPORTED", TELLSTICK_ERROR_METHOD_NOT_SUPPORTED, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_COMMUNICATION", TELLSTICK_ERROR_COMMUNICATION, CONST_CS | CONST_PERSISTENT);
|
||||
//REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_CONNECTING_SERVICE", TELLSTICK_ERROR_CONNECTING_SERVICE, CONST_CS | CONST_PERSISTENT);
|
||||
//REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_UNKNOWN_RESPONSE", TELLSTICK_ERROR_UNKNOWN_RESPONSE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_ERROR_UNKNOWN", TELLSTICK_ERROR_UNKNOWN, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_TYPE_DEVICE", TELLSTICK_TYPE_DEVICE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("TELLSTICK_TYPE_GROUP", TELLSTICK_TYPE_GROUP, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_MSHUTDOWN_FUNCTION(telldus)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdInit)
|
||||
{
|
||||
tdInit();
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdClose)
|
||||
{
|
||||
tdClose();
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdTurnOn)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdTurnOn( id ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdTurnOff)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdTurnOff( id ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdBell)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdBell( id ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdDim)
|
||||
{
|
||||
long id;
|
||||
long level;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &id, &level) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
if (level < 0 || level > 255) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdDim( id, level ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdLearn)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdLearn( id ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdMethods)
|
||||
{
|
||||
long id;
|
||||
long supportedMethods;
|
||||
long methods;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &id, &supportedMethods) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
methods = tdMethods( id, supportedMethods );
|
||||
RETURN_LONG(methods);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdLastSentCommand)
|
||||
{
|
||||
long id;
|
||||
long supportedMethods;
|
||||
long command;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &id, &supportedMethods) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
command = tdLastSentCommand( id, supportedMethods );
|
||||
RETURN_LONG(command);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdLastSentValue)
|
||||
{
|
||||
long id;
|
||||
char *value, *retval;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
value = tdLastSentValue( id );
|
||||
retval = estrdup(value);
|
||||
tdReleaseString(value);
|
||||
RETURN_STRING(retval, 0);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetNumberOfDevices)
|
||||
{
|
||||
int nbr = tdGetNumberOfDevices();
|
||||
RETURN_LONG(nbr);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetDeviceId)
|
||||
{
|
||||
long index;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &index) == FAILURE) {
|
||||
RETURN_LONG(0);
|
||||
}
|
||||
|
||||
RETURN_LONG( tdGetDeviceId( index ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetDeviceType)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_LONG(0);
|
||||
}
|
||||
|
||||
RETURN_LONG( tdGetDeviceType( id ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetErrorString)
|
||||
{
|
||||
long errorNo;
|
||||
char *errorString, *retval;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &errorNo) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
errorString = tdGetErrorString( errorNo );
|
||||
retval = estrdup(errorString);
|
||||
tdReleaseString(errorString);
|
||||
RETURN_STRING( retval, 0 );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetName)
|
||||
{
|
||||
long id;
|
||||
char *name, *retval;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
name = tdGetName( id );
|
||||
retval = estrdup(name);
|
||||
tdReleaseString(name);
|
||||
RETURN_STRING( retval, 0 );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdSetName)
|
||||
{
|
||||
long id;
|
||||
char *name;
|
||||
int nameLen;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &id, &name, &nameLen) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdSetName( id, name ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetProtocol)
|
||||
{
|
||||
long id;
|
||||
char *protocol, *retval;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
protocol = tdGetProtocol( id );
|
||||
retval = estrdup(protocol);
|
||||
tdReleaseString(protocol);
|
||||
RETURN_STRING( retval, 0 );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdSetProtocol)
|
||||
{
|
||||
long id;
|
||||
char *protocol;
|
||||
int protocolLen;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &id, &protocol, &protocolLen) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdSetProtocol( id, protocol ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetModel)
|
||||
{
|
||||
long id;
|
||||
char *model, *retval;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &id) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
model = tdGetModel( id );
|
||||
retval = estrdup(model);
|
||||
tdReleaseString(model);
|
||||
RETURN_STRING( retval, 0 );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdSetModel)
|
||||
{
|
||||
long id;
|
||||
char *model;
|
||||
int modelLen;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &id, &model, &modelLen) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdSetModel( id, model ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdGetDeviceParameter)
|
||||
{
|
||||
long id;
|
||||
char *param, *name, *defaultValue, *retval;
|
||||
int nameLen, defaultValueLen;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lss", &id, &name, &nameLen, &defaultValue, &defaultValueLen) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
param = tdGetDeviceParameter( id, name, defaultValue );
|
||||
retval = estrdup(param);
|
||||
tdReleaseString(param);
|
||||
RETURN_STRING( retval, 0 );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdSetDeviceParameter)
|
||||
{
|
||||
long id;
|
||||
char *name, *value;
|
||||
int nameLen, valueLen;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lss", &id, &name, &nameLen, &value, &valueLen) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL( tdSetDeviceParameter( id, name, value ) );
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdAddDevice)
|
||||
{
|
||||
RETURN_LONG(tdAddDevice());
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdRemoveDevice)
|
||||
{
|
||||
long deviceId;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &deviceId) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL(tdRemoveDevice(deviceId));
|
||||
}
|
||||
|
||||
PHP_FUNCTION(tdSendRawCommand)
|
||||
{
|
||||
char *command;
|
||||
int commandLen;
|
||||
long reserved = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &command, &commandLen, &reserved) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_LONG(tdSendRawCommand(command, reserved));
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
include telldus.c
|
||||
include telldus-core.h
|
||||
recursive-include example/*
|
|
@ -1,47 +0,0 @@
|
|||
|
||||
import telldus
|
||||
import time
|
||||
|
||||
telldus.tdInit()
|
||||
devices = telldus.tdGetNumberOfDevices()
|
||||
print "Devices: %d\n" % devices
|
||||
|
||||
allMethods = telldus.TELLSTICK_TURNON | telldus.TELLSTICK_TURNOFF | telldus.TELLSTICK_BELL | telldus.TELLSTICK_DIM
|
||||
|
||||
for i in xrange(devices):
|
||||
deviceid = telldus.tdGetDeviceId(i)
|
||||
|
||||
if deviceid:
|
||||
name = telldus.tdGetName(deviceid)
|
||||
|
||||
print "%s - %s\n" % (deviceid, name)
|
||||
|
||||
methods = telldus.tdMethods(deviceid, allMethods)
|
||||
|
||||
if methods & telldus.TELLSTICK_TURNON:
|
||||
print " * TurnOn\n"
|
||||
telldus.tdTurnOn(deviceid)
|
||||
time.sleep(1)
|
||||
|
||||
if methods & telldus.TELLSTICK_TURNOFF:
|
||||
print " * TurnOff\n"
|
||||
telldus.tdTurnOff(deviceid)
|
||||
time.sleep(1)
|
||||
|
||||
if methods & telldus.TELLSTICK_BELL:
|
||||
print " * Bell\n"
|
||||
telldus.tdBell(deviceid)
|
||||
time.sleep(1)
|
||||
|
||||
if methods & telldus.TELLSTICK_TOGGLE:
|
||||
print " * Toggle\n"
|
||||
|
||||
if methods & telldus.TELLSTICK_DIM:
|
||||
print " * Dim\n"
|
||||
telldus.tdDim(deviceid, 128)
|
||||
time.sleep(1)
|
||||
|
||||
telldus.tdClose()
|
||||
|
||||
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import threading
|
||||
import telldus
|
||||
import time
|
||||
|
||||
telldus.tdInit()
|
||||
|
||||
def turnOn():
|
||||
print "turning on"
|
||||
telldus.tdTurnOn(1)
|
||||
|
||||
def turnOff():
|
||||
print "turning off"
|
||||
telldus.tdTurnOff(1)
|
||||
|
||||
def callback(deviceId, method, value, callbackId):
|
||||
print "callback"
|
||||
print "DeviceId: %i Method: %i Value: %s" % (deviceId, method, value)
|
||||
return True
|
||||
|
||||
#function to be called when device event occurs, even for unregistered devices
|
||||
def rawcallback(data, controllerId, callbackId):
|
||||
print "raw callback"
|
||||
print "Data: %s ControllerId: %i" % (data, controllerId)
|
||||
return True
|
||||
|
||||
callbackid = telldus.tdRegisterDeviceEvent(callback)
|
||||
rawcallbackid = telldus.tdRegisterRawDeviceEvent(rawcallback)
|
||||
|
||||
print callbackid, rawcallbackid
|
||||
|
||||
try:
|
||||
while(1):
|
||||
time.sleep(0.5) #don't exit
|
||||
except KeyboardInterrupt:
|
||||
print "Exiting"
|
||||
telldus.tdUnregisterCallback(callbackid)
|
||||
telldus.tdUnregisterCallback(rawcallbackid)
|
||||
telldus.tdClose()
|
|
@ -1,28 +0,0 @@
|
|||
import telldus
|
||||
|
||||
telldus.tdInit()
|
||||
|
||||
while True:
|
||||
result = telldus.tdSensor()
|
||||
if not isinstance(result, tuple):
|
||||
break
|
||||
else:
|
||||
protocol, model, sensorId, dataTypes = result
|
||||
print "Protocol: %s,\tModel: %s,\tSensorId: %i\nDataTypes: %i" % (protocol, model, sensorId, dataTypes)
|
||||
|
||||
# Retrieve the values the sensor supports
|
||||
if dataTypes & telldus.TELLSTICK_TEMPERATURE:
|
||||
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_TEMPERATURE)
|
||||
if isinstance(result, tuple):
|
||||
value, timestamp = result
|
||||
print "Temperature:\t%sC\t(%s)\n" % (value, str(timestamp))
|
||||
|
||||
if dataTypes & telldus.TELLSTICK_HUMIDITY:
|
||||
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_HUMIDITY)
|
||||
if isinstance(result, tuple):
|
||||
value, timestamp = result
|
||||
print "Humidity:\t%s\t(%s)\n" % (value, str(timestamp))
|
||||
|
||||
print "\n"
|
||||
|
||||
telldus.tdClose()
|
|
@ -1,345 +0,0 @@
|
|||
import sys
|
||||
from distutils.core import setup, Extension
|
||||
|
||||
DEBUG = True
|
||||
|
||||
PLATFORM_IS_WINDOWS = sys.platform.lower().startswith('win')
|
||||
|
||||
if PLATFORM_IS_WINDOWS:
|
||||
|
||||
__doc__="""This is a distutils setup-script for the telldus extension
|
||||
|
||||
To build the telldus extensions, simply execute:
|
||||
python setup.py -q build
|
||||
or
|
||||
python setup.py -q install
|
||||
to build and install into your current Python installation.
|
||||
|
||||
These extensions require a number of libraries to build, some of which may
|
||||
require you to install special SDKs or toolkits. This script will attempt
|
||||
to build as many as it can, and at the end of the build will report any
|
||||
extension modules that could not be built and why.
|
||||
|
||||
This has got complicated due to the various different versions of
|
||||
Visual Studio used - some VS versions are not compatible with some SDK
|
||||
versions. Below are the Windows SDK versions required (and the URL - although
|
||||
these are subject to being changed by MS at any time:)
|
||||
|
||||
Python 2.6+:
|
||||
|
||||
Build using Microsoft Visual Studio 2008 Express Edition:
|
||||
http://www.microsoft.com/en-us/download/details.aspx?id=6506
|
||||
http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/
|
||||
http://www.cppblog.com/Files/xcpp/VCE64BIT_WIN7SDK.zip
|
||||
|
||||
For 32bit build:
|
||||
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5
|
||||
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b
|
||||
Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvars32.bat to
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
|
||||
|
||||
For 64bit build:
|
||||
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (ISO) GRMSDKX_EN_DVD.iso
|
||||
http://www.microsoft.com/en-us/download/details.aspx?id=18950
|
||||
Copy C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvars64.bat to
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
|
||||
|
||||
Python 2.3->2.5:
|
||||
|
||||
Microsoft Windows Software Development Kit Update for Windows Vista (version 6.0)
|
||||
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=4377f86d-c913-4b5c-b87e-ef72e5b4e065
|
||||
** If you want to build Python 2.3, be sure to install the SDK compilers
|
||||
too - although we don't use them, this setup option installs some .lib
|
||||
files we do need.
|
||||
**
|
||||
|
||||
If you multiple SDK versions on a single machine, set the MSSDK environment
|
||||
variable to point at the one you want to use. Note that using the SDK for
|
||||
a particular platform (eg, Windows 7) doesn't force you to use that OS as your
|
||||
build environment. If the links above don't work, use google to find them.
|
||||
|
||||
Building:
|
||||
---------
|
||||
|
||||
To install the telldus extension, execute:
|
||||
python setup.py -q install
|
||||
|
||||
This will install the built extensions into your site-packages directory,
|
||||
create an appropriate .pth file, and should leave everything ready to use.
|
||||
There is no need to modify the registry.
|
||||
|
||||
To build or install debug (_d) versions of these extensions, ensure you have
|
||||
built or installed a debug version of Python itself, then pass the "--debug"
|
||||
flag to the build command - eg:
|
||||
python setup.py -q build --debug
|
||||
or to build and install a debug version:
|
||||
python setup.py -q build --debug install
|
||||
|
||||
To build 64bit versions of this:
|
||||
|
||||
* py2.5 and earlier - sorry, I've given up in disgust. Using VS2003 with
|
||||
the Vista SDK is just too painful to make work, and VS2005 is not used for
|
||||
any released versions of Python. See revision 1.69 of this file for the
|
||||
last version that attempted to support and document this process.
|
||||
|
||||
* 2.6 and later: On a 64bit OS, just build as you would on a 32bit platform.
|
||||
On a 32bit platform (ie, to cross-compile), you must use VS2008 to
|
||||
cross-compile Python itself. Note that by default, the 64bit tools are not
|
||||
installed with VS2008, so you may need to adjust your VS2008 setup (see "For 64bit build"). Then
|
||||
use:
|
||||
vcs
|
||||
setup.py build --plat-name=win-amd64
|
||||
|
||||
see the distutils cross-compilation documentation for more details.
|
||||
"""
|
||||
# Originally by Thomas Heller, started in 2000 or so.
|
||||
import os
|
||||
import shutil
|
||||
|
||||
is_py3k = sys.version_info > (3,) # get this out of the way early on...
|
||||
# We have special handling for _winreg so our setup3.py script can avoid
|
||||
# using the 'imports' fixer and therefore start much faster...
|
||||
if is_py3k:
|
||||
import winreg as _winreg
|
||||
else:
|
||||
import _winreg
|
||||
|
||||
try:
|
||||
from distutils import log
|
||||
except ImportError:
|
||||
class Log:
|
||||
def debug(self, msg, *args):
|
||||
print msg % args
|
||||
def info(self, msg, *args):
|
||||
print msg % args
|
||||
log = Log()
|
||||
|
||||
try:
|
||||
this_file = __file__
|
||||
except NameError:
|
||||
this_file = sys.argv[0]
|
||||
|
||||
this_file = os.path.abspath(this_file)
|
||||
# We get upset if the cwd is not our source dir, but it is a PITA to
|
||||
# insist people manually CD there first!
|
||||
if os.path.dirname(this_file):
|
||||
os.chdir(os.path.dirname(this_file))
|
||||
|
||||
|
||||
# We need to know the platform SDK dir before we can list the extensions.
|
||||
def find_platform_sdk_dir():
|
||||
# Finding the Platform SDK install dir is a treat. There can be some
|
||||
# dead ends so we only consider the job done if we find the "windows.h"
|
||||
# landmark.
|
||||
landmark = "include\\windows.h"
|
||||
# 1. The use might have their current environment setup for the
|
||||
# SDK, in which case the "MSSdk" env var is set.
|
||||
sdkdir = os.environ.get("MSSdk")
|
||||
if sdkdir:
|
||||
if DEBUG:
|
||||
print "PSDK: try %%MSSdk%%: '%s'" % sdkdir
|
||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||
return sdkdir
|
||||
# 2. The "Install Dir" value in the
|
||||
# HKLM\Software\Microsoft\MicrosoftSDK\Directories registry key
|
||||
# sometimes points to the right thing. However, after upgrading to
|
||||
# the "Platform SDK for Windows Server 2003 SP1" this is dead end.
|
||||
try:
|
||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||
r"Software\Microsoft\MicrosoftSDK\Directories")
|
||||
sdkdir, ignore = _winreg.QueryValueEx(key, "Install Dir")
|
||||
except EnvironmentError:
|
||||
pass
|
||||
else:
|
||||
if DEBUG:
|
||||
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\
|
||||
"\Directories\Install Dir': '%s'" % sdkdir
|
||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||
return sdkdir
|
||||
# 3. Each installed SDK (not just the platform SDK) seems to have GUID
|
||||
# subkey of HKLM\Software\Microsoft\MicrosoftSDK\InstalledSDKs and
|
||||
# it *looks* like the latest installed Platform SDK will be the
|
||||
# only one with an "Install Dir" sub-value.
|
||||
try:
|
||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||
r"Software\Microsoft\MicrosoftSDK\InstalledSDKs")
|
||||
i = 0
|
||||
while True:
|
||||
guid = _winreg.EnumKey(key, i)
|
||||
guidkey = _winreg.OpenKey(key, guid)
|
||||
try:
|
||||
sdkdir, ignore = _winreg.QueryValueEx(guidkey, "Install Dir")
|
||||
except EnvironmentError:
|
||||
pass
|
||||
else:
|
||||
if DEBUG:
|
||||
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDK"\
|
||||
"\InstallSDKs\%s\Install Dir': '%s'"\
|
||||
% (guid, sdkdir)
|
||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||
return sdkdir
|
||||
i += 1
|
||||
except EnvironmentError:
|
||||
pass
|
||||
# 4. Vista's SDK
|
||||
try:
|
||||
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
|
||||
r"Software\Microsoft\Microsoft SDKs\Windows")
|
||||
sdkdir, ignore = _winreg.QueryValueEx(key, "CurrentInstallFolder")
|
||||
except EnvironmentError:
|
||||
pass
|
||||
else:
|
||||
if DEBUG:
|
||||
print r"PSDK: try 'HKLM\Software\Microsoft\MicrosoftSDKs"\
|
||||
"\Windows\CurrentInstallFolder': '%s'" % sdkdir
|
||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||
return sdkdir
|
||||
|
||||
# 5. Failing this just try a few well-known default install locations.
|
||||
progfiles = os.environ.get("ProgramFiles", r"C:\Program Files")
|
||||
defaultlocs = [
|
||||
os.path.join(progfiles, "Microsoft Platform SDK"),
|
||||
os.path.join(progfiles, "Microsoft SDK"),
|
||||
]
|
||||
for sdkdir in defaultlocs:
|
||||
if DEBUG:
|
||||
print "PSDK: try default location: '%s'" % sdkdir
|
||||
if os.path.isfile(os.path.join(sdkdir, landmark)):
|
||||
return sdkdir
|
||||
|
||||
|
||||
# Some nasty hacks to prevent most of our extensions using a manifest, as
|
||||
# the manifest - even without a reference to the CRT assembly - is enough
|
||||
# to prevent the extension from loading. For more details, see
|
||||
# http://bugs.python.org/issue7833 - that issue has a patch, but it is
|
||||
# languishing and will probably never be fixed for Python 2.6...
|
||||
if sys.version_info > (2,6):
|
||||
from distutils.spawn import spawn
|
||||
from distutils.msvc9compiler import MSVCCompiler
|
||||
MSVCCompiler._orig_spawn = MSVCCompiler.spawn
|
||||
MSVCCompiler._orig_link = MSVCCompiler.link
|
||||
|
||||
# We need to override this method for versions where issue7833 *has* landed
|
||||
# (ie, 2.7 and 3.2+)
|
||||
def manifest_get_embed_info(self, target_desc, ld_args):
|
||||
_want_assembly_kept = getattr(self, '_want_assembly_kept', False)
|
||||
if not _want_assembly_kept:
|
||||
return None
|
||||
for arg in ld_args:
|
||||
if arg.startswith("/MANIFESTFILE:"):
|
||||
orig_manifest = arg.split(":", 1)[1]
|
||||
if target_desc==self.EXECUTABLE:
|
||||
rid = 1
|
||||
else:
|
||||
rid = 2
|
||||
return orig_manifest, rid
|
||||
return None
|
||||
# always monkeypatch it in even though it will only be called in 2.7
|
||||
# and 3.2+.
|
||||
MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info
|
||||
|
||||
def monkeypatched_spawn(self, cmd):
|
||||
is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
|
||||
is_mt = cmd[0].endswith("mt.exe") or cmd[0].endswith('"mt.exe"')
|
||||
_want_assembly_kept = getattr(self, '_want_assembly_kept', False)
|
||||
if not _want_assembly_kept and is_mt:
|
||||
# We don't want mt.exe run...
|
||||
return
|
||||
if not _want_assembly_kept and is_link:
|
||||
# remove /MANIFESTFILE:... and add MANIFEST:NO
|
||||
# (but note that for winxpgui, which specifies a manifest via a
|
||||
# .rc file, this is ignored by the linker - the manifest specified
|
||||
# in the .rc file is still added)
|
||||
for i in range(len(cmd)):
|
||||
if cmd[i].startswith("/MANIFESTFILE:"):
|
||||
cmd[i] = "/MANIFEST:NO"
|
||||
break
|
||||
if _want_assembly_kept and is_mt:
|
||||
# We want mt.exe run with the original manifest
|
||||
for i in range(len(cmd)):
|
||||
if cmd[i] == "-manifest":
|
||||
cmd[i+1] = cmd[i+1] + ".orig"
|
||||
break
|
||||
self._orig_spawn(cmd)
|
||||
if _want_assembly_kept and is_link:
|
||||
# We want a copy of the original manifest so we can use it later.
|
||||
for i in range(len(cmd)):
|
||||
if cmd[i].startswith("/MANIFESTFILE:"):
|
||||
mfname = cmd[i][14:]
|
||||
shutil.copyfile(mfname, mfname + ".orig")
|
||||
break
|
||||
|
||||
def monkeypatched_link(self, target_desc, objects, output_filename, *args, **kw):
|
||||
# no manifests for 3.3+
|
||||
self._want_assembly_kept = sys.version_info < (3,3) and \
|
||||
(os.path.basename(output_filename).startswith("PyISAPI_loader.dll") or \
|
||||
os.path.basename(output_filename).startswith("perfmondata.dll") or \
|
||||
os.path.basename(output_filename).startswith("win32ui.pyd") or \
|
||||
target_desc==self.EXECUTABLE)
|
||||
try:
|
||||
return self._orig_link(target_desc, objects, output_filename, *args, **kw)
|
||||
finally:
|
||||
delattr(self, '_want_assembly_kept')
|
||||
MSVCCompiler.spawn = monkeypatched_spawn
|
||||
MSVCCompiler.link = monkeypatched_link
|
||||
|
||||
def find_telldus_dev_dir():
|
||||
landmark = "telldus-core.h"
|
||||
dev_dir = os.environ.get("TELLDUS_DEVDIR")
|
||||
if dev_dir:
|
||||
if DEBUG:
|
||||
print "Telldus dev dir:" % dev_dir
|
||||
if os.path.isfile(os.path.join(dev_dir, landmark)):
|
||||
return dev_dir
|
||||
|
||||
progfiles = os.environ.get("ProgramFiles", r"C:\Program Files")
|
||||
defaultlocs = [
|
||||
os.path.join(progfiles + ' (x86)', "Telldus", "Development"),
|
||||
os.path.join(progfiles, "Telldus", "Development"),
|
||||
]
|
||||
for dev_dir in defaultlocs:
|
||||
if DEBUG:
|
||||
print "Telldus dev dir: '%s'" % dev_dir
|
||||
if os.path.isfile(os.path.join(dev_dir, landmark)):
|
||||
return dev_dir
|
||||
if DEBUG:
|
||||
print "Telldus dev dir not found, make sure dev code is installed. Or set TELLDUS_DEVDIR."
|
||||
|
||||
sdk_dir = find_platform_sdk_dir()
|
||||
sdk_include_dir = os.path.join(sdk_dir, 'Include')
|
||||
|
||||
telldus_dev_dir = find_telldus_dev_dir()
|
||||
telldus_platform = os.environ.get("TELLDUS_PLATFORM", 'x86_64')
|
||||
telldus_library_dir = os.path.join(telldus_dev_dir, telldus_platform)
|
||||
|
||||
include_dirs = [sdk_include_dir, telldus_dev_dir]
|
||||
library_dirs = [telldus_library_dir]
|
||||
libraries = ['python%i%i' % (sys.version_info[0], sys.version_info[1]) , 'TelldusCore']
|
||||
define_macros = [('_WINDOWS', 1)]
|
||||
|
||||
else:
|
||||
include_dirs = ['/usr/include', '/usr/local/include']
|
||||
library_dirs = ['/usr/lib', '/usr/local/lib']
|
||||
libraries = ['telldus-core']
|
||||
define_macros = []
|
||||
|
||||
define_macros.extend([('DATA_LENGTH', 20), ('CALLBACK_LENGTH', 20)])
|
||||
|
||||
telldus = Extension(
|
||||
'telldus',
|
||||
include_dirs = include_dirs,
|
||||
libraries = libraries,
|
||||
library_dirs = library_dirs,
|
||||
define_macros = define_macros,
|
||||
sources = ['telldus.c']
|
||||
)
|
||||
|
||||
setup(
|
||||
name = 'telldus',
|
||||
version = '1.0',
|
||||
description = 'Python bindings for telldus',
|
||||
author='Oyvind Saltvik',
|
||||
author_email='oyvind.saltvik@gmail.com',
|
||||
url='http://github.com/fivethreeo/telldus/',
|
||||
ext_modules = [telldus]
|
||||
)
|
|
@ -1,843 +0,0 @@
|
|||
#include "Python.h"
|
||||
#include "datetime.h"
|
||||
#include <telldus-core.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* estrdup.c -- duplicate a string, die if error
|
||||
*
|
||||
* char *string;
|
||||
* char *newstring;
|
||||
* newstring = estrdup(string);
|
||||
*
|
||||
* estrdup returns a copy of its argument, located in memory
|
||||
* allocated from the heap. If it is unable to allocate the
|
||||
* necessary memory, estrdup executes PyErr_NoMemory();
|
||||
* (Generally, the routine error is not expected to return,
|
||||
* but if it does, estrdup will return NULL.)
|
||||
*/
|
||||
|
||||
int callbackLen = 0;
|
||||
|
||||
typedef struct {
|
||||
PyObject *func;
|
||||
int callbackId;
|
||||
} callbackInfo;
|
||||
|
||||
static callbackInfo callbackList[CALLBACK_LENGTH];
|
||||
|
||||
void
|
||||
addCallback(PyObject *func, int callbackId)
|
||||
{
|
||||
if (callbackLen < CALLBACK_LENGTH) {
|
||||
callbackList[callbackLen].func = func;
|
||||
callbackList[callbackLen].callbackId = callbackId;
|
||||
callbackLen++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
removeCallback(int callbackId)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < callbackLen; i++)
|
||||
{
|
||||
if (callbackList[i].callbackId == callbackId)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
if (!(index == -1)) {
|
||||
for (j = index; j < callbackLen - 1; j++)
|
||||
{
|
||||
callbackList[j] = callbackList[j+1];
|
||||
}
|
||||
callbackLen--;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
hasCallback(int callbackId)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < callbackLen; i++)
|
||||
{
|
||||
if (callbackList[i].callbackId == callbackId)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
PyObject *
|
||||
getCallback(int callbackId)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < callbackLen; i++)
|
||||
{
|
||||
if (callbackList[i].callbackId == callbackId)
|
||||
{
|
||||
return callbackList[i].func;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
estrdup(char *s)
|
||||
{
|
||||
register char *t;
|
||||
|
||||
if (NULL == (t = malloc(strlen(s)+1))) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
strcpy(t, s);
|
||||
return(t);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdInit(PyObject *self)
|
||||
{
|
||||
tdInit();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdClose(PyObject *self)
|
||||
{
|
||||
tdClose();
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdTurnOn(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdTurnOn(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdTurnOff(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdTurnOff(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdBell(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdBell(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdDim(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
unsigned char level;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lb", &id, &level))
|
||||
return NULL;
|
||||
|
||||
if (level < 0 || level > 255)
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdDim(id, level));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdLearn(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdLearn(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdMethods(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
long supportedmethods;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ll", &id, &supportedmethods))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdMethods(id, supportedmethods));
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
telldus_tdLastSentCommand(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
long supportedmethods;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ll", &id, &supportedmethods))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdLastSentCommand(id, supportedmethods));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdLastSentValue(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* value;
|
||||
char* retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
value = tdLastSentValue(id);
|
||||
retval = estrdup(value);
|
||||
tdReleaseString(value);
|
||||
return PyString_FromString(retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetNumberOfDevices(PyObject *self)
|
||||
{
|
||||
return PyLong_FromLong((long) tdGetNumberOfDevices());
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetDeviceId(PyObject *self, PyObject *args)
|
||||
{
|
||||
long index;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &index))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdGetDeviceId(index));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetDeviceType(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdGetDeviceType(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetErrorString(PyObject *self, PyObject *args)
|
||||
{
|
||||
long errorno;
|
||||
char* errorString;
|
||||
char* retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &errorno))
|
||||
return NULL;
|
||||
|
||||
errorString = tdGetErrorString(errorno);
|
||||
retval = estrdup(errorString);
|
||||
tdReleaseString(errorString);
|
||||
return PyString_FromString(retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetName(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* name;
|
||||
char* retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
name = tdGetName(id);
|
||||
retval = estrdup(name);
|
||||
tdReleaseString(name);
|
||||
return PyString_FromString(retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSetName(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* name;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ls", &id, &name))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdSetName(id, name));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetProtocol(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* protocol;
|
||||
char* retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
protocol = tdGetProtocol(id);
|
||||
retval = estrdup(protocol);
|
||||
tdReleaseString(protocol);
|
||||
return PyString_FromString(retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSetProtocol(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* protocol;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ls", &id, &protocol))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdSetProtocol(id, protocol));
|
||||
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetModel(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* model;
|
||||
char* retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
model = tdGetModel(id);
|
||||
retval = estrdup(model);
|
||||
tdReleaseString(model);
|
||||
return PyString_FromString(retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSetModel(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* model;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ls", &id, &model))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdSetProtocol(id, model));
|
||||
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdGetDeviceParameter(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* name;
|
||||
char* defaultValue;
|
||||
char* param;
|
||||
char* retval;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lss", &id, &name, &defaultValue))
|
||||
return NULL;
|
||||
|
||||
param = tdGetDeviceParameter(id, name, defaultValue);
|
||||
retval = estrdup(param);
|
||||
tdReleaseString(param);
|
||||
return PyString_FromString(retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSetDeviceParameter(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
char* name;
|
||||
char* value;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "lss", &id, &name, &value))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdSetDeviceParameter(id, name, value));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdAddDevice(PyObject *self)
|
||||
{
|
||||
return PyLong_FromLong((long) tdAddDevice());
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdRemoveDevice(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdRemoveDevice(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSendRawCommand(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *command;
|
||||
long reserved = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|l", &command, &reserved));
|
||||
return NULL;
|
||||
|
||||
return PyLong_FromLong((long) tdSendRawCommand(command, reserved));
|
||||
}
|
||||
|
||||
static PyObject *DeviceEventCallback = NULL;
|
||||
|
||||
void
|
||||
telldus_deviceEventCallback(int deviceId, int method, const char *data, int callbackId, int context)
|
||||
{
|
||||
|
||||
PyObject * result;
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
// now call the Python callback function
|
||||
result = PyObject_CallFunction(DeviceEventCallback, "llsl", deviceId, method, data, callbackId);
|
||||
|
||||
if (result == NULL) {
|
||||
// something went wrong so print to stderr
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
// take care of reference handling
|
||||
Py_XDECREF(result);
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdRegisterDeviceEvent(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
||||
int result;
|
||||
PyObject *func;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O:tdRegisterDeviceEvent", &func)) {
|
||||
PyErr_SetString(PyExc_StandardError, "Parse error!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func)) {
|
||||
// Error
|
||||
PyErr_SetString(PyExc_StandardError, "The object should be callable!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_XDECREF(DeviceEventCallback);
|
||||
// stick around till we need you
|
||||
Py_XINCREF(func);
|
||||
|
||||
DeviceEventCallback = func;
|
||||
|
||||
result = tdRegisterDeviceEvent((TDDeviceEvent) &telldus_deviceEventCallback, 0);
|
||||
|
||||
addCallback(func, result);
|
||||
|
||||
return PyLong_FromLong((long) result);
|
||||
}
|
||||
|
||||
static PyObject *DeviceChangeEventCallback = NULL;
|
||||
|
||||
void
|
||||
telldus_deviceChangeEventCallback(int deviceId, int changeEvent, int changeType, int callbackId, int context)
|
||||
{
|
||||
PyObject * result;
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
// now call the Python callback function
|
||||
result = PyObject_CallFunction(DeviceChangeEventCallback, "llll", deviceId, changeEvent, changeType, callbackId);
|
||||
|
||||
if (result == NULL) {
|
||||
// something went wrong so print to stderr
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
// take care of reference handling
|
||||
Py_XDECREF(result);
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdRegisterDeviceChangeEvent(PyObject *self, PyObject *args)
|
||||
{
|
||||
int result;
|
||||
PyObject *func;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &func)) {
|
||||
PyErr_SetString(PyExc_StandardError, "Parse error!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func)) {
|
||||
// Error
|
||||
PyErr_SetString(PyExc_StandardError, "The object should be callable!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_XDECREF(DeviceChangeEventCallback);
|
||||
// stick around till we need you
|
||||
Py_XINCREF(func);
|
||||
|
||||
DeviceChangeEventCallback = func;
|
||||
|
||||
result = tdRegisterDeviceChangeEvent((TDDeviceChangeEvent) &telldus_deviceChangeEventCallback, 0);
|
||||
|
||||
addCallback(func, result);
|
||||
|
||||
return PyLong_FromLong((long) result);
|
||||
}
|
||||
|
||||
static PyObject *RawDeviceEventCallback = NULL;
|
||||
|
||||
void
|
||||
telldus_rawDeviceEventCallback(const char *data, int controllerId, int callbackId, int context)
|
||||
{
|
||||
PyObject * result;
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
// now call the Python callback function
|
||||
result = PyObject_CallFunction(RawDeviceEventCallback, "sll", data, controllerId, callbackId);
|
||||
|
||||
if (result == NULL) {
|
||||
// something went wrong so print to stderr
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
// take care of reference handling
|
||||
Py_XDECREF(result);
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdRegisterRawDeviceEvent(PyObject *self, PyObject *args)
|
||||
{
|
||||
int result;
|
||||
PyObject *func;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &func)) {
|
||||
PyErr_SetString(PyExc_StandardError, "Parse error!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func)) {
|
||||
// Error
|
||||
PyErr_SetString(PyExc_StandardError, "The object should be callable!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_XDECREF(RawDeviceEventCallback);
|
||||
// stick around till we need you
|
||||
Py_XINCREF(func);
|
||||
|
||||
RawDeviceEventCallback = func;
|
||||
|
||||
result = tdRegisterRawDeviceEvent((TDRawDeviceEvent) &telldus_rawDeviceEventCallback, 0);
|
||||
|
||||
addCallback(func, result);
|
||||
|
||||
return PyLong_FromLong((long) result);
|
||||
}
|
||||
|
||||
static PyObject *SensorEventCallback = NULL;
|
||||
|
||||
void
|
||||
telldus_sensorEventCallback(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, int context)
|
||||
{
|
||||
PyObject * result;
|
||||
PyGILState_STATE gstate = PyGILState_Ensure();
|
||||
|
||||
// now call the Python callback function
|
||||
result = PyObject_CallFunction(SensorEventCallback, "ssllsll", protocol, model, id, dataType, value, timestamp, callbackId);
|
||||
|
||||
if (result == NULL) {
|
||||
// something went wrong so print to stderr
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
// take care of reference handling
|
||||
Py_XDECREF(result);
|
||||
|
||||
PyGILState_Release(gstate);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdRegisterSensorEvent(PyObject *self, PyObject *args)
|
||||
{
|
||||
int result;
|
||||
PyObject *func;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &func)) {
|
||||
PyErr_SetString(PyExc_StandardError, "Parse error!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(func)) {
|
||||
// Error
|
||||
PyErr_SetString(PyExc_StandardError, "The object should be callable!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_XDECREF(SensorEventCallback);
|
||||
// stick around till we need you
|
||||
Py_XINCREF(func);
|
||||
|
||||
SensorEventCallback = func;
|
||||
|
||||
result = tdRegisterSensorEvent((TDSensorEvent) &telldus_sensorEventCallback, 0);
|
||||
|
||||
addCallback(func, result);
|
||||
|
||||
return PyLong_FromLong((long) result);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdUnregisterCallback(PyObject *self, PyObject *args)
|
||||
{
|
||||
long id;
|
||||
PyObject *callback;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "l", &id))
|
||||
return NULL;
|
||||
|
||||
if (hasCallback(id) == 1) {
|
||||
callback = getCallback(id);
|
||||
Py_DECREF(callback);
|
||||
removeCallback(id);
|
||||
}
|
||||
|
||||
return PyLong_FromLong((long) tdUnregisterCallback(id));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSensor(PyObject *self, PyObject *args)
|
||||
{
|
||||
char protocol[DATA_LENGTH];
|
||||
char model[DATA_LENGTH];
|
||||
long sensorId = 0;
|
||||
long dataTypes = 0;
|
||||
|
||||
long result;
|
||||
|
||||
result = tdSensor(protocol, DATA_LENGTH, model, DATA_LENGTH, &sensorId, &dataTypes);
|
||||
|
||||
if (result == TELLSTICK_SUCCESS)
|
||||
{
|
||||
return Py_BuildValue("ssll", protocol, model, sensorId, dataTypes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PyLong_FromLong(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
telldus_tdSensorValue(PyObject *self, PyObject *args)
|
||||
{
|
||||
char protocol[DATA_LENGTH];
|
||||
char model[DATA_LENGTH];
|
||||
long sensorId = 0;
|
||||
long dataType = 0;
|
||||
char value[DATA_LENGTH];
|
||||
long timestamp = 0;
|
||||
long result;
|
||||
|
||||
PyObject *floatObj = NULL;
|
||||
PyObject *timeTuple = NULL;
|
||||
PyObject *dateTime = NULL;
|
||||
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ssll", &protocol, &model, &sensorId, &dataType))
|
||||
return NULL;
|
||||
|
||||
result = tdSensorValue(protocol, model, sensorId, dataType, value, DATA_LENGTH, ×tamp);
|
||||
|
||||
if (result == TELLSTICK_SUCCESS)
|
||||
{
|
||||
|
||||
floatObj = PyFloat_FromDouble((double) timestamp);
|
||||
timeTuple = Py_BuildValue("(O)", floatObj);
|
||||
dateTime = PyDateTime_FromTimestamp(timeTuple);
|
||||
|
||||
Py_DECREF(floatObj);
|
||||
Py_DECREF(timeTuple);
|
||||
|
||||
return Py_BuildValue("sO", value, dateTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PyLong_FromLong(result);
|
||||
}
|
||||
}
|
||||
|
||||
static PyMethodDef telldus_methods[] = {
|
||||
{"tdInit", (PyCFunction) telldus_tdInit, METH_NOARGS, "Initiate telldus."},
|
||||
{"tdClose", (PyCFunction) telldus_tdClose, METH_NOARGS, "Close telldus."},
|
||||
{"tdTurnOn", (PyCFunction) telldus_tdTurnOn, METH_VARARGS, "Turn on device."},
|
||||
{"tdTurnOff", (PyCFunction) telldus_tdTurnOff, METH_VARARGS, "Turn off device."},
|
||||
{"tdBell", (PyCFunction) telldus_tdBell, METH_VARARGS, "Bell device."},
|
||||
{"tdDim", (PyCFunction) telldus_tdDim, METH_VARARGS, "Dim device."},
|
||||
{"tdLearn", (PyCFunction) telldus_tdLearn, METH_VARARGS, "Learn device."},
|
||||
{"tdMethods", (PyCFunction) telldus_tdMethods, METH_VARARGS, "Methods comment."},
|
||||
{"tdLastSentCommand", (PyCFunction) telldus_tdLastSentCommand, METH_VARARGS, "LastSentCommand comment."},
|
||||
{"tdLastSentValue", (PyCFunction) telldus_tdLastSentValue, METH_VARARGS, "LastSentValue comment."},
|
||||
{"tdGetNumberOfDevices", (PyCFunction) telldus_tdGetNumberOfDevices, METH_VARARGS, "GetNumberOfDevices comment."},
|
||||
{"tdGetDeviceId", (PyCFunction) telldus_tdGetDeviceId, METH_VARARGS, "GetDeviceId comment."},
|
||||
{"tdGetDeviceType", (PyCFunction) telldus_tdGetDeviceType, METH_VARARGS, "GetDeviceType comment."},
|
||||
{"tdGetErrorString", (PyCFunction) telldus_tdGetErrorString, METH_VARARGS, "GetErrorString comment."},
|
||||
{"tdGetName", (PyCFunction) telldus_tdGetName, METH_VARARGS, "GetName comment."},
|
||||
{"tdSetName", (PyCFunction) telldus_tdSetName, METH_VARARGS, "SetName comment."},
|
||||
{"tdGetProtocol", (PyCFunction) telldus_tdGetProtocol, METH_VARARGS, "GetProtocol comment."},
|
||||
{"tdSetProtocol", (PyCFunction) telldus_tdSetProtocol, METH_VARARGS, "SetProtocol comment."},
|
||||
{"tdGetModel", (PyCFunction) telldus_tdGetModel, METH_VARARGS, "GetModel comment."},
|
||||
{"tdSetModel", (PyCFunction) telldus_tdSetModel, METH_VARARGS, "SetModel comment."},
|
||||
{"tdGetDeviceParameter", (PyCFunction) telldus_tdGetDeviceParameter, METH_VARARGS, "GetDeviceParameter comment."},
|
||||
{"tdSetDeviceParameter", (PyCFunction) telldus_tdSetDeviceParameter, METH_VARARGS, "SetDeviceParameter comment."},
|
||||
{"tdAddDevice", (PyCFunction) telldus_tdAddDevice, METH_NOARGS, "AddDevice comment."},
|
||||
{"tdRemoveDevice", (PyCFunction) telldus_tdRemoveDevice, METH_VARARGS, "RemoveDevice comment."},
|
||||
{"tdSendRawCommand", (PyCFunction) telldus_tdSendRawCommand, METH_VARARGS, "SendRawCommand comment."},
|
||||
|
||||
{"tdRegisterDeviceEvent", (PyCFunction) telldus_tdRegisterDeviceEvent, METH_VARARGS, "RegisterDeviceEvent comment."},
|
||||
{"tdRegisterDeviceChangeEvent", (PyCFunction) telldus_tdRegisterDeviceChangeEvent, METH_VARARGS, "RegisterDeviceChangeEvent comment."},
|
||||
{"tdRegisterRawDeviceEvent", (PyCFunction) telldus_tdRegisterRawDeviceEvent, METH_VARARGS, "RegisterRawDeviceEvent comment."},
|
||||
{"tdRegisterSensorEvent", (PyCFunction) telldus_tdRegisterSensorEvent, METH_VARARGS, "RegisterSensorEvent comment."},
|
||||
{"tdUnregisterCallback", (PyCFunction) telldus_tdUnregisterCallback, METH_VARARGS, "UnregisterCallback comment."},
|
||||
{"tdSensor", (PyCFunction) telldus_tdSensor, METH_NOARGS, "Sensor comment."},
|
||||
{"tdSensorValue", (PyCFunction) telldus_tdSensorValue, METH_VARARGS, "SensorValue comment."},
|
||||
|
||||
{NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
void
|
||||
inittelldus(void)
|
||||
{
|
||||
PyObject *module;
|
||||
|
||||
PyObject *TELLSTICK_TURNON_GLUE;
|
||||
PyObject *TELLSTICK_TURNOFF_GLUE;
|
||||
PyObject *TELLSTICK_BELL_GLUE;
|
||||
PyObject *TELLSTICK_TOGGLE_GLUE;
|
||||
PyObject *TELLSTICK_DIM_GLUE;
|
||||
PyObject *TELLSTICK_LEARN_GLUE;
|
||||
PyObject *TELLSTICK_SUCCESS_GLUE;
|
||||
PyObject *TELLSTICK_ERROR_NOT_FOUND_GLUE;
|
||||
PyObject *TELLSTICK_ERROR_PERMISSION_DENIED_GLUE;
|
||||
PyObject *TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE;
|
||||
PyObject *TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE;
|
||||
PyObject *TELLSTICK_ERROR_COMMUNICATION_GLUE;
|
||||
PyObject *TELLSTICK_ERROR_UNKNOWN_GLUE;
|
||||
PyObject *TELLSTICK_TYPE_DEVICE_GLUE;
|
||||
PyObject *TELLSTICK_TYPE_GROUP_GLUE;
|
||||
PyObject *TELLSTICK_TEMPERATURE_GLUE;
|
||||
PyObject *TELLSTICK_HUMIDITY_GLUE;
|
||||
|
||||
/* Create the module and add the functions */
|
||||
|
||||
module = Py_InitModule("telldus", telldus_methods);
|
||||
|
||||
TELLSTICK_TURNON_GLUE = PyLong_FromLong((long) TELLSTICK_TURNON);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_TURNON", TELLSTICK_TURNON_GLUE);
|
||||
Py_DECREF(TELLSTICK_TURNON_GLUE);
|
||||
|
||||
TELLSTICK_TURNOFF_GLUE = PyLong_FromLong((long) TELLSTICK_TURNOFF);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_TURNOFF", TELLSTICK_TURNOFF_GLUE);
|
||||
Py_DECREF(TELLSTICK_TURNOFF_GLUE);
|
||||
|
||||
TELLSTICK_BELL_GLUE = PyLong_FromLong((long) TELLSTICK_BELL);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_BELL", TELLSTICK_BELL_GLUE);
|
||||
Py_DECREF(TELLSTICK_BELL_GLUE);
|
||||
|
||||
TELLSTICK_TOGGLE_GLUE = PyLong_FromLong((long) TELLSTICK_TOGGLE);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_TOGGLE", TELLSTICK_TOGGLE_GLUE);
|
||||
Py_DECREF(TELLSTICK_TOGGLE_GLUE);
|
||||
|
||||
TELLSTICK_DIM_GLUE = PyLong_FromLong((long) TELLSTICK_DIM);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_DIM", TELLSTICK_DIM_GLUE);
|
||||
Py_DECREF(TELLSTICK_DIM_GLUE);
|
||||
|
||||
TELLSTICK_LEARN_GLUE = PyLong_FromLong((long) TELLSTICK_LEARN);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_LEARN", TELLSTICK_LEARN_GLUE);
|
||||
Py_DECREF(TELLSTICK_LEARN_GLUE);
|
||||
|
||||
TELLSTICK_SUCCESS_GLUE = PyLong_FromLong((long) TELLSTICK_SUCCESS);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_SUCCESS", TELLSTICK_SUCCESS_GLUE);
|
||||
Py_DECREF(TELLSTICK_SUCCESS_GLUE);
|
||||
|
||||
TELLSTICK_ERROR_NOT_FOUND_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_NOT_FOUND);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_NOT_FOUND", TELLSTICK_ERROR_NOT_FOUND_GLUE);
|
||||
Py_DECREF(TELLSTICK_ERROR_NOT_FOUND_GLUE);
|
||||
|
||||
TELLSTICK_ERROR_PERMISSION_DENIED_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_PERMISSION_DENIED);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_PERMISSION_DENIED", TELLSTICK_ERROR_PERMISSION_DENIED_GLUE);
|
||||
Py_DECREF(TELLSTICK_ERROR_PERMISSION_DENIED_GLUE);
|
||||
|
||||
TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_DEVICE_NOT_FOUND);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_DEVICE_NOT_FOUND", TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE);
|
||||
Py_DECREF(TELLSTICK_ERROR_DEVICE_NOT_FOUND_GLUE);
|
||||
|
||||
TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_METHOD_NOT_SUPPORTED);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_METHOD_NOT_SUPPORTED", TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE);
|
||||
Py_DECREF(TELLSTICK_ERROR_METHOD_NOT_SUPPORTED_GLUE);
|
||||
|
||||
TELLSTICK_ERROR_COMMUNICATION_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_COMMUNICATION);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_COMMUNICATION", TELLSTICK_ERROR_COMMUNICATION_GLUE);
|
||||
Py_DECREF(TELLSTICK_ERROR_COMMUNICATION_GLUE);
|
||||
|
||||
TELLSTICK_ERROR_UNKNOWN_GLUE = PyLong_FromLong((long) TELLSTICK_ERROR_UNKNOWN);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_ERROR_UNKNOWN", TELLSTICK_ERROR_UNKNOWN_GLUE);
|
||||
Py_DECREF(TELLSTICK_ERROR_UNKNOWN_GLUE);
|
||||
|
||||
TELLSTICK_TYPE_DEVICE_GLUE = PyLong_FromLong((long) TELLSTICK_TYPE_DEVICE);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_TYPE_DEVICE", TELLSTICK_TYPE_DEVICE_GLUE);
|
||||
Py_DECREF(TELLSTICK_TYPE_DEVICE_GLUE);
|
||||
|
||||
TELLSTICK_TYPE_GROUP_GLUE = PyLong_FromLong((long) TELLSTICK_TYPE_GROUP);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_TYPE_GROUP", TELLSTICK_TYPE_GROUP_GLUE);
|
||||
Py_DECREF(TELLSTICK_TYPE_GROUP_GLUE);
|
||||
|
||||
TELLSTICK_TEMPERATURE_GLUE = PyLong_FromLong((long) TELLSTICK_TEMPERATURE);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_TEMPERATURE", TELLSTICK_TEMPERATURE_GLUE);
|
||||
Py_DECREF(TELLSTICK_TEMPERATURE_GLUE);
|
||||
|
||||
TELLSTICK_HUMIDITY_GLUE = PyLong_FromLong((long) TELLSTICK_HUMIDITY);
|
||||
PyObject_SetAttrString(module, "TELLSTICK_HUMIDITY", TELLSTICK_HUMIDITY_GLUE);
|
||||
Py_DECREF(TELLSTICK_HUMIDITY_GLUE);
|
||||
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
%module tellduscore
|
||||
%{
|
||||
#include "../../telldus-core/driver/libtelldus-core/telldus-core.h"
|
||||
%}
|
||||
|
||||
%include "../../telldus-core/driver/libtelldus-core/telldus-core.h"
|
|
@ -1,17 +0,0 @@
|
|||
Attribute VB_Name = "TellStickModule"
|
||||
Public Declare Function devTurnOn Lib "TellUsbD101.dll" (ByVal lngDeviceId As Long) As Boolean
|
||||
Public Declare Function devTurnOff Lib "TellUsbD101.dll" (ByVal lngDeviceId As Long) As Boolean
|
||||
Public Declare Function devBell Lib "TellUsbD101.dll" (ByVal lngDeviceId As Long) As Boolean
|
||||
Public Declare Function devDim Lib "TellUsbD101.dll" (ByVal lngDeviceId As Long, ByVal level As Byte) As Boolean
|
||||
Public Declare Function devMethods Lib "TellUsbD101.dll" (ByVal lngDeviceId As Long) As Long
|
||||
|
||||
Public Declare Function devGetDeviceId Lib "TellUsbD101.dll" (ByVal a As Long) As Long
|
||||
Public Declare Function devGetName Lib "TellUsbD101.dll" (ByVal i As Long) As String
|
||||
Public Declare Function devGetNumberOfDevices Lib "TellUsbD101.dll" () As Long
|
||||
|
||||
Public Const TELLSTICK_TURNON = 1
|
||||
Public Const TELLSTICK_TURNOFF = 2
|
||||
Public Const TELLSTICK_BELL = 4
|
||||
Public Const TELLSTICK_TOGGLE = 8
|
||||
Public Const TELLSTICK_DIM = 16
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
VERSION 5.00
|
||||
Begin VB.Form frmMain
|
||||
BorderStyle = 4 'Fixed ToolWindow
|
||||
Caption = "TellStick VB-example - simple"
|
||||
ClientHeight = 4680
|
||||
ClientLeft = 2040
|
||||
ClientTop = 3600
|
||||
ClientWidth = 3990
|
||||
Icon = "TellStick VB-example - simple.frx":0000
|
||||
LinkTopic = "Form1"
|
||||
MaxButton = 0 'False
|
||||
MinButton = 0 'False
|
||||
ScaleHeight = 4680
|
||||
ScaleWidth = 3990
|
||||
ShowInTaskbar = 0 'False
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "90%"
|
||||
Height = 465
|
||||
Index = 8
|
||||
Left = 3480
|
||||
TabIndex = 12
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "80%"
|
||||
Height = 465
|
||||
Index = 7
|
||||
Left = 3060
|
||||
TabIndex = 11
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "70%"
|
||||
Height = 465
|
||||
Index = 6
|
||||
Left = 2640
|
||||
TabIndex = 10
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "60%"
|
||||
Height = 465
|
||||
Index = 5
|
||||
Left = 2220
|
||||
TabIndex = 9
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "50%"
|
||||
Height = 465
|
||||
Index = 4
|
||||
Left = 1800
|
||||
TabIndex = 8
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "40%"
|
||||
Height = 465
|
||||
Index = 3
|
||||
Left = 1380
|
||||
TabIndex = 7
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "30%"
|
||||
Height = 465
|
||||
Index = 2
|
||||
Left = 960
|
||||
TabIndex = 6
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "20%"
|
||||
Height = 465
|
||||
Index = 1
|
||||
Left = 540
|
||||
TabIndex = 5
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdDim
|
||||
Caption = "10%"
|
||||
Height = 465
|
||||
Index = 0
|
||||
Left = 120
|
||||
TabIndex = 4
|
||||
Top = 4110
|
||||
Width = 420
|
||||
End
|
||||
Begin VB.CommandButton cmdBell
|
||||
Caption = "Bell"
|
||||
Height = 735
|
||||
Left = 1500
|
||||
Picture = "TellStick VB-example - simple.frx":0ECA
|
||||
Style = 1 'Graphical
|
||||
TabIndex = 3
|
||||
Top = 3285
|
||||
Width = 1000
|
||||
End
|
||||
Begin VB.ListBox deviceList
|
||||
Height = 3180
|
||||
Left = 60
|
||||
TabIndex = 2
|
||||
Top = 60
|
||||
Width = 3810
|
||||
End
|
||||
Begin VB.CommandButton cmdOff
|
||||
Caption = "Off"
|
||||
Height = 735
|
||||
Left = 120
|
||||
Picture = "TellStick VB-example - simple.frx":1794
|
||||
Style = 1 'Graphical
|
||||
TabIndex = 1
|
||||
Top = 3285
|
||||
Width = 1000
|
||||
End
|
||||
Begin VB.CommandButton cmdOn
|
||||
Caption = "On"
|
||||
Height = 735
|
||||
Left = 2900
|
||||
Picture = "TellStick VB-example - simple.frx":205E
|
||||
Style = 1 'Graphical
|
||||
TabIndex = 0
|
||||
Top = 3285
|
||||
Width = 1000
|
||||
End
|
||||
End
|
||||
Attribute VB_Name = "frmMain"
|
||||
Attribute VB_GlobalNameSpace = False
|
||||
Attribute VB_Creatable = False
|
||||
Attribute VB_PredeclaredId = True
|
||||
Attribute VB_Exposed = False
|
||||
Private Sub cmdBell_Click()
|
||||
Dim blnBell As Boolean
|
||||
blnBell = devBell(deviceList.ItemData(deviceList.ListIndex))
|
||||
End Sub
|
||||
|
||||
Private Sub cmdDim_Click(Index As Integer)
|
||||
Dim blnDim As Boolean
|
||||
Dim level As Byte
|
||||
Select Case Index
|
||||
Case "8"
|
||||
level = 230
|
||||
Case "7"
|
||||
level = 204
|
||||
Case "6"
|
||||
level = 179
|
||||
Case "5"
|
||||
level = 153
|
||||
Case "4"
|
||||
level = 128
|
||||
Case "3"
|
||||
level = 102
|
||||
Case "2"
|
||||
level = 77
|
||||
Case "1"
|
||||
level = 51
|
||||
Case "0"
|
||||
level = 25
|
||||
End Select
|
||||
blnDim = devDim(deviceList.ItemData(deviceList.ListIndex), level)
|
||||
End Sub
|
||||
|
||||
Private Sub cmdOff_Click()
|
||||
Dim blnOff As Boolean
|
||||
blnOff = devTurnOff(deviceList.ItemData(deviceList.ListIndex))
|
||||
End Sub
|
||||
|
||||
Private Sub cmdOn_Click()
|
||||
Dim blnOn As Boolean
|
||||
blnOn = devTurnOn(deviceList.ItemData(deviceList.ListIndex))
|
||||
End Sub
|
||||
|
||||
Private Sub deviceList_Click()
|
||||
Dim intMethods As Integer
|
||||
|
||||
intMethods = devMethods(deviceList.ItemData(deviceList.ListIndex))
|
||||
cmdOn.Enabled = (intMethods And TELLSTICK_TURNON)
|
||||
cmdOff.Enabled = (intMethods And TELLSTICK_TURNOFF)
|
||||
cmdBell.Enabled = (intMethods And TELLSTICK_BELL)
|
||||
|
||||
For a = 0 To 8
|
||||
cmdDim(a).Enabled = (intMethods And TELLSTICK_DIM)
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Form_Load()
|
||||
|
||||
Dim numDevices As Integer, i As Integer
|
||||
numDevices = devGetNumberOfDevices()
|
||||
|
||||
For i = 0 To numDevices - 1
|
||||
Dim strName As String
|
||||
Dim intId As Integer
|
||||
|
||||
intId = devGetDeviceId(i)
|
||||
strName = devGetName(intId)
|
||||
deviceList.AddItem strName
|
||||
deviceList.ItemData(i) = intId
|
||||
Next
|
||||
|
||||
deviceList.ListIndex = 0
|
||||
|
||||
End Sub
|
Binary file not shown.
|
@ -1,36 +0,0 @@
|
|||
Type=Exe
|
||||
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\..\WINDOWS\system32\STDOLE2.TLB#OLE Automation
|
||||
Form=TellStick VB-example - simple.frm
|
||||
Module=TellStickModule; ..\TellStick.bas
|
||||
Startup="frmMain"
|
||||
HelpFile=""
|
||||
ExeName32="TellStick VB-example - simple.exe"
|
||||
Command32=""
|
||||
Name="TellStickExample"
|
||||
HelpContextID="0"
|
||||
CompatibleMode="0"
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
RevisionVer=0
|
||||
AutoIncrementVer=0
|
||||
ServerSupportFiles=0
|
||||
VersionCompanyName="Telldus Technologies"
|
||||
CompilationType=0
|
||||
OptimizationType=0
|
||||
FavorPentiumPro(tm)=0
|
||||
CodeViewDebugInfo=0
|
||||
NoAliasing=0
|
||||
BoundsCheck=0
|
||||
OverflowCheck=0
|
||||
FlPointCheck=0
|
||||
FDIVCheck=0
|
||||
UnroundedFP=0
|
||||
StartMode=0
|
||||
Unattended=0
|
||||
Retained=0
|
||||
ThreadPerObject=0
|
||||
MaxNumberOfThreads=1
|
||||
DebugStartupOption=0
|
||||
|
||||
[MS Transaction Server]
|
||||
AutoRefresh=1
|
42
cruise_build.sh
Executable file
42
cruise_build.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
CMAKE_LOG="$CC_BUILD_ARTIFACTS/cmake.log"
|
||||
|
||||
if [ ! -d "$CC_BUILD_ARTIFACTS" ]
|
||||
then
|
||||
echo "CC_BUILD_ARTIFACTS does not point to a valid directory!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n "Preparing directories... "
|
||||
test -d build || mkdir build
|
||||
echo "done."
|
||||
|
||||
(
|
||||
echo -n "Preparing build... "
|
||||
echo -n "running cmake... "
|
||||
cd build
|
||||
# cmake .. -DCMAKE_BUILD_TYPE=Profile > "$CMAKE_LOG"
|
||||
cmake .. > "$CMAKE_LOG"
|
||||
)
|
||||
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
echo "failed"
|
||||
exit 1
|
||||
fi
|
||||
echo "done."
|
||||
|
||||
|
||||
echo "Building..."
|
||||
make -C build
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Mina egna tester här
|
||||
|
||||
exit 0
|
||||
|
5
cruise_config.rb
Normal file
5
cruise_config.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Project.configure do |project|
|
||||
project.email_notifier.emails = ["micke.prag@telldus.se"]
|
||||
project.email_notifier.from = 'micke.prag@telldus.se'
|
||||
project.build_command = './cruise_build.sh'
|
||||
end
|
18
debian/changelog
vendored
Normal file
18
debian/changelog
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
telldus-core (2.0.2-1) unstable; urgency=low
|
||||
|
||||
* New upstream version
|
||||
|
||||
-- Micke Prag <micke.prag@telldus.se> Fri, 12 Feb 2010 12:07:00 +0200
|
||||
|
||||
telldus-core (2.0.1-1) unstable; urgency=low
|
||||
|
||||
* New upstream version
|
||||
|
||||
-- Micke Prag <micke.prag@telldus.se> Tue, 10 Nov 2009 21:55:00 +0200
|
||||
|
||||
telldus-core (2.0.0-1) unstable; urgency=low
|
||||
|
||||
* Initial release (Closes: #544982)
|
||||
|
||||
-- Micke Prag <micke.prag@telldus.se> Thu, 03 Sep 2009 20:25:46 +0200
|
||||
|
36
debian/control
vendored
Normal file
36
debian/control
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
Source: telldus-core
|
||||
Priority: extra
|
||||
Maintainer: Micke Prag <micke.prag@telldus.se>
|
||||
Build-Depends: debhelper (>= 7)
|
||||
Standards-Version: 3.7.3
|
||||
Section: libs
|
||||
Homepage: http://www.telldus.se
|
||||
|
||||
Package: libtelldus-core-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libtelldus-core2 (= ${binary:Version})
|
||||
Description: Development file for libtelldus-core
|
||||
This package contains the header file needed to
|
||||
compile applications that use telldus-core.
|
||||
|
||||
Package: libtelldus-core2
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Description: Library to control a Telldus TellStick
|
||||
libtelldus-core is the library for controlling wireless devices by a
|
||||
Telldus TellStick.
|
||||
.
|
||||
It makes it very easy to add home automation capabilities to a
|
||||
program using a simple API.
|
||||
|
||||
Package: telldus-core
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Description: Utilities and driver to control wireless receivers through a TellStick
|
||||
TellStick from Telldus Technologies is a USB-interface to various remote
|
||||
controlled RF receivers on 433,92 MHz.
|
||||
.
|
||||
This package contains the command line interface utilities for controling
|
||||
the devices.
|
20
debian/copyright
vendored
Normal file
20
debian/copyright
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
This package was debianized by Micke Prag <micke.prag@telldus.se> on
|
||||
Thu, 03 Sep 2009 20:25:46 +0200.
|
||||
|
||||
It was downloaded from http://download.telldus.se/TellStick/Software/telldus-core/
|
||||
|
||||
Upstream Author:
|
||||
|
||||
Micke Prag <micke.prag@telldus.se>
|
||||
|
||||
Copyright:
|
||||
|
||||
Copyright (C) 2009 Telldus Technologies AB
|
||||
|
||||
License:
|
||||
|
||||
GPL-2
|
||||
|
||||
The Debian packaging is (C) 2009, Micke Prag <micke.prag@telldus.se> and
|
||||
is licensed under the GPL-2, see `/usr/share/common-licenses/GPL-2'.
|
||||
|
3
debian/libtelldus-core-dev.install
vendored
Normal file
3
debian/libtelldus-core-dev.install
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
usr/include/*
|
||||
usr/lib/lib*.so
|
||||
|
1
debian/libtelldus-core2.install
vendored
Normal file
1
debian/libtelldus-core2.install
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
usr/lib/lib*.so.*
|
117
debian/rules
vendored
Executable file
117
debian/rules
vendored
Executable file
|
@ -0,0 +1,117 @@
|
|||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# Sample debian/rules that uses debhelper.
|
||||
# This file was originally written by Joey Hess and Craig Small.
|
||||
# As a special exception, when this file is copied by dh-make into a
|
||||
# dh-make output file, you may use that output file without restriction.
|
||||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# shared library versions, option 1
|
||||
version=2.0.2
|
||||
major=2
|
||||
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
|
||||
#version=`ls src/.libs/lib*.so.* | \
|
||||
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
|
||||
#major=`ls src/.libs/lib*.so.* | \
|
||||
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
|
||||
|
||||
configure: configure-stamp
|
||||
configure-stamp:
|
||||
dh_testdir
|
||||
# Add here commands to configure the package.
|
||||
|
||||
mkdir build
|
||||
cd build && \
|
||||
cmake \
|
||||
-DBUILD_RFCMD=1 \
|
||||
-DBUILD_RFCMD_WITH_LIBFTDI=0 \
|
||||
-DBUILD_LIBTELLDUS-CORE=1 \
|
||||
-DBUILD_TDTOOL=1 \
|
||||
-DSUPPORT_TELLSTICK_DUO=0 \
|
||||
-DSUPPORT_USB=0 \
|
||||
-DUSE_QT_SETTINGS_BACKEND=0 \
|
||||
-DGENERATE_MAN=1 \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CXX_FLAGS="-Wl,--as-needed" \
|
||||
..
|
||||
|
||||
touch configure-stamp
|
||||
|
||||
|
||||
build: build-stamp
|
||||
build-stamp: configure-stamp
|
||||
dh_testdir
|
||||
|
||||
# Add here commands to compile the package.
|
||||
cd build && \
|
||||
$(MAKE)
|
||||
|
||||
touch $@
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -f build-stamp configure-stamp
|
||||
|
||||
# Add here commands to clean up after the build process.
|
||||
if test -d build; then rm -rf build;fi
|
||||
|
||||
dh_clean
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
|
||||
# Add here commands to install the package into debian/tmp
|
||||
cd build && \
|
||||
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
|
||||
|
||||
|
||||
# Build architecture-independent files here.
|
||||
binary-indep: build install
|
||||
# We have nothing to do by default.
|
||||
|
||||
# Build architecture-dependent files here.
|
||||
binary-arch: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs
|
||||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_install
|
||||
# dh_installmenu
|
||||
# dh_installdebconf
|
||||
# dh_installlogrotate
|
||||
# dh_installemacsen
|
||||
# dh_installpam
|
||||
# dh_installmime
|
||||
# dh_installinit
|
||||
# dh_installcron
|
||||
# dh_installinfo
|
||||
dh_installman
|
||||
dh_link
|
||||
dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
# dh_perl
|
||||
# dh_python
|
||||
dh_makeshlibs
|
||||
dh_installdeb
|
||||
dh_shlibdeps
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install configure
|
4
debian/telldus-core.install
vendored
Normal file
4
debian/telldus-core.install
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
usr/bin/*
|
||||
usr/share/man/man1/*
|
||||
etc/*
|
||||
|
48
debian/telldus-core.postinst
vendored
Normal file
48
debian/telldus-core.postinst
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
# postinst script for telldus-core
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <postinst> `configure' <most-recently-configured-version>
|
||||
# * <old-postinst> `abort-upgrade' <new version>
|
||||
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
||||
# <new-version>
|
||||
# * <postinst> `abort-remove'
|
||||
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
||||
# <failed-install-package> <version> `removing'
|
||||
# <conflicting-package> <version>
|
||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
chown root:plugdev /etc/tellstick.conf
|
||||
chmod 664 /etc/tellstick.conf
|
||||
|
||||
mkdir -p /var/state
|
||||
touch /var/state/telldus-core.conf
|
||||
chown root:plugdev /var/state/telldus-core.conf
|
||||
chmod 666 /var/state/telldus-core.conf
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
||||
|
|
@ -1,351 +0,0 @@
|
|||
/**
|
||||
* @mainpage Telldus Core API
|
||||
*
|
||||
* \section Introduction
|
||||
*
|
||||
* This is the guide to Telldus TellStick SDK. Even though all examples are
|
||||
* written in C/C++ most of the code has a direct eqvivalent function in the
|
||||
* other languages. See \ref sec_other_languages how to use the library in one
|
||||
* of the supported languages by Telldus.
|
||||
*
|
||||
* \section Idea
|
||||
*
|
||||
* All of the devices used by TellStick must be predefined before they can be
|
||||
* used in any software. Under all platforms this can be done with the
|
||||
* software TelldusCenter but under Linux this can also be done by editing the
|
||||
* file <tt>/etc/tellstick.conf</tt> with your favorite text editor.
|
||||
*
|
||||
* Having the devices preconfigured is an advantage to both the developer and
|
||||
* the end user.
|
||||
*
|
||||
* \li The end user might use more then one program for controlling his/her
|
||||
* TellStick. By having the devices preconfigured he/she does not have to
|
||||
* reconfigure the same devices twice. If some settings change in one of the
|
||||
* devices, this change will affect all softwares using Telldus TellStick SDK.
|
||||
* \li Telldus continuously adds support for new devices. If a software
|
||||
* defines it's own devices, the developer will have to keep the software
|
||||
* up to date with new devices and settings implemented by Telldus. By querying
|
||||
* Telldus Tellstick SDK all the new devices will be available automaticly to
|
||||
* the end user.
|
||||
*
|
||||
* \section sec_basic_usage Basic usage (telldus-core)
|
||||
*
|
||||
* Telldus provides a non-gui library to list, query and control the devices
|
||||
* called telldus-core.
|
||||
* To initiate the library a call to tdInit() must be made. This call will
|
||||
* open up all controllers (e.g. a TellStick) and start listening for events from
|
||||
* them.
|
||||
* When you are done with telldus-core, call tdClose() to allow the library to
|
||||
* clean up after itself.
|
||||
*
|
||||
* \subsection sec_bu_listing Listing devices
|
||||
*
|
||||
* To list all of the configured devices, look at the following example:
|
||||
* \code
|
||||
* int intNumberOfDevices = tdGetNumberOfDevices();
|
||||
* for (int i = 0; i < intNumberOfDevices; i++) {
|
||||
* int id = tdGetDeviceId( i );
|
||||
* char *name = tdGetName( id );
|
||||
* printf("%d\t%s\n", id, name);
|
||||
* tdReleaseString(name);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* First, we call tdGetNumberOfDevices(). This returnes the total number of
|
||||
* devices configured. We then iterate over all of the devices with the index
|
||||
* in the variable \c i.
|
||||
* Since the devices could change between runs of the program we can not be
|
||||
* sure that the index points to the same device between two runs of the
|
||||
* program. That is why every device has it's own unique id that is safe to
|
||||
* store in a configuration file. Two different devices can never share the
|
||||
* same device id.
|
||||
*
|
||||
* The call to tdGetDeviceId() returns the id for a specific index. This
|
||||
* function should only be called in a loop iterating over all of the devices.
|
||||
* After we have found the id for a device it is safe to store this or use it
|
||||
* in the rest of the program.
|
||||
*
|
||||
* The next two lines of code queries the device for it's name with a call to
|
||||
* tdGetName() and then displays it to stdout. Finally we must release the
|
||||
* resource after we are done with it by calling tdReleaseString() on any
|
||||
* \c char pointer returned by telldus-core.
|
||||
*
|
||||
* \subsection sec_bu_sending Sending commands to TellStick
|
||||
*
|
||||
* \subsubsection sec_bu_sending_features Device features
|
||||
*
|
||||
* TellStick can control many different types of devices that
|
||||
* support different features. For example, a bell does not support turning
|
||||
* the on-signal and not all lamp switches support dimming.
|
||||
* Call tdMethods() to find out what a specific device supports:
|
||||
* \code
|
||||
* function checkFeatures( int id ) {
|
||||
* int supportedMethods = TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_BELL;
|
||||
* int methods = tdMethods( id, supportedMethods );
|
||||
* if ( methods & TELLSTICK_TURNON ) {
|
||||
* printf( "The device %d support tdTurnOn()\n", id );
|
||||
* }
|
||||
* if ( methods & TELLSTICK_TURNOFF ) {
|
||||
* printf( "The device %d support tdTurnOff()\n", id );
|
||||
* }
|
||||
* if ( methods & TELLSTICK_BELL ) {
|
||||
* printf( "The device %d support tdBell()\n", id );
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* By supplying the methods your application supports, the library can return
|
||||
* customized methods for your application, even if your application doesn't
|
||||
* support the same methods as the device accepts. One example is if your
|
||||
* application only supports ON and OFF, you can control a device that needs UP
|
||||
* and DOWN anyway by using just ON and OFF.
|
||||
* Let's say that the client application only supports turning on and
|
||||
* off. The call to query a device for it's methods should be:
|
||||
* \code
|
||||
* int methods = tdMethods( id, TELLSTICK_TURNON | TELLSTICK_TURNOFF );
|
||||
* \endcode
|
||||
* If the device in the above example is a device only supporing TELLSTICK_BELL,
|
||||
* the library will instead return TELLSTICK_TURNON, making the client application
|
||||
* still able to control the device.
|
||||
* When you know which features a device supports it is safe to call the
|
||||
* controlling functions described in \ref sec_bu_controlling_functions.
|
||||
*
|
||||
* When calling tdMethods() all of the supported methods should be passed in one
|
||||
* call. Do not call tdMethods() for each of the supported methods. Look at the
|
||||
* following example:
|
||||
* \code
|
||||
* //Correct
|
||||
* int methods = tdMethods( id, TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_BELL );
|
||||
*
|
||||
* //Wrong
|
||||
* int turnOn = tdMethods( id, TELLSTICK_TURNON );
|
||||
* int turnOff = tdMethods( id, TELLSTICK_TURNOFF );
|
||||
* int bell = tdMethods( id, TELLSTICK_BELL );
|
||||
* \endcode
|
||||
*
|
||||
* Another thing to note is if you are developing a library intended for
|
||||
* thirdparty use. You should not hardcode which methods are supported by the
|
||||
* library. It is always up to the application implementing the methods to
|
||||
* supply the methods it supports.
|
||||
*
|
||||
* \subsubsection sec_bu_controlling_functions Controlling functions
|
||||
*
|
||||
* TellStick has a couple of functions for controlling devices. Each of
|
||||
* them should only be called if the device support the feature.
|
||||
*
|
||||
* These functions all return zero if the call was successful and non-zero
|
||||
* otherwise.
|
||||
*
|
||||
* \paragraph tdTurnOn tdTurnOn()
|
||||
* Devices supporting \c TELLSTICK_TURNON. Most of the normal switches (for lamp
|
||||
* etc.) support this.
|
||||
* \paragraph tdTurnOff tdTurnOff()
|
||||
* Devices supporting \c TELLSTICK_TURNOFF. Almost all of the devices supporting
|
||||
* \c TELLSTICK_TURNON also support this.
|
||||
* \paragraph tdDim tdDim()
|
||||
* Devices supporting \c TELLSTICK_DIM. This is a quite unusual feature for
|
||||
* dimmers. Many dimmers on the market that are dimmable have no way for sending
|
||||
* a specific level which means it does not support this feature.
|
||||
* \paragraph tdBell tdBell()
|
||||
* Devices supporting \c TELLSTICK_BELL. This is mostly wireless doorbells.
|
||||
*
|
||||
* \subsubsection sec_bu_error_codes Error codes
|
||||
*
|
||||
* If any of the calls in \ref sec_bu_controlling_functions fails it returns
|
||||
* a non-zero error code. This values is one of the \c TELLSTICK_ERROR_* defines.
|
||||
* To translate the error code to a human readable string call the function
|
||||
* tdGetErrorString(). Example:
|
||||
* \code
|
||||
* printf("Error: %s\n", tdGetErrorString( TELLSTICK_METHOD_NOT_SUPPORTED ) );
|
||||
* //Error: The method you tried to use is not supported by the device
|
||||
*
|
||||
* int retval = tdTurnOn( deviceID );
|
||||
* if (retval != TELLSTICK_SUCCESS ) {
|
||||
* char *errorString = tdGetErrorString( retval );
|
||||
* printf("Error: %s\n", errorString );
|
||||
* tdReleaseString(errorString);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \subsection sec_bu_device_state Device states
|
||||
*
|
||||
* Since controllable devices only have a receiver and not a transmitter the communication is
|
||||
* one-way. This means that telldus-core will never know for sure which
|
||||
* state a reciever has. Instead, the library remembers which command was last
|
||||
* sent. Either sent from the TellStick itself, or sent from another controller (e.g. a remote control)
|
||||
* captured by the Tellstick Duo. In this way it "emulates" a two-way communication.
|
||||
*
|
||||
* To query the device state, use the function tdLastSentCommand()
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* char *name = tdGetName( id );
|
||||
* int state = tdLastSentCommand( id );
|
||||
* if (state == TELLSTICK_TURNON) {
|
||||
* printf("%s is on\n", name);
|
||||
* } else if (state == TELLSTICK_TURNOFF) {
|
||||
* printf("%s is off\n", name);
|
||||
* } else {
|
||||
* printf("%s is in an unknown state\n", name);
|
||||
* }
|
||||
* tdReleaseString(name);
|
||||
* \endcode
|
||||
*
|
||||
* \subsection sec_bu_sensors Sensors
|
||||
*
|
||||
* Retrieving sensor values can be done in two ways. Either by a polling
|
||||
* interface or by callbacks. The client application can implement one or both
|
||||
* of these interfaces. For callbacks, read more under \ref sec_events.
|
||||
*
|
||||
* Each of the sensors can have one or several value types. Currently only
|
||||
* temperature and humidity are implemented.
|
||||
*
|
||||
* There is no API to add, remove or edit sensors. Each sensor that
|
||||
* TellStick Duo has got any data from is added to an internal list. It is up to
|
||||
* the client application to filter and only show the sensors your are
|
||||
* interested in.
|
||||
*
|
||||
* To iterate over the list of sensors, call tdSensor() repeatedly as long as it
|
||||
* returns \c TELLSTICK_SUCCESS. The parameters \c protocol, \c model,
|
||||
* \c sensorId, and \c dataTypes are sent by reference and will be filled with
|
||||
* the values.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* char protocol[DATA_LENGTH], model[DATA_LENGTH];
|
||||
* int sensorId = 0, dataTypes = 0;
|
||||
* while(tdSensor(protocol, DATA_LENGTH, model, DATA_LENGTH, &sensorId, &dataTypes) == TELLSTICK_SUCCESS) {
|
||||
* //Print the sensor
|
||||
* printf("%s,\t%s,\t%i\n", protocol, model, sensorId);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* The type of sensor values the sensor supports are stored as flags in the
|
||||
* parameter \c sensorId. Call tdSensorValue() for each type.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* char value[DATA_LENGTH];
|
||||
* char timeBuf[80];
|
||||
* time_t timestamp = 0;
|
||||
* if (dataTypes & TELLSTICK_TEMPERATURE) {
|
||||
* tdSensorValue(protocol, model, sensorId, TELLSTICK_TEMPERATURE, value, DATA_LENGTH, (int *)×tamp);
|
||||
* strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S", localtime(×tamp));
|
||||
* printf("Temperature:\t%sº\t(%s)\n", value, timeBuf);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \section sec_events Events
|
||||
*
|
||||
* To get events from either a TellStick Duo, another software changes the
|
||||
* status of a device, or new sensors values you have to register for a callback.
|
||||
*
|
||||
* \subsection sec_events_registering Registering for callbacks
|
||||
*
|
||||
* For each callback there is a corresponding register function:
|
||||
* \li tdRegisterDeviceEvent()
|
||||
* \li tdRegisterDeviceChangeEvent()
|
||||
* \li tdRegisterRawDeviceEvent()
|
||||
* \li tdRegisterSensorEvent()
|
||||
*
|
||||
* These all work in the same way. The first parameter is a function-pointer to
|
||||
* the callback function. The second parameter is an optional void pointer. This
|
||||
* can be anything and is dependent on the implementation. This object will be
|
||||
* sent back to each call to the callback function. The functions return an
|
||||
* integer which is an id to the specific callback. This is is sent as a
|
||||
* parameter in each call and should also be used for unregister the callback.
|
||||
*
|
||||
* Please note that the callback will be called by another thread than the
|
||||
* thread used by the application and some measures must be taken to synchronize
|
||||
* it with the main thread.
|
||||
*
|
||||
* Many devices (for example motion detectors) resends their messages many times
|
||||
* to ensure that they are received correctly. If a deviceeventcallback or
|
||||
* rawdeviceeventcallback in turn is calling a controlling function, for example
|
||||
* tdTurnOn, it may be neccessary to implement some solution to wait for the
|
||||
* device to finish its resending, before executing the controlling function.
|
||||
* See how this can be done in the python example.
|
||||
*
|
||||
* \subsection sec_events_callbacks Callbacks
|
||||
*
|
||||
* telldus-core currently implements four different callback function for
|
||||
* different purposes.
|
||||
*
|
||||
* \subsubsection sec_events_callbacks_deviceevent DeviceEvent
|
||||
*
|
||||
* This event is fired when the state of a device changes. This can either
|
||||
* occur via a remote control, but can as well occur via another software on the
|
||||
* computer.
|
||||
*
|
||||
* Parameters:
|
||||
* - int deviceId - The device id of the device that changed.
|
||||
* - int method - The new state. Can be TELLSTICK_TURNON, TELLSTICK_TURNOFF
|
||||
* etc.
|
||||
* - const char *data - For some methods this contains data. For TELLSTICK_DIM
|
||||
* this hold the current value.
|
||||
* - int callbackId - id of callback
|
||||
* - void *context - see \ref sec_events_registering for description
|
||||
*
|
||||
* \subsubsection sec_events_callbacks_devicechangeevent DeviceChangeEvent
|
||||
*
|
||||
* This event is fired when the data around a device is changed. It can only be
|
||||
* triggered by another software. Use this callback to keep your list of devices
|
||||
* in sync.
|
||||
*
|
||||
* Parameters:
|
||||
* - int deviceId - The device id of the device that changed.
|
||||
* - int changeEvent - What was changed. This can be:
|
||||
* - TELLSTICK_DEVICE_ADDED - A new device was added. The parameter deviceId
|
||||
* holds the id of the new device.
|
||||
* - TELLSTICK_DEVICE_REMOVED - A device was removed, the parameter deviceId
|
||||
* holds the id of the removed device.
|
||||
* - TELLSTICK_DEVICE_CHANGED - The settings of a device changed. The next
|
||||
* parameter holds what was changed.
|
||||
* - int changeType - If changeEvent is TELLSTICK_DEVICE_CHANGED this parameter
|
||||
* holds what was changed. It can be one of the following:
|
||||
* - TELLSTICK_CHANGE_NAME - Use tdGetName() to read the new name.
|
||||
* - TELLSTICK_CHANGE_PROTOCOL - Use tdGetProtocol() to read the new value.
|
||||
* - TELLSTICK_CHANGE_MODEL - Use tdGetModel() to read the new value.
|
||||
* - int callbackId - id of callback
|
||||
* - void *context - see \ref sec_events_registering for description
|
||||
*
|
||||
* \subsubsection sec_events_callbacks_rawdeviceevent RawDeviceEvent
|
||||
*
|
||||
* Use this callback with caution. It outputs everything from a TellStick Duo
|
||||
* without any preprocessing. This can be used to get events from devices not
|
||||
* already configured.
|
||||
*
|
||||
* Parameters:
|
||||
* - const char *data - raw device data
|
||||
* - int controllerId - id of receiving controller, can identify the TellStick if several exists in the system
|
||||
* - int callbackId - id of callback
|
||||
* - void *context - see \ref sec_events_registering for description
|
||||
*
|
||||
* \subsubsection sec_events_callbacks_sensorevent SensorEvent
|
||||
*
|
||||
* This event is fired when a new sensor value is retrieved.
|
||||
*
|
||||
* Parameters:
|
||||
* - const char *protocol - The sensors protocol
|
||||
* - const char *model - The model of the sensor
|
||||
* - int id - The unique id for the sensor.
|
||||
* - int dataType - Flags for which types of data the sensor supports
|
||||
* - const char *value - A human readable string of the data
|
||||
* - int timestamp - The timestamp when the latest value was received
|
||||
* - int callbackId - id of callback
|
||||
* - void *context - See \ref sec_events_registering for description
|
||||
*
|
||||
* \subsection sec_events_example Example
|
||||
*
|
||||
* \section sec_other_languages Notes using other languages than C/C++
|
||||
*
|
||||
* \subsection sec_ol_pyhon Python
|
||||
*
|
||||
* To use telldus-core in Python,
|
||||
* please have look at the <tt>ctypes</tt> library. It contains <tt>cdll</tt> and
|
||||
* <tt>windll</tt> to load any dynamic link libraries.
|
||||
*
|
||||
* There is also a third party library available:
|
||||
* https://github.com/erijo/tellcore-py
|
||||
*
|
||||
*/
|
|
@ -1,122 +0,0 @@
|
|||
/**
|
||||
* @page TellStick TellStick protocol
|
||||
*
|
||||
* \section Introduction
|
||||
*
|
||||
* Telldus TellStick protocol looks like:<br>
|
||||
* <tt>[prefix[prefix parameters]][command][parameter 1]..[parameter n]['+']</tt>
|
||||
*
|
||||
* Each value in <tt>[</tt> and <tt>]</tt> is representing one byte.
|
||||
*
|
||||
* Command is one ascii character. Not all commands have parameters which
|
||||
* makes it optional. Prefix is always optional.
|
||||
* Note: Due to memory limitations, the parameters is limited in length to 79
|
||||
* bytes.
|
||||
*
|
||||
* An example command to turn on a ArcTech codeswitch A1 may look like:
|
||||
* <tt>S$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$}+</tt>
|
||||
*
|
||||
* TellStick returns to a known command like this:<br>
|
||||
* <tt>['+'][command][parameters][13][10]</tt>
|
||||
*
|
||||
* <tt>[13]</tt> and <tt>[10]</tt> are the ascii characters 10 and 13.
|
||||
*
|
||||
* An example to query a TellStick on its firmware version:<br>
|
||||
* Command:<br>
|
||||
* <tt>V+</tt><br>
|
||||
* Response:<br>
|
||||
* <tt>+V2</tt><br>
|
||||
* The TellStick in the example has the firmware version 2.
|
||||
*
|
||||
* \section Commands
|
||||
*
|
||||
* \subsection sec_send S - Send command
|
||||
* This command tells TellStick to send a command. The parameters to this
|
||||
* command is the data-packet to send.
|
||||
*
|
||||
* Each of the characters in the parameters makes the antenna alternate
|
||||
* high/low/high etc. The time before the alternation is 10 us timer the ASCII
|
||||
* value. For example, $ has the ascii-value 36 and k has 107. The command:
|
||||
* <tt>['S']['$']['k']['$']['k']['$']['+']</tt> makes the following wavepattern on the antenna:
|
||||
* <pre>
|
||||
* _____ _____ _____
|
||||
* | | | | | |
|
||||
* | | | | | |
|
||||
* | |_______________| |_______________| |
|
||||
*
|
||||
* |<===>|<=============>|<===>|<=============>|<===>|
|
||||
* 360us 1070us 360us 1070us 360us
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* \subsection sec_send_extended T - Send command, extended
|
||||
*
|
||||
* The extended command was developed to overcome the limitations och the
|
||||
* length of the data to 79 bytes.
|
||||
* The idea is to have four fixed times on the pulses so the information about
|
||||
* what to send only needs 2 bits instead of 8 in the command <tt>S</tt>
|
||||
*
|
||||
* The parameters to the command is:<br>
|
||||
* <tt>[t0][t1][t2][t3][length][d1]..[dn]</tt>
|
||||
*
|
||||
* <tt>t0-t3</tt>: Times 1 to 4. The times are in the same form as <tt>S</tt>.
|
||||
* Each time is multiplied with the factor of 10.
|
||||
*
|
||||
* <tt>length</tt>: How many pulses to send. Since the data sent to TellStick
|
||||
* is sent in groups of four pulses (one byte) and the actual data might not
|
||||
* have pulses even divided with four.
|
||||
*
|
||||
* <tt>d1..dn</tt>: Each byte is the description for four pulses.
|
||||
*
|
||||
* Example:<br>
|
||||
* <tt>['T'][127][255][24][1][6][98][80]['+']</tt>
|
||||
*
|
||||
* <tt>T</tt>: Send extended.
|
||||
*
|
||||
* <tt>127,255,24,1</tt>: Times 1270 us, 2550 us, 24 us and 10 us
|
||||
*
|
||||
* <tt>6</tt>: Six pulses to send.
|
||||
*
|
||||
* <tt>98,80</tt>: The data in binary is <tt>10011000</tt>,<tt>10000000</tt>. If
|
||||
* we group it in groups of two bits we get <tt>10 01 10 00 10 00 00 00</tt>.
|
||||
* Since the length is only six pulses the last two pulses is discarded, giving:
|
||||
* <tt>10 01 10 00 10 00</tt>.
|
||||
*
|
||||
* Matching those bits to the times gives the following times:<br>
|
||||
* <tt>10 => 2 => t2 => 240 us</tt><br>
|
||||
* <tt>01 => 1 => t1 => 2550 us</tt><br>
|
||||
* <tt>10 => 2 => t2 => 240 us</tt><br>
|
||||
* <tt>00 => 0 => t0 => 1270 us</tt><br>
|
||||
* <tt>10 => 2 => t2 => 240 us</tt><br>
|
||||
* <tt>00 => 0 => t0 => 1270 us</tt><br>
|
||||
*
|
||||
* This is equal if you used <tt>S</tt>:<br>
|
||||
* <tt>['S'][24][255][24][127][24][127]['+']</tt>
|
||||
*
|
||||
* \subsection sec_version V - Firmware version
|
||||
* This command queries the TellStick on its firmware version.
|
||||
*
|
||||
* Example:<br>
|
||||
* <tt>» V+</tt><br>
|
||||
* <tt>« +V2</tt><br>
|
||||
* \section Prefixes
|
||||
* The prefixes are commands that can be prepended before some of the commands
|
||||
* and cannot be used standalone. They are used to alter the behavior of the
|
||||
* command.
|
||||
*
|
||||
* \subsection sec_debug D - Debug
|
||||
* \subsection sec_pause P - Pause
|
||||
* The pause is how low TellStick will wait between two packets. The value is
|
||||
* in ms.
|
||||
*
|
||||
* Example, % has the ascii-value 37. The following packet will be sent with a
|
||||
* pause of 37 ms between the packets:<br>
|
||||
* <tt>» P\%S$k$k$+</tt>
|
||||
*
|
||||
* \subsection sec_repeat R - Repeat
|
||||
* This tells TellStick how many times to send the packet.
|
||||
*
|
||||
* Example, ! has the ascii-value 33. The following packet will be sent 33
|
||||
* times:<br>
|
||||
* <tt>» R!S$k$k$+</tt>
|
||||
*/
|
|
@ -1,94 +0,0 @@
|
|||
/**
|
||||
* @page TellStickNet TellStick Net protocol
|
||||
*
|
||||
* \section Introduction
|
||||
*
|
||||
* TellStick Net will eventually support local access through the LAN. This is
|
||||
* unsupported by Telldus Technologies but can be useful in some cases. For
|
||||
* instance in mobile devices or when the internet is not available. Using
|
||||
* TellStick Net through Telldus Live! is still the prefered and supported
|
||||
* method.
|
||||
*
|
||||
* <em>This interface is still under development and is not ready for
|
||||
* production.</em>
|
||||
*
|
||||
* \section autodiscovery Auto discovery
|
||||
*
|
||||
* The TellStick Net can be auto discovered on the LAN using UDP broadcast.
|
||||
* Sending a package to the broadcast address 255.255.255.255 port 30303 will
|
||||
* be responded by any TellStick Net on the network. The packet should only
|
||||
* contain the single character 'D' (ascii number 68).
|
||||
*
|
||||
* The response from the device will be sent back to the same host and port as
|
||||
* the originated packet. So any dynamically port can be assigned by the host
|
||||
* implementing the auto discovery.
|
||||
* The returning packet is constructed in the following way:
|
||||
* <tt>product:mac address:activation code:firmware</tt>
|
||||
*
|
||||
* Example:<br>
|
||||
* <tt>TellStickNet:ABCDEFGHIJKL:ABDCEFGHIJ:2</tt><br>
|
||||
* Product: <tt>TellStick Net (TSNET)</tt><br>
|
||||
* Mac address: <tt>AB:CD:EF:GH:IJ:KL</tt><br>
|
||||
* Code for activation: <tt>ABCDEFGHIJ</tt><br>
|
||||
* Firmware version: <tt>2</tt>
|
||||
*
|
||||
* Use the source ip-address to determine the address to the device.
|
||||
*
|
||||
* \section messageformat Message format
|
||||
*
|
||||
* The message format used to communicate with TellStick Net is designed to be
|
||||
* easily parsed but still be flexible. It can be converted to and from json
|
||||
* without losing information.
|
||||
*
|
||||
* There exists four datatypes; string, integer, list and dictionary:
|
||||
*
|
||||
* - Strings are length-prefixed base sixteen (upper case) followed by a colon
|
||||
* and the string. For example 6:FooBar corresponds to 'FooBar'.
|
||||
*
|
||||
* - Integers are represented by an 'i' followed by the number in base 16
|
||||
* followed by an 's'. For example i3s corresponds to 3 and i-3s corresponds
|
||||
* to -3. Integers have no size limitation. i-0s is invalid. All encodings
|
||||
* with a leading zero, such as i03s, are invalid, other than i0s, which of
|
||||
* course corresponds to 0.
|
||||
*
|
||||
* - Lists are encoded as an 'l' followed by their elements (also encoded)
|
||||
* followed by an 's'. For example l3:foo3:bars corresponds to ['foo', 'bar'].
|
||||
*
|
||||
* - Dictionaries are encoded as a 'h' followed by a list of alternating keys and
|
||||
* their corresponding values followed by an 's'. For example,
|
||||
* h3:foo3:bar5:hello5:worlds corresponds to {'foo': 'bar', 'hello': 'world'}
|
||||
* and h3:fool3:bar3:bazss corresponds to {'foo': ['bar', 'baz']}. Keys must
|
||||
* be strings.
|
||||
*
|
||||
* Communication with TellStick Net is done over UDP on port 42314.
|
||||
* The first string sent contains the command to execute. The following python
|
||||
* example sends a disconnection command to a TellStick Net. This will reboot
|
||||
* the device.
|
||||
* \code
|
||||
* from socket import *
|
||||
* UDPSock = socket(AF_INET,SOCK_DGRAM)
|
||||
* UDPSock.sendto("A:disconnect", ("192.168.0.155",42314))
|
||||
* \endcode
|
||||
* \section tellstick_net_command_send Send command
|
||||
*
|
||||
* For readability the examples will be displayed in json format in this
|
||||
* documentation. They must be encoded using the TellStick Net message format
|
||||
* before sending to an actual TellStick Net.
|
||||
*
|
||||
* Sending RF-data uses the same encoding as TellStick \ref sec_send with the
|
||||
* difference that prefixes should be sent as a parameter and not in the
|
||||
* RF-data.
|
||||
*
|
||||
* The parameters are sent encoded in a dictionary, with the RF-data in the key
|
||||
* 'S'. Example sending Arctech Code switch A1 ON:<br>
|
||||
* <tt>{'S': '$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$k'}</tt>
|
||||
* The string sent will be encoded like this:<br>
|
||||
* <tt>4:sendh1:S32:$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$k$k$ks</tt>
|
||||
*
|
||||
* The same example as above but with a 20 ms pause between the 15 packages:<br>
|
||||
* <tt>{'S': '$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$k$kk$$kk$$kk$$k',
|
||||
* 'P': 20, 'R': 15}</tt>
|
||||
*
|
||||
* The command \ref sec_send_extended "\"Send extended\" (T)" is not implemented
|
||||
* since a TellStick Net can handle packages over 255 pulses.
|
||||
*/
|
15
driver/CMakeLists.txt
Normal file
15
driver/CMakeLists.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
PROJECT( tellstick )
|
||||
|
||||
if(BUILD_LIBTELLDUS-CORE)
|
||||
ADD_SUBDIRECTORY(libtelldus-core)
|
||||
endif(BUILD_LIBTELLDUS-CORE)
|
||||
|
||||
|
||||
IF (WIN32)
|
||||
SET(BUILD_TELLUSBD101 TRUE CACHE BOOL "Build wrapper TellUsbD101.dll")
|
||||
IF (BUILD_TELLUSBD101)
|
||||
ADD_SUBDIRECTORY(TellUsbD101)
|
||||
ENDIF (BUILD_TELLUSBD101)
|
||||
ENDIF (WIN32)
|
||||
|
||||
ADD_SUBDIRECTORY(bindings)
|
20
driver/TellUsbD101.sln
Normal file
20
driver/TellUsbD101.sln
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual C++ Express 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TellUsbD101", "TellUsbD101\TellUsbD101.vcproj", "{2A868E40-88D9-4800-A83F-21D0F8DCB611}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Debug|Win32.ActiveCfg = Release|Win32
|
||||
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Debug|Win32.Build.0 = Release|Win32
|
||||
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
38
driver/TellUsbD101/CMakeLists.txt
Normal file
38
driver/TellUsbD101/CMakeLists.txt
Normal file
|
@ -0,0 +1,38 @@
|
|||
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
endif(COMMAND cmake_policy)
|
||||
|
||||
SET( tellusbd101_SRCS
|
||||
TellUsbD101.cpp
|
||||
TellUsbD101.def
|
||||
)
|
||||
|
||||
SET( tellusbd101_HDRS
|
||||
TellUsbD101.h
|
||||
)
|
||||
|
||||
SET( tellusbd101_TARGET TellUsbD101 )
|
||||
ADD_DEFINITIONS(
|
||||
-D_WINDOWS
|
||||
-DTellUsbD101_EXPORTS
|
||||
)
|
||||
|
||||
SET( tellusbd101_LIBRARIES
|
||||
"${LIBRARY_OUTPUT_PATH}/Release/TelldusCore.lib"
|
||||
)
|
||||
|
||||
|
||||
######## Configuring ########
|
||||
|
||||
ADD_LIBRARY(${tellusbd101_TARGET} SHARED
|
||||
${tellusbd101_SRCS}
|
||||
${tellusbd101_HDRS}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES( ${tellusbd101_TARGET} ${tellusbd101_LIBRARIES} )
|
||||
|
||||
SET_PROPERTY(TARGET ${tellusbd101_TARGET}
|
||||
PROPERTY PUBLIC_HEADER ${tellusbd101_HDRS}
|
||||
)
|
||||
|
85
driver/TellUsbD101/TellUsbD101.cpp
Normal file
85
driver/TellUsbD101/TellUsbD101.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
//DLL entry point
|
||||
|
||||
#include "TellUsbD101.h"
|
||||
#include "../libtelldus-core/telldus-core.h"
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
int __stdcall devGetNumberOfDevices(void){
|
||||
return tdGetNumberOfDevices();
|
||||
}
|
||||
|
||||
int __stdcall devGetDeviceId(int intDeviceIndex){
|
||||
return tdGetDeviceId(intDeviceIndex);
|
||||
}
|
||||
|
||||
char * __stdcall devGetName(int intDeviceId){
|
||||
return tdGetName(intDeviceId);
|
||||
}
|
||||
|
||||
char* __stdcall devGetVendor(int intDeviceId){
|
||||
return tdGetProtocol(intDeviceId);
|
||||
}
|
||||
|
||||
char* __stdcall devGetModel(int intDeviceId){
|
||||
return tdGetModel(intDeviceId);
|
||||
}
|
||||
|
||||
int __stdcall devGetNumberOfArguments(int intDeviceId){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __stdcall devGetArgument(int intDeviceId, int intArgumentIndex){
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __stdcall devSetName(int intDeviceId, char* strNewName){
|
||||
return tdSetName(intDeviceId, strNewName);
|
||||
}
|
||||
|
||||
bool __stdcall devSetVendor(int intDeviceId, char* strVendor) {
|
||||
if (_stricmp(strVendor, "nexa") == 0) {
|
||||
return tdSetProtocol(intDeviceId, "arctech");
|
||||
} else {
|
||||
return tdSetProtocol(intDeviceId, strVendor);
|
||||
}
|
||||
}
|
||||
|
||||
bool __stdcall devSetModel(int intDeviceId, char* strNewModel){
|
||||
return tdSetModel(intDeviceId, strNewModel);
|
||||
}
|
||||
|
||||
bool __stdcall devSetArguments(int intDeviceId, char* strArguments){
|
||||
return false;
|
||||
}
|
||||
|
||||
int __stdcall devAddDevice(){
|
||||
return tdAddDevice();
|
||||
}
|
||||
|
||||
bool __stdcall devRemoveDevice(int intDeviceId){
|
||||
return tdRemoveDevice(intDeviceId);
|
||||
}
|
||||
|
||||
int __stdcall devMethods(int id){
|
||||
return tdMethods(id, TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM | TELLSTICK_BELL);
|
||||
}
|
||||
|
||||
bool __stdcall devTurnOn(int intDeviceId){
|
||||
return (tdTurnOn(intDeviceId) == TELLSTICK_SUCCESS ? true : false);
|
||||
}
|
||||
|
||||
bool __stdcall devTurnOff(int intDeviceId){
|
||||
return (tdTurnOff(intDeviceId) == TELLSTICK_SUCCESS ? true : false);
|
||||
}
|
||||
|
||||
bool __stdcall devBell(int intDeviceId){
|
||||
return (tdBell(intDeviceId) == TELLSTICK_SUCCESS ? true : false);
|
||||
}
|
||||
|
||||
bool __stdcall devDim(int intDeviceId, unsigned char level){
|
||||
return (tdDim(intDeviceId, level) == TELLSTICK_SUCCESS ? true : false);
|
||||
}
|
24
driver/TellUsbD101/TellUsbD101.def
Normal file
24
driver/TellUsbD101/TellUsbD101.def
Normal file
|
@ -0,0 +1,24 @@
|
|||
LIBRARY TellUsbD101
|
||||
EXPORTS
|
||||
devGetNumberOfDevices @1
|
||||
devGetDeviceId @2
|
||||
|
||||
devGetName @3
|
||||
devGetVendor @4
|
||||
devGetModel @5
|
||||
devGetNumberOfArguments @6
|
||||
devGetArgument @7
|
||||
|
||||
devSetName @8
|
||||
devSetVendor @9
|
||||
devSetModel @10
|
||||
devSetArguments @11
|
||||
|
||||
devAddDevice @12
|
||||
devRemoveDevice @13
|
||||
|
||||
devMethods @14
|
||||
devTurnOn @16
|
||||
devTurnOff @17
|
||||
devBell @18
|
||||
devDim @19
|
45
driver/TellUsbD101/TellUsbD101.h
Normal file
45
driver/TellUsbD101/TellUsbD101.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#ifndef TELLUSBD101_H
|
||||
#define TELLUSBD101_H
|
||||
|
||||
// The following ifdef block is the standard way of creating macros
|
||||
// which make exporting from a DLL simpler. All files within this DLL
|
||||
// are compiled with the TellUsbD101_EXPORTS symbol defined on the command line.
|
||||
// This symbol should not be defined on any project that uses this DLL.
|
||||
// This way any other project whose source files include this file see
|
||||
// TELLUSBD101_API functions as being imported from a DLL, whereas this DLL
|
||||
// sees symbols defined with this macro as being exported.
|
||||
|
||||
#ifdef TellUsbD101_EXPORTS
|
||||
#define TELLUSBD101_API __declspec(dllexport)
|
||||
#else
|
||||
#define TELLUSBD101_API __declspec(dllimport)
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
#define WINAPI __stdcall
|
||||
#else
|
||||
#define WINAPI
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" {
|
||||
TELLUSBD101_API bool WINAPI devTurnOn(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devTurnOff(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devBell(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devDim(int intDeviceId, unsigned char level);
|
||||
TELLUSBD101_API int WINAPI devGetNumberOfDevices();
|
||||
TELLUSBD101_API char * WINAPI devGetName(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devSetName(int intDeviceId, const char* chNewName);
|
||||
TELLUSBD101_API char* WINAPI devGetVendor(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devSetVendor(int intDeviceId, const char* chNewName);
|
||||
TELLUSBD101_API char* WINAPI devGetModel(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devSetModel(int intDeviceId, const char* chNewName);
|
||||
TELLUSBD101_API int WINAPI devGetArgument(int intDeviceId, int intArgumentIndex);
|
||||
TELLUSBD101_API int WINAPI devGetNumberOfArguments(int intDeviceId);
|
||||
TELLUSBD101_API bool WINAPI devSetArguments(int intDeviceId, const char* strArguments);
|
||||
TELLUSBD101_API int WINAPI devAddDevice();
|
||||
TELLUSBD101_API bool WINAPI devRemoveDevice(int intDeviceId);
|
||||
TELLUSBD101_API int WINAPI devGetDeviceId(int intDeviceIndex);
|
||||
TELLUSBD101_API int WINAPI devMethods(int id);
|
||||
}
|
||||
|
||||
#endif
|
215
driver/TellUsbD101/TellUsbD101.vcproj
Normal file
215
driver/TellUsbD101/TellUsbD101.vcproj
Normal file
|
@ -0,0 +1,215 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="TellUsbD101"
|
||||
ProjectGUID="{F2BD0723-1E66-4191-AF6D-DEDD9605B028}"
|
||||
RootNamespace="TellUsbD101"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TellUsbD101_EXPORTS"
|
||||
GeneratePreprocessedFile="0"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="oleaut32.lib"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="$(SolutionDir)\TellUsbD101\TellUsbD101.def"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TellUsbD101_EXPORTS"
|
||||
GeneratePreprocessedFile="0"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="advapi32.lib oleaut32.lib"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="TellUsbD101.def"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\TellUsbD101.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\TellUsbD101.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\TellUsbD101.def"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
15
driver/bindings/CMakeLists.txt
Normal file
15
driver/bindings/CMakeLists.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
SET(BUILD_EXTENSION_JAVA FALSE CACHE BOOL "Build extension for Java")
|
||||
IF(BUILD_EXTENSION_JAVA)
|
||||
ADD_SUBDIRECTORY(java)
|
||||
ENDIF(BUILD_EXTENSION_JAVA)
|
||||
|
||||
# ADD_SUBDIRECTORY(php)
|
||||
|
||||
SET(BUILD_EXTENSION_PYTHON FALSE CACHE BOOL "Build extension for Python")
|
||||
IF(BUILD_EXTENSION_PYTHON)
|
||||
ADD_SUBDIRECTORY(python)
|
||||
ENDIF(BUILD_EXTENSION_PYTHON)
|
||||
|
||||
# ADD_SUBDIRECTORY(ruby)
|
||||
|
18
driver/bindings/java/CMakeLists.txt
Normal file
18
driver/bindings/java/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
#### JAVA ####
|
||||
FIND_PACKAGE(SWIG REQUIRED)
|
||||
FIND_PACKAGE(Java)
|
||||
FIND_PACKAGE(JNI)
|
||||
|
||||
INCLUDE(${SWIG_USE_FILE})
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${JAVA_INCLUDE_PATH} ${JNI_INCLUDE_DIRS})
|
||||
|
||||
SET(CMAKE_SWIG_FLAGS "")
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES CPLUSPLUS OFF)
|
||||
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES SWIG_FLAGS "-includeall")
|
||||
|
||||
SWIG_ADD_MODULE(tellduscore java ../tellduscore.i)
|
||||
SWIG_LINK_LIBRARIES(tellduscore telldus-core ${JNI_LIBRARIES})
|
||||
|
22
driver/bindings/python/CMakeLists.txt
Normal file
22
driver/bindings/python/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
#### PYTHON ####
|
||||
FIND_PACKAGE(SWIG REQUIRED)
|
||||
FIND_PACKAGE(PythonInterp)
|
||||
FIND_PACKAGE(PythonLibs)
|
||||
|
||||
INCLUDE(${SWIG_USE_FILE})
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_INCLUDE_PATH})
|
||||
|
||||
SET(CMAKE_SWIG_FLAGS "")
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES CPLUSPLUS OFF)
|
||||
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES SWIG_FLAGS "-includeall")
|
||||
|
||||
SWIG_ADD_MODULE(tellduscore python ../tellduscore.i)
|
||||
SWIG_LINK_LIBRARIES(tellduscore telldus-core ${PYTHON_LIBRARIES})
|
||||
|
||||
EXECUTE_PROCESS( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_MODULE_tellduscore_REAL_NAME}.so DESTINATION ${PYTHON_SITE_PACKAGES})
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tellduscore.py DESTINATION ${PYTHON_SITE_PACKAGES})
|
||||
|
6
driver/bindings/tellduscore.i
Normal file
6
driver/bindings/tellduscore.i
Normal file
|
@ -0,0 +1,6 @@
|
|||
%module tellduscore
|
||||
%{
|
||||
#include "../../libtelldus-core/telldus-core.h"
|
||||
%}
|
||||
|
||||
%include "../../libtelldus-core/telldus-core.h"
|
2
driver/libtelldus-core/99-tellstick.rules
Normal file
2
driver/libtelldus-core/99-tellstick.rules
Normal file
|
@ -0,0 +1,2 @@
|
|||
KERNEL=="ttyUSB*", BUS=="usb", SYSFS{idVendor}=="1781", SYSFS{idProduct}=="0c30", NAME="tellstick", GROUP="plugdev"
|
||||
|
205
driver/libtelldus-core/CMakeLists.txt
Normal file
205
driver/libtelldus-core/CMakeLists.txt
Normal file
|
@ -0,0 +1,205 @@
|
|||
FIND_PACKAGE( Qt4 REQUIRED )
|
||||
SET( QT_DONT_USE_QTGUI TRUE )
|
||||
INCLUDE( ${QT_USE_FILE} )
|
||||
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
endif(COMMAND cmake_policy)
|
||||
|
||||
######## Non configurable options ########
|
||||
SET( telldus-core_SRCS
|
||||
Device.cpp
|
||||
DeviceBrateck.cpp
|
||||
DeviceEverflourish.cpp
|
||||
DeviceGroup.cpp
|
||||
DeviceIkea.cpp
|
||||
DeviceNexa.cpp
|
||||
DeviceRisingSun.cpp
|
||||
DeviceSartano.cpp
|
||||
DeviceUndefined.cpp
|
||||
DeviceUpm.cpp
|
||||
DeviceWaveman.cpp
|
||||
DeviceX10.cpp
|
||||
Controller.cpp
|
||||
Manager.cpp
|
||||
Settings.cpp
|
||||
telldus-core.cpp
|
||||
)
|
||||
|
||||
SET( telldus-core_HDRS
|
||||
telldus-core.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/config.h
|
||||
)
|
||||
|
||||
SET( telldus-core_MOC_HDRS
|
||||
)
|
||||
|
||||
QT4_WRAP_CPP( telldus-core_MOC_SRCS ${telldus-core_MOC_HDRS} )
|
||||
QT4_AUTOMOC ( ${telldus-core_SRCS} )
|
||||
|
||||
|
||||
SET( telldus-core_LIBRARIES
|
||||
${QT_LIBRARIES}
|
||||
)
|
||||
|
||||
IF (SUPPORT_USB)
|
||||
FIND_LIBRARY(FTD2XX_LIBRARY ftd2xx)
|
||||
|
||||
SET( telldus-core_LIBRARIES
|
||||
${telldus-core_LIBRARIES}
|
||||
${FTD2XX_LIBRARY}
|
||||
)
|
||||
ENDIF (SUPPORT_USB)
|
||||
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/config.h
|
||||
)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
|
||||
######## Configurable options for the platform ########
|
||||
|
||||
#### TellStickDuo ####
|
||||
IF (SUPPORT_TELLSTICK_DUO)
|
||||
#Only build library agains libftdi for TellStick Duo
|
||||
FIND_LIBRARY(FTDI_LIBRARY ftdi)
|
||||
SET( telldus-core_LIBRARIES
|
||||
${telldus-core_LIBRARIES}
|
||||
${FTDI_LIBRARY}
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS( -DTELLSTICK_DUO )
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
TellStickDuo.cpp
|
||||
)
|
||||
ENDIF(SUPPORT_TELLSTICK_DUO)
|
||||
|
||||
#### Settings backend ####
|
||||
IF(USE_QT_SETTINGS_BACKEND)
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
SettingsQt.cpp
|
||||
)
|
||||
ELSE (USE_QT_SETTINGS_BACKEND)
|
||||
IF (APPLE)
|
||||
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||
|
||||
SET( telldus-core_LIBRARIES
|
||||
${telldus-core_LIBRARIES}
|
||||
${COREFOUNDATION_LIBRARY}
|
||||
)
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
SettingsCoreFoundationPreferences.cpp
|
||||
)
|
||||
ELSEIF (WIN32)
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
SettingsWinRegistry.cpp
|
||||
)
|
||||
ELSE (APPLE)
|
||||
SET( telldus-core_LIBRARIES
|
||||
${telldus-core_LIBRARIES}
|
||||
confuse
|
||||
)
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
SettingsConfuse.cpp
|
||||
)
|
||||
ADD_DEFINITIONS( -D_CONFUSE )
|
||||
ENDIF (APPLE)
|
||||
ENDIF(USE_QT_SETTINGS_BACKEND)
|
||||
|
||||
|
||||
|
||||
######## Platforms-specific, non configurable ########
|
||||
|
||||
IF (APPLE)
|
||||
#### Mac OS X ####
|
||||
SET( telldus-core_TARGET TelldusCore )
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
win/Device.cpp
|
||||
)
|
||||
ADD_DEFINITIONS(
|
||||
-D_MACOSX
|
||||
)
|
||||
ELSEIF (WIN32)
|
||||
#### Windows ####
|
||||
SET( telldus-core_TARGET TelldusCore )
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
win/Device.cpp
|
||||
libtelldus-core.def
|
||||
)
|
||||
ADD_DEFINITIONS(
|
||||
-D_WINDOWS
|
||||
-DTELLDUSCORE_EXPORTS
|
||||
)
|
||||
ELSE (APPLE)
|
||||
#### Linux ####
|
||||
SET( telldus-core_TARGET telldus-core )
|
||||
SET( telldus-core_SRCS
|
||||
${telldus-core_SRCS}
|
||||
linux/Device.cpp
|
||||
)
|
||||
ADD_DEFINITIONS(
|
||||
-D_LINUX
|
||||
)
|
||||
ENDIF (APPLE)
|
||||
|
||||
|
||||
|
||||
######## Configuring ########
|
||||
|
||||
ADD_LIBRARY(${telldus-core_TARGET} SHARED
|
||||
${telldus-core_SRCS}
|
||||
${telldus-core_HDRS}
|
||||
${telldus-core_MOC_SRCS}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES( ${telldus-core_TARGET} ${telldus-core_LIBRARIES} )
|
||||
|
||||
SET_PROPERTY(TARGET ${telldus-core_TARGET}
|
||||
PROPERTY FRAMEWORK TRUE
|
||||
)
|
||||
SET_PROPERTY(TARGET ${telldus-core_TARGET}
|
||||
PROPERTY PUBLIC_HEADER ${telldus-core_HDRS}
|
||||
)
|
||||
|
||||
SET_PROPERTY(TARGET ${telldus-core_TARGET}
|
||||
PROPERTY VERSION ${PACKAGE_VERSION}
|
||||
)
|
||||
SET_PROPERTY(TARGET ${telldus-core_TARGET}
|
||||
PROPERTY SOVERSION ${PACKAGE_SOVERSION}
|
||||
)
|
||||
|
||||
IF (NOT LIBRARY_DIR)
|
||||
SET(LIBRARY_DIR "lib")
|
||||
ENDIF (NOT LIBRARY_DIR)
|
||||
|
||||
IF (UNIX)
|
||||
INSTALL(TARGETS ${telldus-core_TARGET}
|
||||
LIBRARY DESTINATION ${LIBRARY_DIR}
|
||||
FRAMEWORK DESTINATION "/Library/Frameworks"
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
)
|
||||
ENDIF (UNIX)
|
||||
|
||||
IF (UNIX AND NOT APPLE)
|
||||
SET(SYSCONF_INSTALL_DIR "/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
|
||||
SET(STATE_INSTALL_DIR "/var/state" CACHE PATH "The directory to store state information of the devices" )
|
||||
SET(UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
|
||||
|
||||
INSTALL(FILES tellstick.conf
|
||||
DESTINATION ${SYSCONF_INSTALL_DIR}
|
||||
)
|
||||
INSTALL(FILES telldus-core.conf
|
||||
DESTINATION ${STATE_INSTALL_DIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
|
||||
)
|
||||
INSTALL(FILES 99-tellstick.rules
|
||||
DESTINATION ${UDEV_RULES_DIR}
|
||||
)
|
||||
ENDIF (UNIX AND NOT APPLE)
|
25
driver/libtelldus-core/Controller.cpp
Normal file
25
driver/libtelldus-core/Controller.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// C++ Implementation: controller
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Micke Prag <micke.prag@telldus.se>, (C) 2009
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include "Controller.h"
|
||||
|
||||
using namespace TelldusCore;
|
||||
|
||||
Controller::Controller()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Controller::~Controller()
|
||||
{
|
||||
}
|
||||
|
||||
|
34
driver/libtelldus-core/Controller.h
Normal file
34
driver/libtelldus-core/Controller.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// C++ Interface: controller
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Micke Prag <micke.prag@telldus.se>, (C) 2009
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#ifndef CONTROLLER_H
|
||||
#define CONTROLLER_H
|
||||
|
||||
#include <string>
|
||||
#include <QObject>
|
||||
|
||||
/**
|
||||
@author Micke Prag <micke.prag@telldus.se>
|
||||
*/
|
||||
namespace TelldusCore {
|
||||
class Controller {
|
||||
public:
|
||||
virtual ~Controller();
|
||||
|
||||
virtual int firmwareVersion() = 0;
|
||||
virtual int send( const std::string &message ) = 0;
|
||||
|
||||
protected:
|
||||
Controller();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
160
driver/libtelldus-core/Device.cpp
Normal file
160
driver/libtelldus-core/Device.cpp
Normal file
|
@ -0,0 +1,160 @@
|
|||
#include "Device.h"
|
||||
#include "Manager.h"
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
|
||||
using namespace TelldusCore;
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
Device::Device(int id, const std::string m, const std::string &name)
|
||||
: deviceId(id),
|
||||
deviceName(name),
|
||||
model(m)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
Device::~Device(void) {
|
||||
}
|
||||
|
||||
int Device::switchState( int newState, const std::string &value ) {
|
||||
int retVal = TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
|
||||
if (!Device::maskUnsupportedMethods(this->methods(), newState)) {
|
||||
return retVal;
|
||||
}
|
||||
std::string stateValue = "";
|
||||
|
||||
switch (newState) {
|
||||
case TELLSTICK_TURNON:
|
||||
retVal = turnOn();
|
||||
break;
|
||||
case TELLSTICK_TURNOFF:
|
||||
retVal = turnOff();
|
||||
break;
|
||||
case TELLSTICK_BELL:
|
||||
retVal = bell();
|
||||
break;
|
||||
case TELLSTICK_LEARN:
|
||||
retVal = learn();
|
||||
break;
|
||||
case TELLSTICK_DIM:
|
||||
//Convert value to string
|
||||
unsigned char v = value[0];
|
||||
std::stringstream st;
|
||||
st << (int)v;
|
||||
stateValue = st.str();
|
||||
|
||||
retVal = dim( v );
|
||||
break;
|
||||
}
|
||||
if (retVal == TELLSTICK_SUCCESS) {
|
||||
Manager *manager = Manager::getInstance();
|
||||
manager->setDeviceState(deviceId, newState, stateValue);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::string Device::getModel() const {
|
||||
std::string strModel = model;
|
||||
//Strip anything after : if it is found
|
||||
size_t pos = strModel.find(":");
|
||||
if (pos != std::string::npos) {
|
||||
strModel = strModel.substr(0, pos);
|
||||
}
|
||||
|
||||
return strModel;
|
||||
}
|
||||
|
||||
std::string Device::getFullModel() const {
|
||||
return model;
|
||||
}
|
||||
|
||||
bool Device::setModel( const std::string &strModel ) {
|
||||
Manager *manager = Manager::getInstance();
|
||||
if (manager->setDeviceModel( deviceId, strModel )) {
|
||||
model = strModel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Device::setParameter(const std::string &strName, const std::string &strValue) {
|
||||
if (setDeviceParameter( strName, strValue )) {
|
||||
Manager *manager = Manager::getInstance();
|
||||
return manager->setDeviceParameter(deviceId, strName, strValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn on, virtual
|
||||
*/
|
||||
int Device::turnOn(void){
|
||||
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off, virtual
|
||||
*/
|
||||
int Device::turnOff(void){
|
||||
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bell, virtual
|
||||
*/
|
||||
int Device::bell(void){
|
||||
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dim, virtual
|
||||
*/
|
||||
int Device::dim(unsigned char level){
|
||||
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int Device::learn(void) {
|
||||
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int Device::methodId( const std::string &methodName ) {
|
||||
if (methodName.compare("turnon") == 0) {
|
||||
return TELLSTICK_TURNON;
|
||||
}
|
||||
if (methodName.compare("turnoff") == 0) {
|
||||
return TELLSTICK_TURNOFF;
|
||||
}
|
||||
if (methodName.compare("bell") == 0) {
|
||||
return TELLSTICK_BELL;
|
||||
}
|
||||
if (methodName.compare("dim") == 0) {
|
||||
return TELLSTICK_DIM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string Device::getName() const {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
bool Device::setName(const std::string & newName) {
|
||||
Manager *manager = Manager::getInstance();
|
||||
if (manager->setDeviceName(deviceId, newName)) {
|
||||
deviceName = newName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int TelldusCore::Device::maskUnsupportedMethods(int methods, int supportedMethods) {
|
||||
// Bell -> On
|
||||
if ((methods & TELLSTICK_BELL) && !(supportedMethods & TELLSTICK_BELL)) {
|
||||
methods |= TELLSTICK_TURNON;
|
||||
}
|
||||
//Cut of the rest of the unsupported methods we don't have a fallback for
|
||||
return methods & supportedMethods;
|
||||
}
|
51
driver/libtelldus-core/Device.h
Normal file
51
driver/libtelldus-core/Device.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#pragma once
|
||||
|
||||
#include "telldus-core.h"
|
||||
#include <string>
|
||||
//#include <QMutex>
|
||||
|
||||
namespace TelldusCore {
|
||||
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
Device(int id, const std::string model, const std::string &name);
|
||||
virtual ~Device(void);
|
||||
|
||||
int switchState( int newState, const std::string &value = "" );
|
||||
virtual int methods() = 0;
|
||||
virtual std::string getProtocol() const = 0;
|
||||
virtual bool parameterMatches( const std::string &name, const std::string &value ) const = 0;
|
||||
bool setParameter(const std::string &strName, const std::string &strValue);
|
||||
|
||||
std::string getModel() const;
|
||||
std::string getFullModel() const;
|
||||
bool setModel( const std::string & strModel );
|
||||
std::string getName() const;
|
||||
bool setName( const std::string &newName );
|
||||
|
||||
static int methodId( const std::string &methodName );
|
||||
static int maskUnsupportedMethods( int methods, int supportedMethods );
|
||||
|
||||
#ifdef _LINUX
|
||||
void setDevice(const std::string &device);
|
||||
protected:
|
||||
std::string strDevice;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue) = 0;
|
||||
virtual int turnOn(void);
|
||||
virtual int turnOff(void);
|
||||
virtual int bell(void);
|
||||
virtual int dim(unsigned char level);
|
||||
virtual int learn(void);
|
||||
int send(const std::string &strMessage);
|
||||
|
||||
private:
|
||||
int deviceId;
|
||||
std::string deviceName, model;
|
||||
// static QMutex deviceMutex;
|
||||
};
|
||||
|
||||
}
|
119
driver/libtelldus-core/DeviceBrateck.cpp
Normal file
119
driver/libtelldus-core/DeviceBrateck.cpp
Normal file
|
@ -0,0 +1,119 @@
|
|||
#include "DeviceBrateck.h"
|
||||
#include <string>
|
||||
#include <bitset>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
using namespace TelldusCore;
|
||||
|
||||
const char S = '!';
|
||||
const char L = 'V';
|
||||
const char B1[] = {L,S,L,S,0};
|
||||
const char BX[] = {S,L,L,S,0};
|
||||
const char B0[] = {S,L,S,L,0};
|
||||
const char BUP[] = {L,S,L,S,S,L,S,L,S,L,S,L,S,L,S,L,S,0};
|
||||
const char BSTOP[] = {S,L,S,L,L,S,L,S,S,L,S,L,S,L,S,L,S,0};
|
||||
const char BDOWN[] = {S,L,S,L,S,L,S,L,S,L,S,L,L,S,L,S,S,0};
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
DeviceBrateck::DeviceBrateck(int id, const std::string &model, const std::string &name)
|
||||
:Device(id, model, name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DeviceBrateck::~DeviceBrateck(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool DeviceBrateck::setHouse(const std::string &strNewHouse) {
|
||||
strHouse = strNewHouse;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceBrateck::setDeviceParameter(const std::string &strName, const std::string &strValue) {
|
||||
if (strName.compare("house") == 0) {
|
||||
return setHouse(strValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn on this device
|
||||
*/
|
||||
int DeviceBrateck::turnOn(void){
|
||||
|
||||
try{
|
||||
std::string strCode = getStringCode();
|
||||
|
||||
strCode.insert(0, "S");
|
||||
strCode.append(BUP);
|
||||
strCode.append("+"); //the "turn on"-code!
|
||||
|
||||
return Device::send(strCode);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceBrateck::turnOff(void){
|
||||
|
||||
try{
|
||||
std::string strCode = getStringCode();
|
||||
|
||||
strCode.insert(0, "S");
|
||||
strCode.append(BDOWN);
|
||||
strCode.append("+"); //the "turn off"-code!
|
||||
|
||||
return Device::send(strCode);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
bool DeviceBrateck::parameterMatches( const std::string &name, const std::string &value ) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Has the device got the method?
|
||||
*/
|
||||
int DeviceBrateck::methods(){
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
|
||||
}
|
||||
|
||||
std::string DeviceBrateck::getStringCode(void){
|
||||
|
||||
std::string strReturn;
|
||||
|
||||
try{
|
||||
for( size_t i = 0; i < strHouse.length(); ++i ) {
|
||||
if (strHouse[i] == '1') {
|
||||
strReturn.insert(0, B1);
|
||||
} else if (strHouse[i] == '-') {
|
||||
strReturn.insert(0, BX);
|
||||
} else if (strHouse[i] == '0') {
|
||||
strReturn.insert(0, B0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return strReturn;
|
||||
|
||||
}
|
||||
|
||||
std::string DeviceBrateck::getProtocol() const {
|
||||
return "brateck";
|
||||
}
|
||||
|
29
driver/libtelldus-core/DeviceBrateck.h
Normal file
29
driver/libtelldus-core/DeviceBrateck.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
#include "Device.h"
|
||||
#include <string>
|
||||
|
||||
namespace TelldusCore {
|
||||
|
||||
class DeviceBrateck : public Device
|
||||
{
|
||||
public:
|
||||
DeviceBrateck(int id, const std::string &model, const std::string &name);
|
||||
virtual ~DeviceBrateck(void);
|
||||
|
||||
virtual int methods();
|
||||
virtual std::string getProtocol() const;
|
||||
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
|
||||
|
||||
bool setHouse(const std::string &strNewHouse);
|
||||
|
||||
protected:
|
||||
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
|
||||
|
||||
virtual int turnOn(void);
|
||||
virtual int turnOff(void);
|
||||
|
||||
std::string getStringCode(void);
|
||||
std::string strHouse;
|
||||
};
|
||||
|
||||
}
|
184
driver/libtelldus-core/DeviceEverflourish.cpp
Normal file
184
driver/libtelldus-core/DeviceEverflourish.cpp
Normal file
|
@ -0,0 +1,184 @@
|
|||
#include "DeviceEverflourish.h"
|
||||
#include "common.h"
|
||||
|
||||
using namespace TelldusCore;
|
||||
|
||||
const unsigned char ON = 15;
|
||||
const unsigned char OFF = 0;
|
||||
const unsigned char LEARN = 10;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
DeviceEverflourish::DeviceEverflourish(int id, const std::string &model, const std::string &name)
|
||||
:Device(id, model, name),
|
||||
intHouse(0),
|
||||
intCode(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
DeviceEverflourish::~DeviceEverflourish(void)
|
||||
{}
|
||||
|
||||
bool DeviceEverflourish::setHouse(const std::string &newHouse) {
|
||||
if (newHouse.length() > 0) {
|
||||
intHouse = atoi(newHouse.c_str());
|
||||
} else {
|
||||
intHouse = 0;
|
||||
}
|
||||
if (intHouse < 0) {
|
||||
intHouse = 0;
|
||||
} else if (intHouse > 16383) {
|
||||
intHouse = 16383;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceEverflourish::setUnit(const std::string &newUnit) {
|
||||
if (newUnit.length() > 0) {
|
||||
intCode = atoi(newUnit.c_str()) - 1;
|
||||
} else {
|
||||
intCode = 0;
|
||||
}
|
||||
if (intCode < 0) {
|
||||
intCode = 0;
|
||||
} else if (intCode > 3) {
|
||||
intCode = 3;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceEverflourish::setDeviceParameter(const std::string &strName, const std::string &strValue) {
|
||||
if (strName.compare("house") == 0) {
|
||||
return setHouse(strValue);
|
||||
} else if (strName.compare("unit") == 0) {
|
||||
return setUnit(strValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn on this device
|
||||
*/
|
||||
int DeviceEverflourish::turnOn(void){
|
||||
try{
|
||||
std::string strCode = getCode(ON);
|
||||
return Device::send(strCode);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceEverflourish::turnOff(void){
|
||||
try{
|
||||
std::string strCode = getCode(OFF);
|
||||
return Device::send(strCode);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
int DeviceEverflourish::learn(void){
|
||||
try{
|
||||
std::string strCode = getCode(LEARN);
|
||||
return Device::send(strCode);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
bool DeviceEverflourish::parameterMatches( const std::string &name, const std::string &value ) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Has the device got the method?
|
||||
*/
|
||||
int DeviceEverflourish::methods(){
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
|
||||
}
|
||||
|
||||
std::string DeviceEverflourish::getProtocol() const {
|
||||
return "arctech";
|
||||
}
|
||||
|
||||
std::string DeviceEverflourish::getCode(unsigned char action) {
|
||||
unsigned int deviceCode = intHouse;
|
||||
|
||||
const char ssss = 85;
|
||||
const char sssl = 84; // 0
|
||||
const char slss = 69; // 1
|
||||
|
||||
const char bits[2] = {sssl,slss};
|
||||
int i, check;
|
||||
|
||||
std::string strCode;
|
||||
|
||||
deviceCode = (deviceCode << 2) | intCode;
|
||||
|
||||
check = calculateChecksum(deviceCode);
|
||||
|
||||
char preamble[] = {'R', 5, 'T', 114,60,1,1,105,ssss,ssss,0};
|
||||
strCode.append(preamble);
|
||||
|
||||
for(i=15;i>=0;i--) {
|
||||
strCode.append(1, bits[(deviceCode>>i)&0x01]);
|
||||
}
|
||||
for(i=3;i>=0;i--) {
|
||||
strCode.append(1, bits[(check>>i)&0x01]);
|
||||
}
|
||||
for(i=3;i>=0;i--) {
|
||||
strCode.append(1, bits[(action>>i)&0x01]);
|
||||
}
|
||||
|
||||
strCode.append(1, ssss);
|
||||
strCode.append(1, '+');
|
||||
|
||||
return strCode;
|
||||
}
|
||||
|
||||
// The calculation used in this function is provided by Frank Stevenson
|
||||
unsigned int DeviceEverflourish::calculateChecksum(unsigned int x) {
|
||||
unsigned int bits[16] = {
|
||||
0xf ,0xa ,0x7 ,0xe,
|
||||
0xf ,0xd ,0x9 ,0x1,
|
||||
0x1 ,0x2 ,0x4 ,0x8,
|
||||
0x3 ,0x6 ,0xc ,0xb
|
||||
};
|
||||
unsigned int bit = 1;
|
||||
unsigned int res = 0x5;
|
||||
int i;
|
||||
unsigned int lo,hi;
|
||||
|
||||
if ((x&0x3)==3) {
|
||||
lo = x & 0x00ff;
|
||||
hi = x & 0xff00;
|
||||
lo += 4;
|
||||
if (lo>0x100) {
|
||||
lo = 0x12;
|
||||
}
|
||||
x = lo | hi;
|
||||
}
|
||||
|
||||
for(i=0;i<16;i++) {
|
||||
if (x&bit) {
|
||||
res = res ^ bits[i];
|
||||
}
|
||||
bit = bit << 1;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
38
driver/libtelldus-core/DeviceEverflourish.h
Normal file
38
driver/libtelldus-core/DeviceEverflourish.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef DEVICEEVERFLOURISH_H
|
||||
#define DEVICEEVERFLOURISH_H
|
||||
|
||||
#include "Device.h"
|
||||
#include <string>
|
||||
|
||||
namespace TelldusCore {
|
||||
|
||||
class DeviceEverflourish : public Device
|
||||
{
|
||||
public:
|
||||
DeviceEverflourish(int id, const std::string &model, const std::string &name);
|
||||
virtual int methods();
|
||||
virtual std::string getProtocol() const;
|
||||
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
|
||||
|
||||
bool setHouse(const std::string &newHouse);
|
||||
bool setUnit(const std::string &newUnit);
|
||||
|
||||
public:
|
||||
~DeviceEverflourish(void);
|
||||
|
||||
protected:
|
||||
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
|
||||
virtual int turnOn(void);
|
||||
virtual int turnOff(void);
|
||||
virtual int learn(void);
|
||||
|
||||
int intHouse;
|
||||
int intCode;
|
||||
|
||||
std::string getCode(unsigned char action);
|
||||
static unsigned int calculateChecksum(unsigned int x);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //DEVICEEVERFLOURISH_H
|
145
driver/libtelldus-core/DeviceGroup.cpp
Normal file
145
driver/libtelldus-core/DeviceGroup.cpp
Normal file
|
@ -0,0 +1,145 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "DeviceGroup.h"
|
||||
#include "Manager.h"
|
||||
|
||||
using namespace TelldusCore;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
DeviceGroup::DeviceGroup(int id, const std::string &model, const std::string &name)
|
||||
:Device(id, model, name)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
DeviceGroup::~DeviceGroup(void) {
|
||||
}
|
||||
|
||||
bool DeviceGroup::setDeviceParameter(const std::string &strName, const std::string &strValue) {
|
||||
if (strName.compare("devices") == 0) {
|
||||
return setDevices(strValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeviceGroup::setDevices(const std::string &newDevices) {
|
||||
/* if (strDevices.length() > 0) {
|
||||
char *tempDevices = new char[strDevices.size()+1];
|
||||
#ifdef _WINDOWS
|
||||
strcpy_s(tempDevices, strDevices.size()+1, strDevices.c_str());
|
||||
#else
|
||||
strcpy(tempDevices, strDevices.c_str());
|
||||
#endif
|
||||
|
||||
Manager *manager = Manager::getInstance();
|
||||
char *strToken = strtok(tempDevices, ",");
|
||||
do {
|
||||
int intDevice = atoi(strToken);
|
||||
Device *device = manager->getDevice(intDevice);
|
||||
if (device != NULL) {
|
||||
deviceList.push_back( device );
|
||||
}
|
||||
} while ( (strToken = strtok(NULL, ",")) != NULL );
|
||||
|
||||
free(tempDevices);
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn on this device
|
||||
*/
|
||||
int DeviceGroup::turnOn(void) {
|
||||
int retVal = TELLSTICK_ERROR_UNKNOWN;
|
||||
|
||||
for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
|
||||
int methods = (*it)->methods();
|
||||
if (methods & TELLSTICK_TURNON) {
|
||||
int success = (*it)->switchState( TELLSTICK_TURNON );
|
||||
if (retVal != TELLSTICK_SUCCESS) {
|
||||
retVal = success;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceGroup::turnOff(void) {
|
||||
int retVal = TELLSTICK_ERROR_UNKNOWN;
|
||||
|
||||
for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
|
||||
int methods = (*it)->methods();
|
||||
if (methods & TELLSTICK_TURNOFF) {
|
||||
int success = (*it)->switchState( TELLSTICK_TURNOFF );
|
||||
if (retVal != TELLSTICK_SUCCESS) {
|
||||
retVal = success;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a bell
|
||||
*/
|
||||
int DeviceGroup::bell(void){
|
||||
int retVal = TELLSTICK_ERROR_UNKNOWN;
|
||||
|
||||
for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
|
||||
int methods = (*it)->methods();
|
||||
if (methods & TELLSTICK_BELL) {
|
||||
int success = (*it)->switchState( TELLSTICK_BELL );
|
||||
if (retVal != TELLSTICK_SUCCESS) {
|
||||
retVal = success;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceGroup::dim(unsigned char level){
|
||||
int retVal = TELLSTICK_ERROR_UNKNOWN;
|
||||
|
||||
for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
|
||||
int methods = (*it)->methods();
|
||||
if (methods & TELLSTICK_DIM) {
|
||||
int success = (*it)->switchState( TELLSTICK_DIM, (char*)&level);
|
||||
if (retVal != TELLSTICK_SUCCESS) {
|
||||
retVal = success;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool DeviceGroup::parameterMatches( const std::string &name, const std::string &value ) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Has the device got the method?
|
||||
*/
|
||||
int DeviceGroup::methods(){
|
||||
int retVal = 0;
|
||||
|
||||
for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
|
||||
retVal = retVal | (*it)->methods();
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
std::string DeviceGroup::getProtocol() const {
|
||||
return "group";
|
||||
}
|
||||
|
36
driver/libtelldus-core/DeviceGroup.h
Normal file
36
driver/libtelldus-core/DeviceGroup.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include "Device.h"
|
||||
#include <string.h>
|
||||
#include <list>
|
||||
|
||||
class Controller;
|
||||
|
||||
namespace TelldusCore {
|
||||
|
||||
typedef std::list<Device *> DeviceList;
|
||||
|
||||
class DeviceGroup : public Device
|
||||
{
|
||||
public:
|
||||
DeviceGroup(int id, const std::string &model, const std::string &name);
|
||||
~DeviceGroup(void);
|
||||
|
||||
virtual int methods();
|
||||
virtual std::string getProtocol() const;
|
||||
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
|
||||
|
||||
bool setDevices(const std::string &newDevices);
|
||||
|
||||
protected:
|
||||
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
|
||||
|
||||
virtual int turnOn(void);
|
||||
virtual int turnOff(void);
|
||||
virtual int bell(void);
|
||||
virtual int dim(unsigned char level);
|
||||
|
||||
private:
|
||||
DeviceList deviceList;
|
||||
};
|
||||
|
||||
}
|
233
driver/libtelldus-core/DeviceIkea.cpp
Normal file
233
driver/libtelldus-core/DeviceIkea.cpp
Normal file
|
@ -0,0 +1,233 @@
|
|||
// #include "StdAfx.h" //Needed?
|
||||
#include "DeviceIkea.h"
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define strcasecmp(x, y) _strcmpi(x, y)
|
||||
#endif
|
||||
|
||||
using namespace TelldusCore;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
DeviceIkea::DeviceIkea(int id, const std::string &model, const std::string &name)
|
||||
:Device(id, model, name)
|
||||
{
|
||||
}
|
||||
|
||||
bool DeviceIkea::setSystem(const std::string &strSystem) {
|
||||
if (strSystem.length() > 0) {
|
||||
intSystem = atoi(strSystem.c_str()) - 1;
|
||||
} else {
|
||||
intSystem = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceIkea::setUnits(const std::string &strUnits) {
|
||||
if (strUnits.length() > 0) {
|
||||
intUnits = 0; //Start without any units
|
||||
|
||||
char *tempUnits = new char[strUnits.size()+1];
|
||||
#ifdef _WINDOWS
|
||||
strcpy_s(tempUnits, strUnits.size()+1, strUnits.c_str());
|
||||
#else
|
||||
strcpy(tempUnits, strUnits.c_str());
|
||||
#endif
|
||||
|
||||
char *strToken = strtok(tempUnits, ",");
|
||||
do {
|
||||
int intUnit = atoi(strToken);
|
||||
if (intUnit == 10) {
|
||||
intUnit = 0;
|
||||
}
|
||||
intUnits = intUnits | ( 1<<(9-intUnit) );
|
||||
} while ( (strToken = strtok(NULL, ",")) != NULL );
|
||||
|
||||
free(tempUnits);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceIkea::setFade(const std::string &strFadeStyle) {
|
||||
if (strFadeStyle.length() > 0 && strcasecmp(strFadeStyle.c_str(), "true") == 0) {
|
||||
intFadeStyle = 1;
|
||||
} else {
|
||||
intFadeStyle = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
DeviceIkea::~DeviceIkea(void)
|
||||
{
|
||||
intSystem = -1;
|
||||
intUnits = -1;
|
||||
intFadeStyle = -1;
|
||||
}
|
||||
|
||||
bool DeviceIkea::setDeviceParameter(const std::string &strName, const std::string &strValue) {
|
||||
if (strName.compare("system") == 0) {
|
||||
return setSystem(strValue);
|
||||
} else if (strName.compare("units") == 0) {
|
||||
return setUnits(strValue);
|
||||
} else if (strName.compare("fade") == 0) {
|
||||
return setFade(strValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn on this device
|
||||
*/
|
||||
int DeviceIkea::turnOn(void){
|
||||
try{
|
||||
std::string strMessage = getStringCode(255);
|
||||
|
||||
return Device::send(strMessage);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceIkea::turnOff(void){
|
||||
try{
|
||||
std::string strMessage = getStringCode(0);
|
||||
|
||||
return Device::send(strMessage);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceIkea::dim(unsigned char level){
|
||||
try{
|
||||
std::string strMessage = getStringCode(level);
|
||||
|
||||
return Device::send(strMessage);
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an integer to byte string where 0 is represented by ª and 1 by TT
|
||||
*/
|
||||
std::string DeviceIkea::getStringCode(unsigned char level){
|
||||
|
||||
std::string strReturn = "STTTTTTª"; //Startcode, always like this;
|
||||
|
||||
try{
|
||||
std::string strChannels = "";
|
||||
int intCode = (intSystem << 10) | intUnits;
|
||||
int checksum1 = 0;
|
||||
int checksum2 = 0;
|
||||
for (int i = 13; i >= 0; --i) {
|
||||
if ((intCode>>i) & 1) {
|
||||
strChannels.append("TT");
|
||||
if (i % 2 == 0)
|
||||
checksum2++;
|
||||
else
|
||||
checksum1++;
|
||||
} else {
|
||||
strChannels.append("ª");
|
||||
}
|
||||
}
|
||||
strReturn.append(strChannels); //System + Units
|
||||
|
||||
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); //1st checksum
|
||||
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); //2nd checksum
|
||||
|
||||
int intLevel = 0;
|
||||
if (level <= 12) {
|
||||
intLevel = 10; // Level 10 is actually off
|
||||
} else if (level <= 37) {
|
||||
intLevel = 1;
|
||||
} else if (level <= 62) {
|
||||
intLevel = 2;
|
||||
} else if (level <= 87) {
|
||||
intLevel = 3;
|
||||
} else if (level <= 112) {
|
||||
intLevel = 4;
|
||||
} else if (level <= 137) {
|
||||
intLevel = 5;
|
||||
} else if (level <= 162) {
|
||||
intLevel = 6;
|
||||
} else if (level <= 187) {
|
||||
intLevel = 7;
|
||||
} else if (level <= 212) {
|
||||
intLevel = 8;
|
||||
} else if (level <= 237) {
|
||||
intLevel = 9;
|
||||
} else {
|
||||
intLevel = 0; // Level 0 is actually full on
|
||||
}
|
||||
|
||||
int intFade = 0;
|
||||
if (intFadeStyle == 1) {
|
||||
intFade = 11 << 4; //Smooth
|
||||
} else {
|
||||
intFade = 1 << 4; //Instant
|
||||
}
|
||||
|
||||
intCode = intLevel | intFade; //Concat level and fade
|
||||
|
||||
checksum1 = 0;
|
||||
checksum2 = 0;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if ((intCode>>i) & 1) {
|
||||
strReturn.append("TT");
|
||||
if (i % 2 == 0)
|
||||
checksum1++;
|
||||
else
|
||||
checksum2++;
|
||||
} else {
|
||||
strReturn.append("ª");
|
||||
}
|
||||
}
|
||||
|
||||
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); //1st checksum
|
||||
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); //2nd checksum
|
||||
|
||||
strReturn.append("+");
|
||||
}
|
||||
catch(...){
|
||||
throw;
|
||||
}
|
||||
return strReturn;
|
||||
|
||||
}
|
||||
|
||||
bool DeviceIkea::parameterMatches( const std::string &name, const std::string &value ) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Has the device got the method?
|
||||
*/
|
||||
int DeviceIkea::methods(){
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM);
|
||||
}
|
||||
|
||||
std::string DeviceIkea::getProtocol() const {
|
||||
return "ikea";
|
||||
}
|
34
driver/libtelldus-core/DeviceIkea.h
Normal file
34
driver/libtelldus-core/DeviceIkea.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#include "Device.h"
|
||||
#include <string>
|
||||
|
||||
namespace TelldusCore {
|
||||
|
||||
class DeviceIkea : public Device
|
||||
{
|
||||
public:
|
||||
DeviceIkea(int id, const std::string &model, const std::string &name);
|
||||
virtual ~DeviceIkea(void);
|
||||
|
||||
virtual int methods();
|
||||
virtual std::string getProtocol() const;
|
||||
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
|
||||
|
||||
bool setSystem(const std::string &strSystem);
|
||||
bool setUnits(const std::string &strUnits);
|
||||
bool setFade(const std::string &strFade);
|
||||
|
||||
protected:
|
||||
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
|
||||
|
||||
virtual int turnOn(void);
|
||||
virtual int turnOff(void);
|
||||
virtual int dim(unsigned char level);
|
||||
|
||||
int intSystem;
|
||||
int intUnits;
|
||||
int intFadeStyle;
|
||||
std::string getStringCode(unsigned char);
|
||||
};
|
||||
|
||||
}
|
149
driver/libtelldus-core/DeviceNexa.cpp
Normal file
149
driver/libtelldus-core/DeviceNexa.cpp
Normal file
|
@ -0,0 +1,149 @@
|
|||
// #include "StdAfx.h"
|
||||
#include "DeviceNexa.h"
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "common.h"
|
||||
|
||||
using namespace TelldusCore;
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
DeviceNexa::DeviceNexa(int id, const std::string &model, const std::string &name)
|
||||
:Device(id, model, name),
|
||||
intHouse(0),
|
||||
intCode(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor
|
||||
*/
|
||||
DeviceNexa::~DeviceNexa(void)
|
||||
{}
|
||||
|
||||
bool DeviceNexa::setHouse(const std::string &newHouse) {
|
||||
if (newHouse.length() > 0) {
|
||||
intHouse = atoi(newHouse.c_str());
|
||||
} else {
|
||||
intHouse = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceNexa::setUnit(const std::string &newUnit) {
|
||||
if (newUnit.length() > 0) {
|
||||
intCode = atoi(newUnit.c_str()) - 1;
|
||||
} else {
|
||||
intCode = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceNexa::setDeviceParameter(const std::string &strName, const std::string &strValue) {
|
||||
if (strName.compare("house") == 0) {
|
||||
return setHouse(strValue);
|
||||
} else if (strName.compare("unit") == 0) {
|
||||
return setUnit(strValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn on this device
|
||||
*/
|
||||
int DeviceNexa::turnOn(void) {
|
||||
std::string strCode = "";
|
||||
if (isDimmer()) {
|
||||
return dim(255);
|
||||
} else {
|
||||
strCode = getStringSelflearning(false, 0);
|
||||
strCode.append( 1, 1 ); //On
|
||||
strCode.append( ":" );
|
||||
}
|
||||
return Device::send(strCode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn off this device
|
||||
*/
|
||||
int DeviceNexa::turnOff(void){
|
||||
std::string strCode = getStringSelflearning(false, 0);
|
||||
strCode.append( 1, 2 ); //Off
|
||||
strCode.append( ":" );
|
||||
return Device::send(strCode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dim this device
|
||||
*/
|
||||
int DeviceNexa::dim(unsigned char level) {
|
||||
std::string strCode = getStringSelflearning(true, level);
|
||||
return Device::send(strCode);
|
||||
}
|
||||
|
||||
|
||||
int DeviceNexa::learn(void) {
|
||||
std::string strCode = getStringSelflearning(false, 0);
|
||||
strCode.append( 1, 1 ); //On
|
||||
strCode.append( ":" );
|
||||
return Device::send(strCode);
|
||||
}
|
||||
|
||||
|
||||
std::string DeviceNexa::getStringSelflearning(bool dim, unsigned char level) {
|
||||
std::string strMessage;
|
||||
strMessage.append( ":" );
|
||||
strMessage.append( 1, 15);
|
||||
strMessage.append( ":SEND:ATSL:" );
|
||||
int c = intHouse << 4;
|
||||
c = c | (intCode & 0xFF);
|
||||
strMessage.append( 1, (c >> 24) & 0xFF );
|
||||
strMessage.append( 1, (c >> 16) & 0xFF );
|
||||
strMessage.append( 1, (c >> 8) & 0xFF );
|
||||
strMessage.append( 1, c & 0xFF );
|
||||
return strMessage;
|
||||
}
|
||||
|
||||
bool DeviceNexa::parameterMatches( const std::string &name, const std::string &value ) const {
|
||||
if (value.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name.compare("arctech_house") == 0) {
|
||||
return intHouse == value[0] - 'A';
|
||||
} else if (name.compare("arctech_unit") == 0) {
|
||||
return intCode == atoi(value.c_str()) - 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Has the device got the method?
|
||||
*/
|
||||
int DeviceNexa::methods(){
|
||||
std::string strModel = this->getModel();
|
||||
|
||||
if (strcasecmp(strModel.c_str(), "selflearning-switch") == 0) {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
|
||||
|
||||
} else if (strcasecmp(strModel.c_str(), "selflearning-dimmer") == 0) {
|
||||
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM | TELLSTICK_LEARN);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DeviceNexa::isSelflearning() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceNexa::isDimmer() const {
|
||||
return strcasecmp(getModel().c_str(), "selflearning-dimmer") == 0;
|
||||
}
|
||||
|
||||
std::string DeviceNexa::getProtocol() const {
|
||||
return "arctech";
|
||||
}
|
36
driver/libtelldus-core/DeviceNexa.h
Normal file
36
driver/libtelldus-core/DeviceNexa.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
#include "Device.h"
|
||||
#include <string>
|
||||
|
||||
namespace TelldusCore {
|
||||
|
||||
class DeviceNexa : public Device
|
||||
{
|
||||
public:
|
||||
DeviceNexa(int id, const std::string &model, const std::string &name);
|
||||
virtual int methods();
|
||||
virtual std::string getProtocol() const;
|
||||
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
|
||||
|
||||
bool setHouse(const std::string &newHouse);
|
||||
bool setUnit(const std::string &newUnit);
|
||||
|
||||
public:
|
||||
~DeviceNexa(void);
|
||||
|
||||
protected:
|
||||
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
|
||||
virtual int turnOn(void);
|
||||
virtual int turnOff(void);
|
||||
virtual int dim(unsigned char level);
|
||||
virtual int learn(void);
|
||||
|
||||
bool isSelflearning() const;
|
||||
bool isDimmer() const;
|
||||
|
||||
int intHouse;
|
||||
int intCode;
|
||||
std::string getStringSelflearning(bool dim, unsigned char level);
|
||||
};
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue