1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-18 19:49:40 +00:00

Add new port comms/telldus-core

PR:		189221
Submitted by:	johan (stromnet.se)

Allows access to Telldus Tellstick USB dongles for communicating with
433MHz devices in your home.

Provides "telldusd", the daemon which keeps track of your tellstick
devices. Through a UNIX socket, the sensors and devices can be used/
controlled from the command line tool "tdtool", or via the libtelldus-core
C client library.
This commit is contained in:
John Marino 2014-08-15 14:43:47 +00:00
parent 40209a476a
commit 941fc51733
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=364977
20 changed files with 380 additions and 0 deletions

View File

@ -152,6 +152,7 @@
SUBDIR += svxlink
SUBDIR += syncterm
SUBDIR += tcpser
SUBDIR += telldus-core
SUBDIR += thebridge
SUBDIR += tilp2
SUBDIR += tits

View File

@ -0,0 +1,46 @@
# Created by: Johan Strom <johna@stromnet.se>
# $FreeBSD$
PORTNAME= telldus-core
PORTVERSION= 2.1.2
CATEGORIES= comms
MASTER_SITES= http://download.telldus.se/TellStick/Software/telldus-core/
MAINTAINER= johan@stromnet.se
COMMENT= Tellstick Telldus daemon + library
LICENSE= LGPL21
BUILD_DEPENDS= help2man:${PORTSDIR}/misc/help2man
LIB_DEPENDS= libftdi.so:${PORTSDIR}/devel/libftdi \
libconfuse.so:${PORTSDIR}/devel/libconfuse \
libargp.so:${PORTSDIR}/devel/argp-standalone
USES= iconv cmake compiler:c++11-lang
#CMAKE_VERBOSE=yes
CMAKE_ARGS+=-DGENERATE_MAN=TRUE
# Note: these are internal defines and shall NOT contain ${STAGEDIR}
CMAKE_ARGS+=-DSYSCONF_INSTALL_DIR="${PREFIX}/etc"
CMAKE_ARGS+=-DSTATE_INSTALL_DIR="/var/telldus"
MAKE_JOBS_UNSAFE= yes
USE_RC_SUBR= telldusd
USER= nobody
GROUP= dialer
.include <bsd.port.pre.mk>
post-patch:
# remove tr1 if using libc++
.if ${COMPILER_FEATURES:Mlibc++}
@${REINPLACE_CMD} -e 's|tr1::||' ${WRKSRC}/common/Event.h
.endif
post-install:
cd ${STAGEDIR}${PREFIX}/etc && \
${MV} tellstick.conf tellstick.conf.sample
${RM} ${STAGEDIR}/var/telldus/telldus-core.conf
.include <bsd.port.post.mk>

View File

@ -0,0 +1,2 @@
SHA256 (telldus-core-2.1.2.tar.gz) = a20f6c74814afc23312d2c93ebbb37fdea9deaaee05ae7b6a6275e11e4662014
SIZE (telldus-core-2.1.2.tar.gz) = 169850

View File

@ -0,0 +1,62 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -42,8 +42,18 @@ ENDIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(BUILD_TDTOOL TRUE CACHE BOOL "Build tdtool")
SET(BUILD_TDADMIN ${TDADMIN_DEFAULT} CACHE BOOL "Build tdadmin")
+SET(GENERATE_DOXYGEN FALSE CACHE BOOL "Enable generation of doxygen")
SET(GENERATE_MAN FALSE CACHE BOOL "Enable generation of man-files")
+
+IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ SET(MAN_DIR_DEFAULT "man")
+ELSE()
+ SET(MAN_DIR_DEFAULT "share/man")
+ENDIF()
+SET(MAN_DIR ${MAN_DIR_DEFAULT} CACHE PATH "The directory where man pages are located (related to ${CMAKE_INSTALL_PREFIX})")
+
+
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(service)
ADD_SUBDIRECTORY(client)
@@ -61,20 +71,23 @@ ENDIF(BUILD_TDADMIN)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
-FIND_PACKAGE(Doxygen)
-
-IF(DOXYGEN_FOUND)
- SET(DOXY_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
-
- CONFIGURE_FILE(
- "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in"
- ${DOXY_CONFIG} @ONLY
- )
-
- ADD_CUSTOM_TARGET(docs
- ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG}
- DEPENDS ${DOXY_CONFIG}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMENT "Generating doxygen documentation" VERBATIM
- )
-ENDIF()
+IF (GENERATE_DOXYGEN)
+ FIND_PACKAGE(Doxygen)
+ IF(DOXYGEN_FOUND)
+ SET(DOXY_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+
+ CONFIGURE_FILE(
+ "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in"
+ ${DOXY_CONFIG} @ONLY
+ )
+
+ ADD_CUSTOM_TARGET(docs
+ ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG}
+ DEPENDS ${DOXY_CONFIG}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Generating doxygen documentation" VERBATIM
+ )
+ ELSE()
+ MESSAGE("Warn: doxygen not found, wont build")
+ ENDIF()
+ENDIF(GENERATE_DOXYGEN)

View File

@ -0,0 +1,29 @@
--- common/CMakeLists.txt
+++ common/CMakeLists.txt
@@ -54,16 +54,22 @@ ELSEIF (WIN32)
)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
#### FreeBSD ####
- FIND_LIBRARY(ICONV_LIBRARY iconv)
+ string(REGEX MATCH "(([0-9]+)\\.([0-9]+))-([A-Z0-9])+" FREEBSD "${CMAKE_SYSTEM_VERSION}")
+ set( FREEBSD_RELEASE "${CMAKE_MATCH_1}" )
ADD_DEFINITIONS( -D_FREEBSD )
LIST(APPEND telldus-common_SRCS
Event_unix.cpp
EventHandler_unix.cpp
Socket_unix.cpp
)
- LIST(APPEND telldus-common_LIBRARIES
- ${ICONV_LIBRARY}
- )
+
+ # FreeBSD 10 has iconv built in to libc
+ IF(FREEBSD_RELEASE LESS 10)
+ FIND_LIBRARY(ICONV_LIBRARY iconv)
+ LIST(APPEND telldus-common_LIBRARIES
+ ${ICONV_LIBRARY}
+ )
+ ENDIF ()
ELSE (APPLE)
#### Linux ####
ADD_DEFINITIONS( -D_LINUX )

View File

@ -0,0 +1,24 @@
--- common/Socket_unix.cpp
+++ common/Socket_unix.cpp
@@ -18,7 +18,7 @@
#include "common/Strings.h"
#define BUFSIZE 512
-#if defined(_MACOSX) && !defined(SOCK_CLOEXEC)
+#if (defined(_MACOSX) || defined (__FreeBSD__)) && !defined(SOCK_CLOEXEC)
#define SOCK_CLOEXEC 0
#endif
@@ -130,8 +130,10 @@ std::wstring Socket::read(int timeout) {
void Socket::stopReadWait() {
TelldusCore::MutexLocker locker(&d->mutex);
- d->connected = false;
- // TODO(stefan): somehow signal the socket here?
+ if(d->connected && d->socket != -1) {
+ d->connected = false;
+ shutdown(d->socket, SHUT_RDWR);
+ }
}
void Socket::write(const std::wstring &msg) {

View File

@ -0,0 +1,12 @@
--- common/Thread.h
+++ common/Thread.h
@@ -13,6 +13,9 @@
#define TELLDUS_CORE_COMMON_THREAD_H_
#include <string>
+#ifdef __FreeBSD__
+#include <pthread.h>
+#endif
#include "common/Mutex.h"
namespace TelldusCore {

View File

@ -0,0 +1,11 @@
--- service/CMakeLists.txt
+++ service/CMakeLists.txt
@@ -249,7 +249,7 @@ IF (UNIX)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating man file telldusd.1"
)
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/telldusd.1 DESTINATION share/man/man1)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/telldusd.1 DESTINATION ${MAN_DIR}/man1)
ENDIF (GENERATE_MAN)
ENDIF (UNIX)

View File

@ -0,0 +1,11 @@
--- service/ConnectionListener_unix.cpp
+++ service/ConnectionListener_unix.cpp
@@ -17,7 +17,7 @@
#include "service/ConnectionListener.h"
#include "common/Socket.h"
-#if defined(_MACOSX) && !defined(SOCK_CLOEXEC)
+#if (defined(_MACOSX) || defined (__FreeBSD__)) && !defined(SOCK_CLOEXEC)
#define SOCK_CLOEXEC 0
#endif

View File

@ -0,0 +1,13 @@
--- service/EventUpdateManager.cpp
+++ service/EventUpdateManager.cpp
@@ -33,6 +33,10 @@
#include "service/ConnectionListener.h"
#include "service/Log.h"
+#ifdef __FreeBSD__
+extern char **environ;
+#endif
+
typedef std::list<TelldusCore::Socket *> SocketList;
typedef std::list<std::string> StringList;

View File

@ -0,0 +1,12 @@
--- service/Sensor.h
+++ service/Sensor.h
@@ -8,6 +8,9 @@
#define TELLDUS_CORE_SERVICE_SENSOR_H_
#include <string>
+#ifdef __FreeBSD__
+#include <ctime>
+#endif
#include "common/Mutex.h"
class Sensor : public TelldusCore::Mutex {

View File

@ -0,0 +1,11 @@
--- service/SettingsConfuse.cpp
+++ service/SettingsConfuse.cpp
@@ -17,6 +17,8 @@
class Settings::PrivateData {
public:
+ PrivateData()
+ : cfg(NULL), var_cfg(NULL) {}
cfg_t *cfg;
cfg_t *var_cfg;
};

View File

@ -0,0 +1,9 @@
--- service/tellstick.conf 2014-04-08 20:53:25.374751487 +0200
+++ service/tellstick.conf 2014-04-08 20:53:36.055838124 +0200
@@ -1,5 +1,5 @@
user = "nobody"
-group = "plugdev"
+group = "dialer"
ignoreControllerConfirmation = "false"
device {
id = 1

View File

@ -0,0 +1,34 @@
--- tdadmin/CMakeLists.txt
+++ tdadmin/CMakeLists.txt
@@ -52,13 +52,13 @@ IF (UNIX)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating man file tdadmin.1"
)
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdadmin.1 DESTINATION share/man/man1)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdadmin.1 DESTINATION ${MAN_DIR}/man1)
ENDIF (GENERATE_MAN)
ENDIF (UNIX)
INSTALL(TARGETS tdadmin RUNTIME DESTINATION sbin)
-IF (UNIX AND NOT APPLE)
+IF (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/05-tellstick.rules
@@ -76,4 +76,14 @@ IF (UNIX AND NOT APPLE)
INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/parsed/udev.sh
DESTINATION share/telldus-core/helpers/
)
-ENDIF (UNIX AND NOT APPLE)
+ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ SET(UDEV_RULES_DIR "/usr/local/etc/devd/" CACHE PATH "The directory where devd store its rules" )
+ CONFIGURE_FILE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/freebsd-devd-tellstick.conf
+ ${CMAKE_BINARY_DIR}/parsed/tellstick.conf
+ @ONLY
+ )
+ INSTALL(FILES ${CMAKE_BINARY_DIR}/parsed/tellstick.conf
+ DESTINATION ${UDEV_RULES_DIR}
+ )
+ENDIF ()

View File

@ -0,0 +1,15 @@
--- tdadmin/freebsd-devd-tellstick.conf 2014-04-06 22:40:11.000000000 +0200
+++ tdadmin/freebsd-devd-tellstick.conf 2014-04-06 20:37:50.501751596 +0200
@@ -0,0 +1,12 @@
+attach 10 {
+ device-name "uftdi[0-9]+";
+ match "vendor" "0x1781";
+ match "product" "0x0c30";
+
+ action "chgrp dialer /dev/ugen$port.$devaddr; chmod 660 /dev/ugen$port.$devaddr;
+ @CMAKE_INSTALL_PREFIX@/sbin/tdadmin --pid $product --vid $vendor --serial $sernum controller connect";
+};
+
+
+# Haven't managed to handle detach/disconnect events, seems they do not provide any information
+# at all so cannot distinguish different uftdi devices.

View File

@ -0,0 +1,11 @@
--- tdtool/CMakeLists.txt
+++ tdtool/CMakeLists.txt
@@ -49,7 +49,7 @@ IF (UNIX)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating man file tdtool.1"
)
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdtool.1 DESTINATION share/man/man1)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdtool.1 DESTINATION ${MAN_DIR}/man1)
ENDIF (GENERATE_MAN)
ENDIF (UNIX)

View File

@ -0,0 +1,28 @@
#!/bin/sh
#
# PROVIDE: telldusd
# Add the following lines to /etc/rc.conf to enable telldusd:
# telldusd_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable telldusd.
# telldusd_flags (str): Set to "" by default.
# telldusd_configfile (str): Set to "/usr/local/etc/tellstick.conf" by defult
#
. /etc/rc.subr
name="telldusd"
rcvar=telldusd_enable
command="/usr/local/sbin/telldusd"
pidfile="/var/run/telldusd.pid"
telldusd_enable=${telldusd_enable:-"NO"}
telldusd_flags=${telldusd_flags:-""}
telldusd_configfile=${telldusd_configfile:-"/usr/local/etc/tellstick.conf"}
load_rc_config "${name}"
required_files="${telldusd_configfile}"
run_rc_command "$1"

View File

@ -0,0 +1,9 @@
Allows access to Telldus Tellstick USB dongles for communicating with
433MHz devices in your home.
Provides "telldusd", the daemon which keeps track of your tellstick
devices. Through a UNIX socket, the sensors and devices can be used/
controlled from the command line tool "tdtool", or via the libtelldus-core
C client library.
WWW: http://www.telldus.com/products/tellstick

View File

@ -0,0 +1,20 @@
======
NOTICE
======
A devd rule has been installed to automatically notify telldusd
when a new device has been detected.
Please restart devd to activate this:
/etc/rc.d/devd restart
Edit /usr/local/etc/tellstick.conf to configure some devices,
and enable telldusd in rc.conf.
Then start telldusd.
When starting for the first time, you might need to unplug/plugin the device
to allow devd to fix the permissions on the /dev/ugenX.X device.

View File

@ -0,0 +1,20 @@
bin/tdtool
@group dialer
@mode 664
@exec mkdir -p /var/telldus && chown nobody:dialer /var/telldus
@exec [ -f /var/telldus/telldus-core.conf ] || touch /var/telldus/telldus-core.conf && chown nobody:dialer %D/var/telldus/telldus-core.conf
@unexec if [ ! -s /var/telldus/telldus-core.conf ]; then rm -vf /var/telldus/telldus-core.conf; fi
@unexec rmdir /var/telldus >/dev/null 2>&1 || :
@sample etc/tellstick.conf.sample
@group
@mode
etc/devd/tellstick.conf
include/telldus-core.h
lib/libtelldus-core.so
lib/libtelldus-core.so.2
lib/libtelldus-core.so.2.1.2
man/man1/tdadmin.1.gz
man/man1/tdtool.1.gz
man/man1/telldusd.1.gz
sbin/tdadmin
sbin/telldusd