diff --git a/Makefile b/Makefile deleted file mode 100644 index 23f3e2b..0000000 --- a/Makefile +++ /dev/null @@ -1,19 +0,0 @@ - -DOCS = README CHANGES BUGS - -.PHONY: all install clean - -all: - make -C build - -install: - cp -a $(DOCS) debian - make -C build install - -clean: - make -C build clean - (cd debian; \ - rm -rf $(DOCS)) - -distclean: clean - diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..cc8d5c7 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = src +dist_doc_DATA = README CHANGES BUGS + +etcdir = /etc +etc_DATA = $(PACKAGE).conf + +EXTRA_DIST = $(dist_doc_DATA) $(etc_DATA) diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..0090a41 --- /dev/null +++ b/configure.ac @@ -0,0 +1,49 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.69]) +AC_INIT([sanji-controller], [1.0.1], [aeluin.chen@moxa.com]) +AM_INIT_AUTOMAKE([1.11 foreign]) +AC_CONFIG_SRCDIR([src/sanji_controller.c]) +AC_CONFIG_HEADERS([config.h]) + +# Checks for programs. +AC_PROG_AWK +AC_PROG_CC +AC_PROG_RANLIB +AC_PROG_INSTALL +AC_PROG_MAKE_SET + +# Checks for libraries. +AC_SUBST(mosquitto_LIBS) +AC_CHECK_LIB([rt], [clock_gettime]) +AC_CHECK_LIB([jansson], [json_object]) +AC_CHECK_LIB([mosquitto], [mosquitto_lib_init], + [mosquitto_LIBS="-lmosquitto"], + AC_ERROR([Misssing mosquitto client library])) + +# Checks for header files. +AC_CHECK_HEADERS([fcntl.h stdint.h stdlib.h string.h unistd.h utime.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_CHECK_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_OFF_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_TYPE_UINT8_T + +# Checks for library functions. +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_FUNC_STRERROR_R +AC_CHECK_FUNCS([clock_gettime gethostname memmove memset strchr strerror strrchr utime]) + +AC_CONFIG_FILES([Makefile + src/Makefile + src/lib/Makefile]) +AC_OUTPUT diff --git a/debian/control b/debian/control index 8f51193..1dbeb35 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,6 @@ Section: libs Homepage: http://www.moxa.com #Vcs-Git: git@github.com:Sanji-IO/sanji-controller.git #Vcs-Browser: -X-Python-Version: >= 2.5 Package: sanji-controller Section: libs diff --git a/debian/rules b/debian/rules index 955dd78..f38d3ea 100755 --- a/debian/rules +++ b/debian/rules @@ -10,4 +10,4 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ --with autotools-dev diff --git a/debian/source/format b/debian/source/format index 89ae9db..163aaf8 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (native) +3.0 (quilt) diff --git a/sanji-controller.conf b/sanji-controller.conf new file mode 100644 index 0000000..a19855b --- /dev/null +++ b/sanji-controller.conf @@ -0,0 +1,78 @@ +[global] + +# ================================================================= +# Connection +# ================================================================= + +# MQTT broker IP. +host = '127.0.0.1' + +# MQTT broker port. +port = 1883 + +# Retry times to connect MQTT broker +# Max to 65535. If you want to try forever, use -1. +retry = -1 + + +# ================================================================= +# MQTT +# ================================================================= + +# Keep alive in seconds to MQTT broker. +# Max to 65535. +keepalive = 600 + +# On connection, a client sets the "clean session" flag, +# which is sometimes also known as the "clean start" flag. +# +# If clean session is set to false, then the connection is treated as durable. +# This means that when the client disconnects, any subscriptions it has will +# remain and any subsequent QoS 1 or 2 messages will be stored +# until it connects again in the future. If clean session is true, +# then all subscriptions will be removed for the client when it disconnects. +clean_session = true + +# QoS for subscription and publication. +# +# Higher levels of QoS are more reliable, +# but involve higher latency and have higher bandwidth requirements. +# 0: The broker/client will deliver the message once, with no confirmation. +# 1: The broker/client will deliver the message at least once, with confirmation required. +# 2: The broker/client will deliver the message exactly once by using a four step handshake. +sub_qos = 2 +pub_qos = 1 + +# Set the client id for this bridge connection. If not defined, this defaults +# to 'controller'. +cliet_id = + +# Username and password (requires MQTT 3.1 broker). +username = +password = + + +# ================================================================= +# Sanji Controller +# ================================================================= + +# The inverval in milliseconds for sanji controller to refresh sessions. +# +# Sanji controller will refresh every session status in order to +# drop TTL session, do heart beat with MQTT broker, +# and some protocol layer procedure. +# +# Noted, refresh interval MUST less then keepalive time. +# Max to 65535. +refresh_interval = 1000 + + +# ================================================================= +# MISC +# ================================================================= + +# Local id for extra topic +local_id = + +# Enable mosquitto debug function. +mosq_debug = false diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..0d841ea --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = lib + +libdir = lib +bin_PROGRAMS = sanji-controller +sanji_controller_SOURCES = \ + debug.h \ + error.h \ + http.h \ + list.h \ + sanji_controller.h sanji_controller.c \ + resource.h resource.c \ + component.h component.c \ + session.h session.c \ + ini.h ini.c +sanji_controller_LDFLAGS = $(mosquitto_LIBS) $(jansson_LIBS) +sanji_controller_LDADD = $(libdir)/libsanjimisc.a + +AM_CPPFLAGS = -I$(libdir) diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 0000000..473e62e --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,13 @@ +noinst_LIBRARIES = libsanjimisc.a +libsanjimisc_a_SOURCES = \ + bswap.h \ + typedefs.h \ + crc16.h crc16.c \ + daemonize.h daemonize.c \ + dt.h dt.c \ + time_util.h time_util.c \ + lock.h lock.c \ + pid.h pid.c \ + text_util.h text_util.c \ + strext.h strext.c \ + random_util.h random_util.c diff --git a/src/lib/build/Makefile b/src/lib/build/Makefile index bcb0788..b12dc42 100755 --- a/src/lib/build/Makefile +++ b/src/lib/build/Makefile @@ -8,15 +8,15 @@ CFLAGS += -DDEBUG endif SRCS = \ - crc16.c \ - daemonize.c \ - dt.c \ - time_util.c \ - lock.c \ - pid.c \ - text_util.c \ - strext.c \ - random_util.c + crc16.c \ + daemonize.c \ + dt.c \ + time_util.c \ + lock.c \ + pid.c \ + text_util.c \ + strext.c \ + random_util.c OBJS = $(SRCS:.c=.o)