mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
add alljoyn and wifimngr packages to BB
This commit is contained in:
parent
687322337f
commit
a4adcb919a
32 changed files with 3889 additions and 0 deletions
135
alljoyn/alljoyn-config/Makefile
Normal file
135
alljoyn/alljoyn-config/Makefile
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
AJ_SERVICE:=config
|
||||
AJ_SERVICE_NAME:=Config
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn-$(AJ_SERVICE)
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=.00
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=389c2623619281e6849da25cee7e1bb7
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/alljoyn-services-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=alljoyn-services-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)-samples
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=off
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
TITLE:=AllJoyn $(AJ_SERVICE_NAME) service library
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=alljoyn \
|
||||
+alljoyn-about
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AllJoyn $(AJ_SERVICE_NAME) service library.
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)-samples
|
||||
$(call Package/$(PKG_NAME))
|
||||
TITLE+=- testing samples
|
||||
DEPENDS:=$(PKG_NAME) \
|
||||
+alljoyn-services_common
|
||||
MENU:=0
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)-samples/description
|
||||
Alljoyn $(AJ_SERVICE_NAME) service library samples. (This is primarily for testing.
|
||||
The contents of this package vary according which other alljoyn packages
|
||||
are selected.)
|
||||
endef
|
||||
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist/$(AJ_SERVICE)
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
|
||||
ifdef CONFIG_PACKAGE_$(PKG_NAME)-samples
|
||||
ifdef CONFIG_PACKAGE_alljoyn-about
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=on
|
||||
endif
|
||||
endif
|
||||
|
||||
define Build/Configure/Default
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"BUILD_SERVICES_SAMPLES=$(ALLJOYN_BUILD_SERVICES_SAMPLES)" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
BT=off \
|
||||
ICE=off \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(CP) $(PKG_INSTALL_DIR)/inc/alljoyn/$(AJ_SERVICE)/*.h $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)-samples/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/* $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/etc/alljoyn-config
|
||||
$(CP) $(PKG_BUILD_DIR)/services/base/config/cpp/samples/ConfigServiceSample/ConfigService.conf $(1)/etc/alljoyn-config/
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)-samples))
|
||||
|
||||
133
alljoyn/alljoyn-controlpanel/Makefile
Normal file
133
alljoyn/alljoyn-controlpanel/Makefile
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
AJ_SERVICE:=controlpanel
|
||||
AJ_SERVICE_NAME:=ControlPanel
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn-$(AJ_SERVICE)
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=.00
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=389c2623619281e6849da25cee7e1bb7
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/alljoyn-services-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=alljoyn-services-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)-samples
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=off
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
TITLE:=AllJoyn $(AJ_SERVICE_NAME) service library
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=alljoyn
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AllJoyn $(AJ_SERVICE_NAME) service library.
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)-samples
|
||||
$(call Package/$(PKG_NAME))
|
||||
TITLE+=- testing samples
|
||||
DEPENDS:=$(PKG_NAME) \
|
||||
+alljoyn-about \
|
||||
+alljoyn-notification \
|
||||
+alljoyn-services_common
|
||||
MENU:=0
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)-samples/description
|
||||
Alljoyn $(AJ_SERVICE_NAME) service library samples. (This is primarily for testing.
|
||||
The contents of this package vary according which other alljoyn packages
|
||||
are selected.)
|
||||
endef
|
||||
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist/$(AJ_SERVICE)
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
|
||||
ifdef CONFIG_PACKAGE_$(PKG_NAME)-samples
|
||||
ifdef CONFIG_PACKAGE_alljoyn-about
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=on
|
||||
endif
|
||||
endif
|
||||
|
||||
define Build/Configure/Default
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"BUILD_SERVICES_SAMPLES=$(ALLJOYN_BUILD_SERVICES_SAMPLES)" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
BT=off \
|
||||
ICE=off \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(CP) $(PKG_INSTALL_DIR)/inc/alljoyn/$(AJ_SERVICE)/*.h $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)-samples/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/* $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)-samples))
|
||||
|
||||
132
alljoyn/alljoyn-notification/Makefile
Normal file
132
alljoyn/alljoyn-notification/Makefile
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
AJ_SERVICE:=notification
|
||||
AJ_SERVICE_NAME:=Notification
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn-$(AJ_SERVICE)
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=.00
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=389c2623619281e6849da25cee7e1bb7
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/alljoyn-services-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=alljoyn-services-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)-samples
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=off
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
TITLE:=AllJoyn $(AJ_SERVICE_NAME) service library
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=alljoyn \
|
||||
+alljoyn-about
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AllJoyn $(AJ_SERVICE_NAME) service library.
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)-samples
|
||||
$(call Package/$(PKG_NAME))
|
||||
TITLE+=- testing samples
|
||||
DEPENDS:=$(PKG_NAME) \
|
||||
+alljoyn-services_common
|
||||
MENU:=0
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)-samples/description
|
||||
Alljoyn $(AJ_SERVICE_NAME) service library samples. (This is primarily for testing.
|
||||
The contents of this package vary according which other alljoyn packages
|
||||
are selected.)
|
||||
endef
|
||||
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist/$(AJ_SERVICE)
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
|
||||
ifdef CONFIG_PACKAGE_$(PKG_NAME)-samples
|
||||
ifdef CONFIG_PACKAGE_alljoyn-about
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=on
|
||||
endif
|
||||
endif
|
||||
|
||||
define Build/Configure/Default
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"BUILD_SERVICES_SAMPLES=$(ALLJOYN_BUILD_SERVICES_SAMPLES)" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
BT=off \
|
||||
ICE=off \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(CP) $(PKG_INSTALL_DIR)/inc/alljoyn/$(AJ_SERVICE)/*.h $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)-samples/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/* $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)-samples))
|
||||
|
||||
160
alljoyn/alljoyn-onboarding/Makefile
Normal file
160
alljoyn/alljoyn-onboarding/Makefile
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
AJ_SERVICE:=onboarding
|
||||
AJ_SERVICE_NAME:=onboarding
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn-$(AJ_SERVICE)
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=.00
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=389c2623619281e6849da25cee7e1bb7
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/alljoyn-services-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=alljoyn-services-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
|
||||
# Due to inherited dependencies (onboarding package depends on wpa-cli package and therefore inherits its dependencies)
|
||||
# the onboarding package will not be visible for selection unless the wpa-supplicant package is first selected
|
||||
define Package/$(PKG_NAME)
|
||||
TITLE:=AllJoyn $(AJ_SERVICE_NAME) service library
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=alljoyn \
|
||||
wpa-supplicant \
|
||||
+alljoyn-about \
|
||||
+alljoyn-config \
|
||||
+alljoyn-services_common \
|
||||
+hostapd \
|
||||
+wpa-cli
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AllJoyn $(AJ_SERVICE_NAME) service.
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist/$(AJ_SERVICE)
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
TARGET_LDFLAGS+=-lpthread -lrt
|
||||
|
||||
define Build/Configure/Default
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"BUILD_SERVICES_SAMPLES=off" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
BT=off \
|
||||
ICE=off \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(CP) $(PKG_INSTALL_DIR)/inc/alljoyn/$(AJ_SERVICE)/*.h $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/onboarding-daemon $(1)/usr/bin/
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/alljoyn-onboarding.init $(1)/etc/init.d/alljoyn-onboarding
|
||||
$(INSTALL_BIN) ./files/alljoyn-onboarding-reload.init $(1)/etc/init.d/alljoyn-onboarding-reload
|
||||
$(INSTALL_BIN) ./files/wifi_scan.init $(1)/etc/init.d/wifi_scan
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/alljoyn-onboarding.defaults $(1)/etc/uci-defaults/alljoyn-onboarding
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/alljoyn-onboarding.config $(1)/etc/config/alljoyn-onboarding
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/wifi_scan $(1)/usr/sbin/wifi_scan
|
||||
$(INSTALL_BIN) ./files/parse_iw_wifi_scan $(1)/usr/sbin/parse_iw_wifi_scan
|
||||
$(INSTALL_BIN) ./files/parse_iwlist_wifi_scan $(1)/usr/sbin/parse_iwlist_wifi_scan
|
||||
$(INSTALL_BIN) ./files/wifi_mgmt $(1)/usr/sbin/wifi_mgmt
|
||||
$(INSTALL_DIR) $(1)/etc/alljoyn-onboarding
|
||||
$(INSTALL_CONF) ./files/alljoyn-onboarding.state $(1)/etc/alljoyn-onboarding/alljoyn-onboarding-state
|
||||
$(CP) $(PKG_BUILD_DIR)/services/base/onboarding/cpp/src/OnboardingDaemon/OnboardingService.conf $(1)/etc/alljoyn-onboarding/
|
||||
$(CP) $(PKG_BUILD_DIR)/services/base/onboarding/cpp/src/OnboardingDaemon/FactoryOnboardingService.conf $(1)/etc/alljoyn-onboarding/
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
. /etc/uci-defaults/alljoyn-onboarding
|
||||
rm -f /etc/uci-defaults/alljoyn-onboarding
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/prerm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
/etc/init.d/alljoyn-onboarding stop
|
||||
/etc/init.d/alljoyn-onboarding disable
|
||||
/etc/init.d/wifi_scan disable
|
||||
/etc/init.d/alljoyn-onboarding-reload disable
|
||||
crontab -l 2>/dev/null | sed '/\/etc\/init.d\/alljoyn-onboarding/d' | crontab -
|
||||
crontab -l 2>/dev/null | sed '/\/usr\/sbin\/wifi_scan/d' | crontab -
|
||||
local obswifiIndex=$(uci show /etc/config/firewall | grep obswifi | grep name | cut -d"[" -f2 | cut -c1)
|
||||
uci delete firewall.@zone[$(obswifiIndex)]
|
||||
uci commit firewall
|
||||
uci batch <<EOF
|
||||
del_list ucitrack.@alljoyn[-1].affects=alljoyn-onboarding
|
||||
delete ucitrack.@alljoyn-onboarding[-1]
|
||||
commit ucitrack
|
||||
EOF
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
# Copyright (c) 2013 - 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
START=58
|
||||
|
||||
RADIO_24G=
|
||||
find_2_4_radio() {
|
||||
local cfg=$1
|
||||
|
||||
#list of known wireless protocols
|
||||
local validModes="11b 11g 11a 11ng 11na"
|
||||
|
||||
# get the current hwmode
|
||||
local hwmode
|
||||
config_get hwmode "$cfg" hwmode
|
||||
|
||||
# verify that the hwmode is one of the valid modes
|
||||
local hasMode=`echo "$validModes" | grep $hwmode`
|
||||
if [ -n "$hasMode" ]; then
|
||||
RADIO_24G=$cfg
|
||||
fi
|
||||
}
|
||||
|
||||
APVAP_24G=
|
||||
find_2_4_apvap() {
|
||||
local cfg=$1
|
||||
local radio=$2
|
||||
|
||||
local mode
|
||||
config_get mode "$cfg" mode
|
||||
local device
|
||||
config_get device "$cfg" device
|
||||
|
||||
[ "$mode" = "ap" -a "$device" = "$radio" ] && \
|
||||
APVAP_24G="$cfg"
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load alljoyn-onboarding
|
||||
local state
|
||||
state=$(uci_get alljoyn-onboarding @onboarding[0] state)
|
||||
[ "${state}" = "3" ] && return 0
|
||||
|
||||
local iface=$(cat /proc/net/wireless | grep -m 1 : | sed -e 's/:.*//' | sed -e 's/ //g')
|
||||
local macaddr=$(cat /sys/class/net/$iface/address)
|
||||
|
||||
# save the ssid in case it gets overwritten and we need it again
|
||||
uci_set alljoyn-onboarding @onboarding[0] apssid "AJ_OpenWRT ${macaddr}"
|
||||
uci_commit alljoyn-onboarding
|
||||
|
||||
config_load wireless
|
||||
|
||||
config_foreach find_2_4_radio wifi-device
|
||||
[ -z "${RADIO_24G}" ] && {
|
||||
echo "Error: No 2.4GHz radio found"
|
||||
return 1
|
||||
}
|
||||
|
||||
config_foreach find_2_4_apvap wifi-iface ${RADIO_24G}
|
||||
[ -z "${APVAP_24G}" ] && {
|
||||
echo "Error: No 2.4GHz AP VAP found"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Ok, now we start setting the configuration parameters
|
||||
uci_set wireless ${RADIO_24G} disabled 0
|
||||
uci_set wireless ${RADIO_24G} channel 6
|
||||
uci_set wireless ${APVAP_24G} ssid "AJ_OpenWRT ${macaddr}"
|
||||
uci_commit wireless
|
||||
wifi
|
||||
|
||||
# Add other appropriate tasks when device is not fully configured
|
||||
}
|
||||
15
alljoyn/alljoyn-onboarding/files/alljoyn-onboarding.config
Normal file
15
alljoyn/alljoyn-onboarding/files/alljoyn-onboarding.config
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Option Values:
|
||||
#
|
||||
# option apssid The access point name as seen by the onboarder application.
|
||||
# Note: In order for Alljoyn to detect the access point the name must start with prefix 'AJ_'
|
||||
# option apencryption The cypher mode
|
||||
# For the full list refer to http://wiki.openwrt.org/doc/uci/wireless#wpa.modes
|
||||
# Example - WPA2 would be: option apencryption 'psk2+tkip+ccmp'
|
||||
# option apkey Cypher key for connecting to the access point
|
||||
# option aphidden Determines whether the softAp will be hidden or broadcast. Default is 0 - not hidden
|
||||
|
||||
config onboarding
|
||||
option apssid 'AJ_OpenWRT'
|
||||
option apencryption 'none'
|
||||
option apkey ''
|
||||
option aphidden '0'
|
||||
33
alljoyn/alljoyn-onboarding/files/alljoyn-onboarding.defaults
Normal file
33
alljoyn/alljoyn-onboarding/files/alljoyn-onboarding.defaults
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#! /bin/sh
|
||||
local hasOnboarding=$(uci get ucitrack.@alljoyn-onboarding[-1] 2> /dev/null)
|
||||
if [ -z "$hasOnboarding" ]; then
|
||||
uci batch <<EOF
|
||||
add ucitrack alljoyn-onboarding
|
||||
set ucitrack.@alljoyn-onboarding[-1].init=alljoyn-onboarding
|
||||
add_list ucitrack.@alljoyn[-1].affects=alljoyn-onboarding
|
||||
commit ucitrack
|
||||
EOF
|
||||
fi
|
||||
uci batch <<EOF
|
||||
set wireless.@wifi-device[-1].disabled=0
|
||||
set wireless.@wifi-iface[-1].disabled=0
|
||||
commit wireless
|
||||
EOF
|
||||
local hasObswifi=$(uci show /etc/config/firewall | grep obswifi)
|
||||
if [ -z "$hasObswifi" ]; then
|
||||
uci batch <<EOF
|
||||
add firewall zone
|
||||
set firewall.@zone[-1].name=obswifi
|
||||
add_list firewall.@zone[-1].network='obswifi'
|
||||
set firewall.@zone[-1].input=ACCEPT
|
||||
set firewall.@zone[-1].output=ACCEPT
|
||||
set firewall.@zone[-1].forward=ACCEPT
|
||||
commit firewall
|
||||
EOF
|
||||
fi
|
||||
/etc/init.d/alljoyn-onboarding enable
|
||||
/etc/init.d/wifi_scan enable
|
||||
/etc/init.d/alljoyn-onboarding-reload enable
|
||||
crontab -l 2>/dev/null | sed '/\/etc\/init.d\/alljoyn-onboarding/d' | echo '*/1 * * * * /etc/init.d/alljoyn-onboarding poll_connection' | crontab -
|
||||
/etc/init.d/cron enable
|
||||
exit 0
|
||||
199
alljoyn/alljoyn-onboarding/files/alljoyn-onboarding.init
Normal file
199
alljoyn/alljoyn-onboarding/files/alljoyn-onboarding.init
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
# Copyright (c) 2013 - 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
. /usr/sbin/wifi_mgmt
|
||||
|
||||
START=66
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
CONFIGFILE=/etc/alljoyn-onboarding/OnboardingService.conf
|
||||
FACTORYCONFIGFILE=/etc/alljoyn-onboarding/FactoryOnboardingService.conf
|
||||
|
||||
EXTRA_COMMANDS="state error connect softap offboard configure validate reset retry poll_connection"
|
||||
EXTRA_HELP=<<EOF
|
||||
state Get onboarding state
|
||||
error Get onboarding error
|
||||
connect Connect to AP with provided configuration
|
||||
softap Disconnect from AP and enable soft AP
|
||||
offboard softap + wipe configuration
|
||||
configure Configure device with personal AP credentials
|
||||
validate Validate the provided configuration
|
||||
reset Reset the radio
|
||||
retry Enter SoftAP mode temporarily to allow reconfig
|
||||
poll_connection Poll the status of the connection
|
||||
EOF
|
||||
|
||||
STATE_NOTCONFIGURED=0
|
||||
STATE_CONFIGURED=1
|
||||
STATE_VALIDATING=2
|
||||
STATE_VALIDATED=3
|
||||
STATE_ERROR=4
|
||||
STATE_RETRY=5
|
||||
|
||||
boot() {
|
||||
local obswifi=$(uci get network.obswifi)
|
||||
if [ -z "$obswifi" ]; then
|
||||
uci set network.obswifi=interface
|
||||
uci set network.obswifi.proto=dhcp
|
||||
uci commit network
|
||||
/etc/init.d/network reload
|
||||
fi
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
start() {
|
||||
cache_state
|
||||
cache_error
|
||||
connect
|
||||
service_start /usr/bin/onboarding-daemon --config-file=$CONFIGFILE --factory-config-file=$FACTORYCONFIGFILE
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/bin/onboarding-daemon
|
||||
}
|
||||
|
||||
state() {
|
||||
return $(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state)
|
||||
}
|
||||
|
||||
error() {
|
||||
return $(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].lasterrorcode)
|
||||
}
|
||||
|
||||
connect() {
|
||||
local state="$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state)"
|
||||
|
||||
if [ ${state} -eq $STATE_NOTCONFIGURED ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ${state} -eq $STATE_CONFIGURED ] || [ ${state} -eq $STATE_ERROR ]; then
|
||||
validate
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ${state} -eq $STATE_VALIDATING ]; then
|
||||
retries=2
|
||||
else
|
||||
retries=$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].connect_retry_max)
|
||||
fi
|
||||
|
||||
local status=$ERROR_NONE
|
||||
while [ $retries -gt 0 ]; do
|
||||
wifi_connect
|
||||
sleep 2
|
||||
wifi_connect_status
|
||||
status=$?
|
||||
echo "status: $status"
|
||||
if [ ${status} -eq $ERROR_NONE ]; then
|
||||
set_state $STATE_VALIDATED
|
||||
return $status
|
||||
else
|
||||
retries=$((--retries))
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${state} -eq $STATE_VALIDATED ] || [ ${state} -eq $STATE_RETRY ]; then
|
||||
if [ $(ps -w | grep "/etc/init.d/alljoyn-onboarding retry" | grep -v "grep" | wc -l) -eq 0 ]; then
|
||||
/etc/init.d/alljoyn-onboarding retry &
|
||||
status=$((status+8)) # set a bit saying we are in retry
|
||||
fi
|
||||
elif [ ${state} -eq ${STATE_VALIDATING} ]; then
|
||||
set_state $STATE_ERROR
|
||||
softap
|
||||
fi
|
||||
|
||||
return $status
|
||||
}
|
||||
|
||||
offboard() {
|
||||
set_state $STATE_NOTCONFIGURED
|
||||
softap
|
||||
uci delete alljoyn-onboarding.@onboarding[0].ssid
|
||||
uci delete alljoyn-onboarding.@onboarding[0].encryption
|
||||
uci delete alljoyn-onboarding.@onboarding[0].key
|
||||
uci commit alljoyn-onboarding
|
||||
set_error $ERROR_NONE "Unconfigured"
|
||||
}
|
||||
|
||||
softap() {
|
||||
wifi_softap
|
||||
}
|
||||
|
||||
reset() {
|
||||
wifi_reset
|
||||
}
|
||||
|
||||
retry() {
|
||||
echo "STATE_RETRY"
|
||||
set_state $STATE_RETRY
|
||||
local retry_duration="$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].config_retry_duration)"
|
||||
softap
|
||||
sleep $retry_duration
|
||||
local state="$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state)"
|
||||
if [ ${state} -eq $STATE_RETRY ]; then
|
||||
/etc/init.d/alljoyn-onboarding connect &
|
||||
fi
|
||||
}
|
||||
|
||||
configure() {
|
||||
local codeoption="-p"
|
||||
if [ "$2" = "WEP" ]; then
|
||||
codeoption="-k"
|
||||
fi
|
||||
wifi_configure -s "$1" -a "$2" $codeoption "$3"
|
||||
set_state $STATE_CONFIGURED
|
||||
}
|
||||
|
||||
validate() {
|
||||
set_state $STATE_VALIDATING
|
||||
connect
|
||||
}
|
||||
|
||||
set_state() {
|
||||
uci set -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state=$1
|
||||
uci commit -c /etc/alljoyn-onboarding alljoyn-onboarding-state
|
||||
cache_state $1
|
||||
}
|
||||
|
||||
cache_state(){
|
||||
local state="$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state)"
|
||||
printf '%d\n' "$state" > /tmp/state/alljoyn-onboarding
|
||||
}
|
||||
|
||||
cache_error() {
|
||||
local code=$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].lasterrorcode)
|
||||
local msg=$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].lasterrormsg)
|
||||
printf '%s\n%s' "$code" "$msg" > /tmp/state/alljoyn-onboarding-lasterror
|
||||
}
|
||||
|
||||
poll_connection() {
|
||||
local state="$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state)"
|
||||
if [ ${state} -eq $STATE_VALIDATED ]; then
|
||||
wifi_connect_status
|
||||
local status=$?
|
||||
if [ ${status} -ne $ERROR_NONE ]; then
|
||||
## check state again in case it changed since last get
|
||||
state="$(uci get -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].state)"
|
||||
if [ ${state} -ne $STATE_VALIDATED ]; then
|
||||
return
|
||||
fi
|
||||
/etc/init.d/alljoyn-onboarding connect &
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
config onboarding
|
||||
option state '0'
|
||||
option lasterrorcode '0'
|
||||
option lasterrormsg 'Unconfigured'
|
||||
option config_retry_duration '180'
|
||||
option connect_retry_max '2'
|
||||
89
alljoyn/alljoyn-onboarding/files/parse_iw_wifi_scan
Normal file
89
alljoyn/alljoyn-onboarding/files/parse_iw_wifi_scan
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
device=`iw dev | grep Interface | cut -f 2 -s -d" "`
|
||||
# Sometimes right after boot, the device is not ready yet
|
||||
if [ -n $device ]; then
|
||||
iw $device scan |
|
||||
grep -e "^BSS" -e "signal:" -e "SSID:" -e "capability:" -e "RSN:" -e "WPA:" -e "Pairwise ciphers" -e "Authentication suites" |
|
||||
{
|
||||
while read -r line; do
|
||||
case "$line" in
|
||||
BSS* )
|
||||
## Handling a new SSID. Print out previously processed SSID only if it is defined.
|
||||
## Note the different syntax based on WPA/WPA2 VS Open or WEP
|
||||
if [ "$enc" == "Open" ] || [ "$enc" == "WEP" ]; then
|
||||
printf "%s\t%s\t%s\n" "$quality" "$enc" "$ssid"
|
||||
elif [ -n "$ssid" ]; then
|
||||
printf "%s\t%s-%s-%s-%s\t%s\n" "$quality" "$enc" "$ccmp" "$tkip" "$psk" "$ssid"
|
||||
fi
|
||||
|
||||
## Initialize the variables
|
||||
ssid=""
|
||||
enc="Open"
|
||||
ccmp=""
|
||||
tkip=""
|
||||
psk=""
|
||||
quality=""
|
||||
;;
|
||||
SSID:* )
|
||||
## Set the ssid variable
|
||||
ssid=$(echo "$line" | sed s/"SSID: "//)
|
||||
;;
|
||||
signal:* )
|
||||
## Set signal quality variable
|
||||
quality=$(echo "$line" | sed s/"signal: "//)
|
||||
;;
|
||||
capability:* )
|
||||
## Encryption is on. We assume it's WEP by default, if we later find out it's WPA or WPA2 we override it
|
||||
if [ $(echo $line | grep "Privacy" | wc -l) -ne 0 ]; then
|
||||
enc="WEP"
|
||||
fi
|
||||
;;
|
||||
RSN:* )
|
||||
## Set Encryption to be WPA2
|
||||
enc="WPA2"
|
||||
;;
|
||||
WPA* )
|
||||
enc="WPA"
|
||||
;;
|
||||
"* Pairwise ciphers:"* )
|
||||
## Set the appropriate cipher variables
|
||||
if [ $(echo $line | grep "CCMP" | wc -l) -ne 0 ]; then
|
||||
ccmp="CCMP"
|
||||
fi
|
||||
if [ $(echo $line | grep "TKIP" | wc -l) -ne 0 ]; then
|
||||
tkip="TKIP"
|
||||
fi
|
||||
;;
|
||||
"* Authentication suites:"* )
|
||||
## Set the appropriate Authentication Suite variable
|
||||
if [ $(echo $line | grep "PSK" | wc -l) -ne 0 ]; then
|
||||
psk="PSK";
|
||||
fi
|
||||
;;
|
||||
* ) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$enc" == "Open" ] || [ "$enc" == "WEP" ]; then
|
||||
printf "%s\t%s\t%s\n" "$quality" "$enc" "$ssid"
|
||||
elif [ -n "$ssid" ]; then
|
||||
printf "%s\t%s-%s-%s-%s\t%s\n" "$quality" "$enc" "$ccmp" "$tkip" "$psk" "$ssid"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
83
alljoyn/alljoyn-onboarding/files/parse_iwlist_wifi_scan
Normal file
83
alljoyn/alljoyn-onboarding/files/parse_iwlist_wifi_scan
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
iwlist scanning 2> /dev/null |
|
||||
grep -e "Quality=" -e "ESSID:" -e "Encryption key:on" -e "IE:" -e "Pairwise Ciphers" -e "Authentication Suites" |
|
||||
{
|
||||
while read -r line; do
|
||||
case "$line" in
|
||||
ESSID:\"* )
|
||||
## Handling a new SSID. Print out previously processed SSID only if it is defined.
|
||||
## Note the different syntax based on WPA/WPA2 VS Open or WEP
|
||||
if [ "$enc" == "Open" ] || [ "$enc" == "WEP" ]; then
|
||||
printf "%s\t%s\t%s\n" "$quality" "$enc" "$ssid"
|
||||
elif [ -n "$ssid" ]; then
|
||||
printf "%s\t%s-%s-%s-%s\t%s\n" "$quality" "$enc" "$ccmp" "$tkip" "$psk" "$ssid"
|
||||
fi
|
||||
|
||||
## Initialize the variables
|
||||
ssid=$(echo "${line%?}" | sed s/ESSID:\"//)
|
||||
enc="Open"
|
||||
ccmp=""
|
||||
tkip=""
|
||||
psk=""
|
||||
quality=""
|
||||
;;
|
||||
Quality=* )
|
||||
## Set signal quality variables
|
||||
quality=$(echo "$line" | sed s/.*"Signal level="// | sed s/" dBm".*/" dBm"/)
|
||||
;;
|
||||
Encryption* )
|
||||
## Encryption is on. We assume it's WEP by default, if we later find out it's WPA or WPA2 we override it
|
||||
enc="WEP"
|
||||
;;
|
||||
IE:* )
|
||||
## Set Encryption to be WPA or WPA2
|
||||
case "$line" in
|
||||
*WPA2* )
|
||||
enc="WPA2"
|
||||
;;
|
||||
*WPA* )
|
||||
enc="WPA"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
Pairwise* )
|
||||
## Set the appropriate cipher variables
|
||||
if [ $(echo $line | grep "CCMP" | wc -l) -ne 0 ]; then
|
||||
ccmp="CCMP"
|
||||
fi
|
||||
if [ $(echo $line | grep "TKIP" | wc -l) -ne 0 ]; then
|
||||
tkip="TKIP"
|
||||
fi
|
||||
;;
|
||||
Authentication* )
|
||||
## Set the appropriate Authentication Suite variable
|
||||
if [ $(echo $line | grep "PSK" | wc -l) -ne 0 ]; then
|
||||
psk="PSK";
|
||||
fi
|
||||
;;
|
||||
* ) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$enc" == "Open" ] || [ "$enc" == "WEP" ]; then
|
||||
printf "%s\t%s\t%s\n" "$quality" "$enc" "$ssid"
|
||||
elif [ -n "$ssid" ]; then
|
||||
printf "%s\t%s-%s-%s-%s\t%s\n" "$quality" "$enc" "$ccmp" "$tkip" "$psk" "$ssid"
|
||||
fi
|
||||
}
|
||||
337
alljoyn/alljoyn-onboarding/files/wifi_mgmt
Normal file
337
alljoyn/alljoyn-onboarding/files/wifi_mgmt
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2013 - 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
. /lib/config/uci.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
DEBUG=
|
||||
|
||||
ERROR_NONE=0
|
||||
ERROR_UNREACHABLE=1
|
||||
ERROR_PROTOCOL=2
|
||||
ERROR_UNAUTHORIZED=3
|
||||
ERROR_GENERAL=4
|
||||
|
||||
WPA_CLI() {
|
||||
local iface=$1;shift
|
||||
local opt
|
||||
case ${iface} in
|
||||
global) opt="-g /var/run/wpa_supplicant-${iface}" ;;
|
||||
*) opt="-p /var/run/wpa_supplicant-${iface} -i ${iface}";;
|
||||
esac
|
||||
if [ -n "${DEBUG}" ]; then
|
||||
echo wpa_cli ${opt} "$@" >&2
|
||||
wpa_cli ${opt} "$@" || exit 2
|
||||
return 0
|
||||
fi
|
||||
wpa_cli ${opt} "$@" >/dev/null 2>&1 || exit 2
|
||||
}
|
||||
|
||||
wifi_connect() {
|
||||
local ssid=$(uci get alljoyn-onboarding.@onboarding[0].ssid)
|
||||
local encryption=$(uci get alljoyn-onboarding.@onboarding[0].encryption)
|
||||
local key=$(uci get alljoyn-onboarding.@onboarding[0].key)
|
||||
|
||||
if [ "$encryption" = "wep" ]; then
|
||||
local getwepkey="uci get alljoyn-onboarding.@onboarding[0].key$key"
|
||||
uci set wireless.@wifi-iface[0].key$key="$($getwepkey)"
|
||||
fi
|
||||
|
||||
uci set wireless.@wifi-iface[0].mode=sta
|
||||
uci set wireless.@wifi-iface[0].network=obswifi
|
||||
uci set wireless.@wifi-iface[0].ssid="$ssid"
|
||||
uci set wireless.@wifi-iface[0].key="$key"
|
||||
uci set wireless.@wifi-iface[0].encryption=$encryption
|
||||
uci delete wireless.@wifi-iface[0].hidden
|
||||
uci commit wireless
|
||||
wifi
|
||||
|
||||
# when in station mode, set the scan_wifi cron job to run every hour
|
||||
/etc/init.d/cron stop
|
||||
sed -i '/\/usr\/sbin\/wifi_scan/d' /etc/crontabs/root
|
||||
echo '1 * * * * /usr/sbin/wifi_scan' >> /etc/crontabs/root
|
||||
/etc/init.d/cron start
|
||||
}
|
||||
|
||||
wifi_softap() {
|
||||
local ssid=$(uci get alljoyn-onboarding.@onboarding[0].apssid)
|
||||
local encryption=$(uci get alljoyn-onboarding.@onboarding[0].apencryption)
|
||||
local key=$(uci get alljoyn-onboarding.@onboarding[0].apkey)
|
||||
local hidden=$(uci get alljoyn-onboarding.@onboarding[0].aphidden)
|
||||
uci set wireless.@wifi-iface[0].mode=ap
|
||||
uci set wireless.@wifi-iface[0].network=lan
|
||||
uci set wireless.@wifi-iface[0].ssid="$ssid"
|
||||
uci set wireless.@wifi-iface[0].key="$key"
|
||||
uci set wireless.@wifi-iface[0].encryption=$encryption
|
||||
uci set wireless.@wifi-iface[0].hidden=$hidden
|
||||
uci commit wireless
|
||||
wifi
|
||||
|
||||
# when in soft ap mode, set the scan_wifi cron job to run every 15 minutes
|
||||
/etc/init.d/cron stop
|
||||
sed -i '/\/usr\/sbin\/wifi_scan/d' /etc/crontabs/root
|
||||
echo '*/15 * * * * /usr/sbin/wifi_scan' >> /etc/crontabs/root
|
||||
/etc/init.d/cron start
|
||||
}
|
||||
|
||||
wifi_reset() {
|
||||
wifi
|
||||
}
|
||||
|
||||
wifi_configure_commit() {
|
||||
uci set alljoyn-onboarding.@onboarding[0].ssid="$1"
|
||||
uci set alljoyn-onboarding.@onboarding[0].encryption="$2"
|
||||
if [ "$2" = "wep" ]; then
|
||||
uci set alljoyn-onboarding.@onboarding[0].key="$5"
|
||||
uci set alljoyn-onboarding.@onboarding[0].key$5="$4"
|
||||
else
|
||||
uci set alljoyn-onboarding.@onboarding[0].key="$3"
|
||||
fi
|
||||
uci commit alljoyn-onboarding
|
||||
}
|
||||
|
||||
wifi_connect_status() {
|
||||
ifstatus=$(ifstatus obswifi)
|
||||
json_load "$ifstatus"
|
||||
json_get_var iface device
|
||||
local timeout=4
|
||||
local result=$ERROR_UNREACHABLE
|
||||
local conn_state=0
|
||||
|
||||
if [ -z $iface ]; then
|
||||
echo "Device not defined for obswifi" >&2
|
||||
set_error $ERROR_UNREACHABLE "Unreachable"
|
||||
return $result
|
||||
fi
|
||||
|
||||
while [ ${timeout} -gt 0 ]; do
|
||||
sleep 1
|
||||
ctrl_iface=$(grep ctrl_interface /var/run/wpa_supplicant-${iface}.conf | sed s/ctrl_interface=//)
|
||||
if [ -z "${ctrl_iface}" ]; then
|
||||
conn_state=$(wpa_cli -i ${iface} status 2>/dev/null | grep wpa_state | cut -d= -f2)
|
||||
else
|
||||
conn_state=$(wpa_cli -i ${iface} -p ${ctrl_iface} status 2>/dev/null | grep wpa_state | cut -d= -f2)
|
||||
fi
|
||||
echo ${conn_state} >&2
|
||||
if [ "${conn_state}" = "COMPLETED" ]; then
|
||||
result=$ERROR_NONE
|
||||
set_error $ERROR_NONE "Validated"
|
||||
return $result
|
||||
elif [ "${conn_state}" = "SCANNING" ]; then
|
||||
result=$ERROR_UNREACHABLE
|
||||
set_error $ERROR_UNREACHABLE "Unreachable"
|
||||
elif [ "${conn_state}" = "4WAY_HANDSHAKE" ]; then
|
||||
set_error $ERROR_UNAUTHORIZED "Unauthorized - 4WAY_HANDSHAKE timeout"
|
||||
result=$ERROR_UNAUTHORIZED
|
||||
elif [ "${conn_state}" = "DISCONNECTED" ]; then
|
||||
set_error $ERROR_UNAUTHORIZED "Unauthorized - DISCONNECTED"
|
||||
result=$ERROR_UNAUTHORIZED
|
||||
else
|
||||
result=$ERROR_PROTOCOL
|
||||
set_error $ERROR_PROTOCOL "Unsupported protocol"
|
||||
echo "wpa_cli returned unknown status" >&2
|
||||
fi
|
||||
timeout=$((--timeout))
|
||||
done
|
||||
|
||||
echo "Timeout --> unreachable" >&2
|
||||
return $result
|
||||
}
|
||||
|
||||
showhelp() {
|
||||
cat << EOF
|
||||
$0 -s <ssid> -a <auth>
|
||||
[-p <passphrase>] [-k key] [-i index] [ -t timeout ] [ -d ]
|
||||
|
||||
Mandatory parameters:
|
||||
-s <ssid>: Connect to SSID <ssid>
|
||||
-a <auth>: Use authentication <auth>, where <auth> can be one of:
|
||||
"open": No authentication
|
||||
"wep": WEP authentication
|
||||
"psk": WPA authentication
|
||||
"psk2": WPA2 authentication
|
||||
|
||||
Optional parameters:
|
||||
-p <passphrase>: (WEP or WPA only) Set the WEP (string) or WPA passphrase
|
||||
-k <key>: (WEP only) Set the key (hex key only, either 5 or 13 bytes len)
|
||||
-i <index>: (WEP only) Set the key index (1-4)
|
||||
-t <timeout>: Set the connection timeout (in seconds) - default=4
|
||||
-d : enable debug
|
||||
-h : print this help
|
||||
|
||||
Return value:
|
||||
0: Connection Success
|
||||
1: Connection Failed
|
||||
2: Error
|
||||
EOF
|
||||
}
|
||||
|
||||
check_params() {
|
||||
local ssid=$1
|
||||
local auth=$2
|
||||
local psk=$3
|
||||
local key=$4
|
||||
local index=$5
|
||||
|
||||
if [ -z "${auth}" ] || [ -z "${ssid}" ]; then
|
||||
echo "Error:ssid or authentication not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Using passphrase and/or key and/or index in Open mode is inconsistent
|
||||
if [ "${auth}" = "open" ]; then
|
||||
if [ -n "${key}" -o -n "${index}" -o -n "${psk}" ]; then
|
||||
echo "Open mode can't be used with passphrase/key/index" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If wep is used, make sure we also got a key & its index
|
||||
if [ "${auth}" = "wep" ]; then
|
||||
if [ -z "${key}" ]; then
|
||||
echo "In WEP, please specify the key and optionally, the index" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Having a key and/or index with non-WEP encryption is inconsistent
|
||||
if [ "${auth}" != "wep" ]; then
|
||||
if [ -n "${key}" -o -n "${index}" ]; then
|
||||
echo "Index/Key can't be used with non-WEP authentication " >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If wpa is used, make sure we also got a passphrase
|
||||
case "$auth" in
|
||||
*psk*)
|
||||
if [ -z "${psk}" ]; then
|
||||
echo "In WPA, please specify a passphrase" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $(expr length "${psk}") -lt 8 ]; then
|
||||
echo "In WPA, please specify a passphrase of size at least 8" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $(expr length "${psk}") -eq 64 ]; then
|
||||
local i=0
|
||||
while [ $i -lt 64 ]; do
|
||||
char=${psk:$i:1}
|
||||
case "$char" in
|
||||
|
||||
[a-fA-F0-9] );;
|
||||
|
||||
* )
|
||||
echo "In WPA, please specify an ASCII passphrase of size less than 64 or a Hex passphrase of size 64" >&2
|
||||
return 1;;
|
||||
esac
|
||||
i=$((i+1))
|
||||
done
|
||||
elif [ $(expr length "${psk}") -gt 64 ]; then
|
||||
echo "In WPA, please specify an ASCII passphrase of size less than 64 or a Hex passphrase of size 64" >&2
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
wifi_configure() {
|
||||
# Process arguments
|
||||
local ssid auth psk key index
|
||||
|
||||
while [ -n "$1" ];do
|
||||
case "$1" in
|
||||
-s) ssid="$2"; shift;;
|
||||
-a) auth="$2"; shift
|
||||
|
||||
if [ "${auth}" = "OPEN" ]; then
|
||||
auth="none"
|
||||
fi
|
||||
|
||||
if [ "${auth}" = "WEP" ]; then
|
||||
auth="wep"
|
||||
fi
|
||||
|
||||
case "$auth" in
|
||||
WPA2*)
|
||||
auth="psk2+tkip+ccmp"
|
||||
;;
|
||||
WPA*)
|
||||
auth="psk+tkip+ccmp"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${auth}" = "WPS" ]; then
|
||||
auth="psk"
|
||||
fi
|
||||
|
||||
[ ${auth} = "none" ] || [ ${auth} = "wep" ] || [ ${auth} = "psk+tkip+ccmp" ] || [ ${auth} = "psk2+tkip+ccmp" ] || {
|
||||
echo "Invalid authentication \"${auth}\"" >&2
|
||||
echo "Valid authentication values are \"none\", \"wep\", \"psk+tkip+ccmp\", \"psk2+tkip+ccmp\"" >&2
|
||||
showhelp
|
||||
exit 2;
|
||||
};;
|
||||
-p) psk="$2"; shift;;
|
||||
-k) key="$2"; shift;;
|
||||
-i) index="$2"; shift
|
||||
if [ ! ${index} -ge 1 ] && [ ! ${index} -le 4 ]; then
|
||||
echo "Invalid index \"${index}\"" >&2
|
||||
echo "Valid index values are \"1\", \"2\", \"3\", \"4\"" >&2
|
||||
showhelp
|
||||
exit 2
|
||||
fi;;
|
||||
-t) timeout="$2"; shift;;
|
||||
-d) DEBUG=1;;
|
||||
-h) showhelp; exit 2;;
|
||||
*)
|
||||
echo "Invalid option: -${OPTARG}" >&2
|
||||
showhelp
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "${auth}" = "wep" ]; then
|
||||
if [ -z "${index}" ]; then
|
||||
index=1
|
||||
echo "Defaulting index to 1" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# Perform sanity checks on the script arguments
|
||||
check_params "${ssid}" "${auth}" "${psk}" "${key}" "${index}" || {
|
||||
showhelp
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
|
||||
wifi_configure_commit "${ssid}" "${auth}" "${psk}" "${key}" "${index}"
|
||||
}
|
||||
|
||||
set_error() {
|
||||
uci set -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].lasterrorcode=$1
|
||||
uci set -c /etc/alljoyn-onboarding alljoyn-onboarding-state.@onboarding[0].lasterrormsg="$2"
|
||||
uci commit -c /etc/alljoyn-onboarding alljoyn-onboarding-state
|
||||
printf '%s\n%s' "$1" "$2" > /tmp/state/alljoyn-onboarding-lasterror
|
||||
}
|
||||
34
alljoyn/alljoyn-onboarding/files/wifi_scan
Executable file
34
alljoyn/alljoyn-onboarding/files/wifi_scan
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
# Copyright (c) 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
findPid=$(pgrep /usr/sbin/wifi_scan)
|
||||
|
||||
if [ -z $findPid ]; then
|
||||
|
||||
## Get the scan results based on method available
|
||||
hasIw=$(which iw)
|
||||
hasIwList=$(which iwlist)
|
||||
|
||||
if [ -n "$hasIw" ]; then
|
||||
result=$(/usr/sbin/parse_iw_wifi_scan)
|
||||
elif [ -n "$hasIwList" ]; then
|
||||
result=$(/usr/sbin/parse_iwlist_wifi_scan)
|
||||
fi
|
||||
|
||||
## Sort the results based on signal strength and print it to the file
|
||||
if [ -n "$result" ]; then
|
||||
printf "$result" | sort -n -r | awk '{sep="";for (i=4;i<=NF;i++) {printf "%s%s",sep, $i;sep=" "}; printf "\t"$3"\n"}' | sort | uniq > /tmp/wifi_scan_results
|
||||
fi
|
||||
fi
|
||||
26
alljoyn/alljoyn-onboarding/files/wifi_scan.init
Normal file
26
alljoyn/alljoyn-onboarding/files/wifi_scan.init
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
# Copyright (c) 2013 - 2014, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
START=61
|
||||
|
||||
boot() {
|
||||
# Schedule the script to refresh the results with a cron job
|
||||
/etc/init.d/cron stop
|
||||
sed -i '/\/usr\/sbin\/wifi_scan/d' /etc/crontabs/root
|
||||
echo '*/15 * * * * /usr/sbin/wifi_scan' >> /etc/crontabs/root
|
||||
/etc/init.d/cron start
|
||||
}
|
||||
104
alljoyn/alljoyn-sample_apps/Makefile
Normal file
104
alljoyn/alljoyn-sample_apps/Makefile
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
AJ_SERVICE:=sample_apps
|
||||
AJ_SERVICE_NAME:=sample_apps
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn-$(AJ_SERVICE)
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=.00
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=389c2623619281e6849da25cee7e1bb7
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/alljoyn-services-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=alljoyn-services-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= CONFIG_PACKAGE_$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=on
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
TITLE:=AllJoyn services $(AJ_SERVICE_NAME) - sample applications
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=alljoyn \
|
||||
+alljoyn-about \
|
||||
+alljoyn-config \
|
||||
+alljoyn-controlpanel \
|
||||
+alljoyn-notification \
|
||||
+alljoyn-services_common
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AllJoyn services $(AJ_SERVICE_NAME) sample applications - includes ServerSample and ACServerSample.
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist/$(AJ_SERVICE)
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
|
||||
define Build/Configure/Default
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"BUILD_SERVICES_SAMPLES=$(ALLJOYN_BUILD_SERVICES_SAMPLES)" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
BT=off \
|
||||
ICE=off \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)" \
|
||||
"ALL=1"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/* $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/* $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
||||
|
||||
97
alljoyn/alljoyn-services_common/Makefile
Normal file
97
alljoyn/alljoyn-services_common/Makefile
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
AJ_SERVICE:=services_common
|
||||
AJ_SERVICE_NAME:=Services Common
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn-$(AJ_SERVICE)
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=.00
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=389c2623619281e6849da25cee7e1bb7
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/alljoyn-services-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=alljoyn-services-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=off
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
TITLE:=AllJoyn $(AJ_SERVICE_NAME) service library
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=alljoyn
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
AllJoyn $(AJ_SERVICE_NAME) service library.
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist/$(AJ_SERVICE)
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
|
||||
define Build/Configure/Default
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR)/services/base/$(AJ_SERVICE) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"BUILD_SERVICES_SAMPLES=$(ALLJOYN_BUILD_SERVICES_SAMPLES)" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
BT=off \
|
||||
ICE=off \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(CP) $(PKG_INSTALL_DIR)/inc/alljoyn/$(AJ_SERVICE)/*.h $(1)/usr/include/alljoyn/$(AJ_SERVICE)
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/lib/liballjoyn_$(AJ_SERVICE).so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
301
alljoyn/alljoyn/Makefile
Normal file
301
alljoyn/alljoyn/Makefile
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alljoyn
|
||||
PKG_BASE_VERSION:=14.12
|
||||
PKG_PATCHLEVEL:=a
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=1435d8611a26bfde115a771ab7cd3d74
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)$(PKG_PATCHLEVEL)
|
||||
PKG_TARBALL_VERSION:=$(PKG_BASE_VERSION).00$(PKG_PATCHLEVEL)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_TARBALL_VERSION)-src
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_TARBALL_VERSION)-src.tar.gz
|
||||
PKG_SOURCE_URL:=https://allseenalliance.org/releases/alljoyn/$(PKG_BASE_VERSION)/
|
||||
|
||||
# SCons supports parallel builds but does not support make's jobserver
|
||||
PKG_BUILD_PARALLEL:=$(if $(CONFIG_PKG_BUILD_USE_JOBSERVER),0,1)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_DEBUG \
|
||||
CONFIG_PACKAGE_alljoyn-c \
|
||||
CONFIG_PACKAGE_alljoyn-about \
|
||||
CONFIG_PACKAGE_alljoyn-samples
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
TARGET_CC=$(TARGET_CC_NOCACHE)
|
||||
TARGET_CXX=$(TARGET_CXX_NOCACHE)
|
||||
endif
|
||||
|
||||
define Package/alljoyn/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libopenssl +libpthread +librt +libstdcpp
|
||||
URL:=http://www.allseenalliance.org
|
||||
MAINTAINER:=AllSeen Alliance <allseen-core@lists.allseenalliance.org>
|
||||
endef
|
||||
|
||||
define Package/alljoyn
|
||||
$(call Package/alljoyn/Default)
|
||||
TITLE:=AllJoyn Peer-to-Peer networking
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/alljoyn/description
|
||||
AllJoyn is a daemon and application framework for developing
|
||||
ad hoc peer-to-peer applications. This includes the run-time
|
||||
daemon and C++ library.
|
||||
endef
|
||||
|
||||
|
||||
define Package/alljoyn-non-gw-config
|
||||
$(call Package/alljoyn/Default)
|
||||
TITLE:=AllJoyn - alternate non-Gateway Config
|
||||
DEPENDS:=alljoyn
|
||||
endef
|
||||
|
||||
define Package/alljoyn-non-gw-config/description
|
||||
Alternate AllJoyn configuration with defaults suitable for
|
||||
non-Gateway devices. Do not install this on devices with a
|
||||
network interface connected to an insecure network such as
|
||||
the Internet.
|
||||
endef
|
||||
|
||||
|
||||
define Package/alljoyn-c
|
||||
$(call Package/alljoyn/Default)
|
||||
TITLE:=AllJoyn - C binding
|
||||
DEPENDS:=alljoyn
|
||||
endef
|
||||
|
||||
define Package/alljoyn-c/description
|
||||
AllJoyn C binding. This provides a C library for building
|
||||
AllJoyn programs in C. This is just a C callable wrapper
|
||||
to the C++ library.
|
||||
endef
|
||||
|
||||
|
||||
define Package/alljoyn-about
|
||||
$(call Package/alljoyn/Default)
|
||||
TITLE:=AllJoyn - About service library (deprecated)
|
||||
DEPENDS:=alljoyn
|
||||
endef
|
||||
|
||||
define Package/alljoyn-about/description
|
||||
AllJoyn About services library. This library is deprecated. The functionality
|
||||
provided by About has been integrated into liballjoyn with a simpler API. This
|
||||
library will continue to be supported into 2015 and will be removed in 2016.
|
||||
endef
|
||||
|
||||
define Package/alljoyn-samples
|
||||
$(call Package/alljoyn/Default)
|
||||
TITLE:=AllJoyn - testing samples
|
||||
DEPENDS:=alljoyn \
|
||||
+PACKAGE_alljoyn-about:alljoyn-about
|
||||
endef
|
||||
|
||||
define Package/alljoyn-samples/description
|
||||
Alljoyn samples. (This is primarily for testing. The contents of this
|
||||
package vary according which other alljoyn packages are selected.)
|
||||
endef
|
||||
|
||||
ALLJOYN_BINDINGS:=cpp,
|
||||
ALLJOYN_SERVICES:=
|
||||
ALLJOYN_BUILD_SERVICES_SAMPLES:=off
|
||||
|
||||
ifdef CONFIG_PACKAGE_alljoyn-c
|
||||
ALLJOYN_BINDINGS+=c,
|
||||
endif
|
||||
|
||||
ifdef CONFIG_PACKAGE_alljoyn-about
|
||||
ALLJOYN_SERVICES+=about,
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
ALLJOYN_BUILD_VARIANT:=debug
|
||||
else
|
||||
ALLJOYN_BUILD_VARIANT:=release
|
||||
endif
|
||||
|
||||
|
||||
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/build/openwrt/openwrt/$(ALLJOYN_BUILD_VARIANT)/dist
|
||||
|
||||
TARGET_CFLAGS+=-fPIC
|
||||
TARGET_CPPFLAGS+=-fPIC
|
||||
|
||||
define Build/Configure
|
||||
# Override default to do nothing
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
scons -C $(PKG_BUILD_DIR) \
|
||||
$(PKG_JOBS) \
|
||||
WS=off \
|
||||
CPU=openwrt \
|
||||
OS=openwrt \
|
||||
"BINDINGS=$(ALLJOYN_BINDINGS)" \
|
||||
"SERVICES=$(ALLJOYN_SERVICES)" \
|
||||
"BUILD_SERVICES_SAMPLES=$(ALLJOYN_BUILD_SERVICES_SAMPLES)" \
|
||||
"VARIANT=$(ALLJOYN_BUILD_VARIANT)" \
|
||||
BR=off \
|
||||
ICE=off \
|
||||
POLICYDB=on \
|
||||
"TARGET_CC=$$(TARGET_CC)" \
|
||||
"TARGET_CXX=$$(TARGET_CXX)" \
|
||||
"TARGET_CFLAGS=$$(TARGET_CFLAGS)" \
|
||||
"TARGET_CPPFLAGS=$$(TARGET_CPPFLAGS)" \
|
||||
"TARGET_PATH=$$(TARGET_PATH)" \
|
||||
"TARGET_LINKFLAGS=$$(TARGET_LDFLAGS)" \
|
||||
"TARGET_LINK=$$(TARGET_CC)" \
|
||||
"TARGET_AR=$$(TARGET_AR)" \
|
||||
"TARGET_RANLIB=$$(TARGET_RANLIB)" \
|
||||
"STAGING_DIR=$$(STAGING_DIR)"
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn
|
||||
$(INSTALL_DIR) $(1)/usr/include/qcc
|
||||
$(INSTALL_DIR) $(1)/usr/include/qcc/posix
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/inc/alljoyn/*.h $(1)/usr/include/alljoyn/
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/inc/qcc/*.h $(1)/usr/include/qcc/
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/inc/qcc/posix/*.h $(1)/usr/include/qcc/posix/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/lib/liballjoyn.a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/lib/liballjoyn.so $(1)/usr/lib/
|
||||
ifdef CONFIG_PACKAGE_alljoyn-about
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn/about
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/inc/alljoyn/about/*.h $(1)/usr/include/alljoyn/about
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/lib/liballjoyn_about.a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/lib/liballjoyn_about.so $(1)/usr/lib/
|
||||
endif
|
||||
ifdef CONFIG_PACKAGE_alljoyn-c
|
||||
$(INSTALL_DIR) $(1)/usr/include/alljoyn_c
|
||||
$(CP) $(PKG_INSTALL_DIR)/c/inc/alljoyn_c/*.h $(1)/usr/include/alljoyn_c/
|
||||
$(CP) $(PKG_INSTALL_DIR)/c/lib/liballjoyn_c.a $(1)/usr/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/c/lib/liballjoyn_c.so $(1)/usr/lib/
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/alljoyn/conffiles
|
||||
/etc/alljoyn/alljoyn.conf
|
||||
/etc/config/alljoyn
|
||||
endef
|
||||
|
||||
define Package/alljoyn-non-gw-config/conffiles
|
||||
/etc/config/alljoyn
|
||||
endef
|
||||
|
||||
define Package/alljoyn/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/alljoyn-daemon $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/lib/liballjoyn.so $(1)/usr/lib/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/alljoyn.init $(1)/etc/init.d/alljoyn
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/alljoyn.defaults $(1)/etc/uci-defaults/alljoyn
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/alljoyn.config $(1)/etc/config/alljoyn
|
||||
$(INSTALL_DIR) $(1)/etc/alljoyn
|
||||
$(INSTALL_CONF) ./files/alljoyn.conf $(1)/etc/alljoyn/alljoyn.conf
|
||||
endef
|
||||
|
||||
define Package/alljoyn-non-gw-config/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/alljoyn-non-gw.config $(1)/etc/config/alljoyn
|
||||
endef
|
||||
|
||||
define Package/alljoyn-c/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/c/lib/liballjoyn_c.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/alljoyn-about/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/cpp/lib/liballjoyn_about.so $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/alljoyn-samples/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/advtunnel $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/aes_ccm $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bastress $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bastress2 $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bbclient $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bbjitter $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bbjoin $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bbservice $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bbsig $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/bignum $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/compression $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/keystore $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/marshal $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/names $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/ns $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/rawclient $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/rawservice $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/remarshal $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/rsa $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/sessions $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/socktest $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/srp $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/unpack $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/samples/AboutClient $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/samples/AboutService $(1)/usr/bin/
|
||||
ifdef CONFIG_PACKAGE_alljoyn-about
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/cpp/bin/samples/sample_rule_app $(1)/usr/bin/
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/alljoyn/postinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
. /etc/uci-defaults/alljoyn
|
||||
rm -f /etc/uci-defaults/alljoyn
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/alljoyn/prerm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
/etc/init.d/alljoyn stop
|
||||
/etc/init.d/alljoyn disable
|
||||
uci batch <<EOF
|
||||
del_list ucitrack.@network[-1].affects=alljoyn
|
||||
delete ucitrack.@alljoyn[-1]
|
||||
commit ucitrack
|
||||
EOF
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
define Package/alljoyn-non-gw-config/preinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo 'Saving original alljoyn config file to alljoyn-orig'
|
||||
mv /etc/config/alljoyn /etc/config/alljoyn-orig
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/alljoyn-non-gw-config/postrm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
if [ -e /etc/config/alljoyn-orig ]; then
|
||||
echo 'Restoring original alljoyn config file from alljoyn-orig'
|
||||
mv /etc/config/alljoyn-orig /etc/config/alljoyn
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,alljoyn))
|
||||
$(eval $(call BuildPackage,alljoyn-non-gw-config))
|
||||
$(eval $(call BuildPackage,alljoyn-c))
|
||||
$(eval $(call BuildPackage,alljoyn-about))
|
||||
$(eval $(call BuildPackage,alljoyn-samples))
|
||||
|
||||
25
alljoyn/alljoyn/files/alljoyn-non-gw.config
Normal file
25
alljoyn/alljoyn/files/alljoyn-non-gw.config
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
config transport 'unix'
|
||||
option enable '1'
|
||||
option path 'alljoyn'
|
||||
option abstract '1'
|
||||
|
||||
config transport 'ip'
|
||||
option enable '1'
|
||||
option max_incomplete_conn '16'
|
||||
option max_complete_conn '96'
|
||||
option bus_port '9955'
|
||||
option auth_timeout '20000'
|
||||
option advertise_daemon '1'
|
||||
option all_networks '1'
|
||||
list networks
|
||||
|
||||
config transport 'slap'
|
||||
option enable '0'
|
||||
option path '/dev/ttyUSB0'
|
||||
option baud 115200
|
||||
option databits 8
|
||||
option parity 'none'
|
||||
option stopbits 1
|
||||
|
||||
config daemon 'daemon'
|
||||
option user 'nobody'
|
||||
38
alljoyn/alljoyn/files/alljoyn.conf
Normal file
38
alljoyn/alljoyn/files/alljoyn.conf
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
|
||||
<!--
|
||||
Copyright (c) 2014, AllSeen Alliance. All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
-->
|
||||
|
||||
<busconfig>
|
||||
<type>alljoyn</type>
|
||||
<fork/>
|
||||
<syslog/>
|
||||
|
||||
<!-- Default limits -->
|
||||
<limit name="auth_timeout">20000</limit>
|
||||
<limit name="max_incomplete_connections">16</limit>
|
||||
<limit name="max_completed_connections">96</limit>
|
||||
<limit name="max_untrusted_clients">96</limit>
|
||||
<flag name="restrict_untrusted_clients">false</flag>
|
||||
|
||||
<!-- Include configuration file generated from /etc/config/alljoyn -->
|
||||
<include>/var/etc/alljoyn.conf</include>
|
||||
|
||||
<!-- Include Gateway Agent policy rules configuration -->
|
||||
<includedir ignore_missing="yes">/etc/alljoyn/gwagent</includeidr>
|
||||
|
||||
</busconfig>
|
||||
25
alljoyn/alljoyn/files/alljoyn.config
Normal file
25
alljoyn/alljoyn/files/alljoyn.config
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
config transport 'unix'
|
||||
option enable '1'
|
||||
option path 'alljoyn'
|
||||
option abstract '1'
|
||||
|
||||
config transport 'ip'
|
||||
option enable '1'
|
||||
option max_incomplete_conn '16'
|
||||
option max_complete_conn '96'
|
||||
option bus_port '9955'
|
||||
option auth_timeout '20000'
|
||||
option advertise_daemon '1'
|
||||
option all_networks '0'
|
||||
list networks 'lan'
|
||||
|
||||
config transport 'slap'
|
||||
option enable '0'
|
||||
option path '/dev/ttyUSB0'
|
||||
option baud 115200
|
||||
option databits 8
|
||||
option parity 'none'
|
||||
option stopbits 1
|
||||
|
||||
config daemon 'daemon'
|
||||
option user 'nobody'
|
||||
9
alljoyn/alljoyn/files/alljoyn.defaults
Normal file
9
alljoyn/alljoyn/files/alljoyn.defaults
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#! /bin/sh
|
||||
uci batch <<EOF
|
||||
add ucitrack alljoyn
|
||||
set ucitrack.@alljoyn[-1].init=alljoyn
|
||||
add_list ucitrack.@network[-1].affects=alljoyn
|
||||
commit ucitrack
|
||||
EOF
|
||||
/etc/init.d/alljoyn enable
|
||||
exit 0
|
||||
170
alljoyn/alljoyn/files/alljoyn.init
Normal file
170
alljoyn/alljoyn/files/alljoyn.init
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
# Copyright (c) 2013-2015, AllSeen Alliance. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
START=65
|
||||
|
||||
SERVICE_PID_FILE=/var/run/alljoyn.pid
|
||||
|
||||
CONFIGFILE="/etc/alljoyn/alljoyn.conf"
|
||||
GENCONFIGFILE="/var/etc/alljoyn.conf"
|
||||
|
||||
|
||||
check() {
|
||||
local flag
|
||||
|
||||
config_get_bool flag "$1" "$2" 0
|
||||
|
||||
test "$flag" == "1"
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
process_unix_transport() {
|
||||
if check unix enable; then
|
||||
local path
|
||||
local abstract
|
||||
|
||||
|
||||
config_get path unix path "alljoyn"
|
||||
config_get_bool abstract unix abstract "1"
|
||||
|
||||
if [ -n "$abstract" ]; then
|
||||
path="abstract=$path"
|
||||
else
|
||||
path="path=$path"
|
||||
fi
|
||||
export ${NO_EXPORT:+-n} listen_specs="${listen_specs}
|
||||
<listen>unix:${path}</listen>"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
process_ip_network() {
|
||||
local network="$1"
|
||||
local port="$2"
|
||||
local ifname
|
||||
|
||||
config_get ifname "$network" ifname
|
||||
if [ -n "$ifname" ]; then
|
||||
export ${NO_EXPORT:+-n} listen_specs="${listen_specs}
|
||||
<listen>tcp:iface=${ifname},port=${port}</listen>
|
||||
<listen>udp:iface=${ifname},port=${port}</listen>"
|
||||
fi
|
||||
}
|
||||
|
||||
process_ip_transport() {
|
||||
if check ip enable; then
|
||||
local port
|
||||
|
||||
if check ip advertise_daemon; then
|
||||
export ${NO_EXPORT:+-n} ip_advertise_daemon="<property name=\"router_advertisement_prefix\">org.alljoyn.BusNode.</property>"
|
||||
fi
|
||||
|
||||
config_get port ip bus_port 9955
|
||||
|
||||
if check ip all_networks; then
|
||||
export ${NO_EXPORT:+-n} listen_specs="${listen_specs}
|
||||
<listen>tcp:iface=*,port=${port}</listen>
|
||||
<listen>udp:iface=*,port=${port}</listen>"
|
||||
else
|
||||
config_load network
|
||||
config_load alljoyn # loading the network config clobbers the alljoyn config vars
|
||||
config_list_foreach ip networks process_ip_network "${port}"
|
||||
fi
|
||||
|
||||
config_get ip_max_incomplete_conn ip max_incomplete_conn "$ip_max_incomplete_conn"
|
||||
config_get ip_max_complete_conn ip max_complete_conn "$ip_max_complete_conn"
|
||||
config_get ip_auth_timeout ip auth_timeout "$ip_auth_timeout"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
process_slap_transport() {
|
||||
if check slap enable; then
|
||||
local path
|
||||
local baud
|
||||
|
||||
config_get path slap path "/dev/ttyUSB0"
|
||||
config_get baud slap baud "115200"
|
||||
config_get databits slap databits "8"
|
||||
config_get parity slap parity "none"
|
||||
config_get stopbits slap stopbits "1"
|
||||
|
||||
export ${NO_EXPORT:+-n} listen_specs="${listen_specs}
|
||||
<listen>slap:type=uart;dev=${path};baud=${baud};databits=${databits};parity=${parity};stopbits=${stopbits}</listen>"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
process_switch_user() {
|
||||
local user
|
||||
|
||||
config_get user daemon user "root"
|
||||
|
||||
if [ "$user" != "root" ]; then
|
||||
export ${NO_EXPORT:+-n} switch_user="<user>${user}</user>"
|
||||
fi
|
||||
}
|
||||
|
||||
generate_conf_file() {
|
||||
local listen_specs=""
|
||||
|
||||
local ip_max_incomplete_conn=16
|
||||
local ip_max_complete_conn=64
|
||||
local ip_auth_timeout=20000
|
||||
local ip_networks=""
|
||||
local ip_advertise_daemon=""
|
||||
local switch_user=""
|
||||
|
||||
rm -f $GENCONFIGFILE
|
||||
|
||||
include /lib/network
|
||||
|
||||
config_load alljoyn
|
||||
|
||||
process_unix_transport
|
||||
process_ip_transport
|
||||
process_slap_transport
|
||||
process_switch_user
|
||||
|
||||
mkdir -p $(dirname $GENCONFIGFILE)
|
||||
|
||||
cat > $GENCONFIGFILE <<EOF
|
||||
<busconfig>
|
||||
<pidfile>${SERVICE_PID_FILE}</pidfile>
|
||||
${switch_user}
|
||||
${listen_specs}
|
||||
${ip_advertise_daemon}
|
||||
<limit name="auth_timeout">${ip_auth_timeout}</limit>
|
||||
<limit name="max_incomplete_connections">${ip_max_incomplete_conn}</limit>
|
||||
<limit name="max_completed_connections">${ip_max_complete_conn}</limit>
|
||||
<limit name="max_untrusted_clients">${ip_max_complete_conn}</limit>
|
||||
</busconfig>
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
generate_conf_file
|
||||
if [ -e $CONFIGFILE ]; then
|
||||
service_start /usr/bin/alljoyn-daemon --config-file=$CONFIGFILE
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/bin/alljoyn-daemon
|
||||
}
|
||||
65
alljoyn/readme.txt
Normal file
65
alljoyn/readme.txt
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
This repository is designated to serve as a feed for OpenWrt
|
||||
(http://openwrt.org) based systems. As such, the organization, management,
|
||||
and usage of this repository will be different from the other source
|
||||
repositories hosted by the AllSeen Alliance.
|
||||
|
||||
Most notable of these differences is that the master branch only contains this
|
||||
readme file. Package definitions will only exist in branches whos name
|
||||
corresponds to code names for OpenWrt releases. At the time of the initial
|
||||
commit of this readme file, there will be 2 such branches: attitude_adjustment
|
||||
and barrier_breaker. As the OpenWrt project develops and creates new
|
||||
releases, new corresponding branches will be created.
|
||||
|
||||
The reason for tracking package definitions on a per OpenWrt release basis is
|
||||
due to the fact that AllJoyn packages depend on OpenWrt packages which may
|
||||
change from release to release. This also allows us to retire support for
|
||||
obsolete versions of OpenWrt in the future without breaking others who may
|
||||
still be using/building the obsolete versions.
|
||||
|
||||
To use this feed in an OpenWrt build environment, follow these instructions:
|
||||
|
||||
1. Copy feeds.conf.default to feeds.conf (if not already done):
|
||||
|
||||
cp feeds.conf.default feeds.conf
|
||||
|
||||
|
||||
2. Add the following feeds.conf (replace <openwrt_release> with the
|
||||
appropriate branch that corresponds to the OpenWrt release you are building):
|
||||
|
||||
src-git alljoyn git://git.allseenalliance.org/gerrit/core/openwrt_feed;<openwrt_release>
|
||||
|
||||
# For Attitude Adjustment
|
||||
src-git alljoyn git://git.allseenalliance.org/gerrit/core/openwrt_feed;attitude_adjustment
|
||||
|
||||
# For Barrier Breaker
|
||||
src-git alljoyn git://git.allseenalliance.org/gerrit/core/openwrt_feed;barrier_breaker
|
||||
|
||||
|
||||
3. Update the feed information:
|
||||
|
||||
./scripts/feeds update -a
|
||||
|
||||
|
||||
4. Add the the packages from the AllJoyn feed to build system:
|
||||
|
||||
./scripts feeds install -a -p alljoyn
|
||||
|
||||
5. Enable AllJoyn in the build:
|
||||
|
||||
make menuconfig
|
||||
|
||||
Networking --->
|
||||
< > alljoyn --->
|
||||
< > alljoyn-about
|
||||
< > alljoyn-c
|
||||
< > alljoyn-config
|
||||
< > alljoyn-config-samples
|
||||
< > alljoyn-controlpanel
|
||||
< > alljoyn-controlpanel-samples
|
||||
< > alljoyn-notification
|
||||
< > alljoyn-notification-samples
|
||||
< > alljoyn-onboarding
|
||||
< > alljoyn-onboarding-samples
|
||||
< > alljoyn-sample_apps
|
||||
< > alljoyn-samples
|
||||
< > alljoyn-service_common
|
||||
39
wifimngr/Makefile
Normal file
39
wifimngr/Makefile
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# Copyright (C) 2015 Inteno
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=wifimngr
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
define Package/wifimngr
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libpthread +libstdcpp +librt +libjson +alljoyn +ubus +libuci
|
||||
TITLE:=WiFi Manager
|
||||
endef
|
||||
|
||||
define Package/wifimngr/description
|
||||
wifimngr manages wireless driver
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Package/wifimngr/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/wifimngr $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,wifimngr))
|
||||
16
wifimngr/src/Makefile
Normal file
16
wifimngr/src/Makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
CC = g++
|
||||
CXXFLAGS = -Wall -pipe -std=c++98 -fno-rtti -fno-exceptions -Wno-long-long -Wno-deprecated -g -DQCC_OS_LINUX -DQCC_OS_GROUP_POSIX -DQCC_CPU_X86
|
||||
LIBS = -lalljoyn -lstdc++ -lcrypto -lpthread -lrt -luci -lubus -lubox -lblobmsg_json -ljson-c
|
||||
OBJS = wifimngr.o tools.o ubus.o jsp.o
|
||||
SRCS = wifimngr.cc tools.cc ubus.c jsp.c
|
||||
LIBSRCS =
|
||||
ISRCS = wifi.h common.h
|
||||
|
||||
all: wifimngr
|
||||
|
||||
wifimngr: ${OBJS}
|
||||
${CC} ${LDFLAGS} ${LIBSRCS} -o wifimngr ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f wifimngr *.o
|
||||
|
||||
14
wifimngr/src/common.h
Normal file
14
wifimngr/src/common.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
typedef struct {
|
||||
int conntype;
|
||||
char hostname[128];
|
||||
char macaddr[24];
|
||||
char wdev[8];
|
||||
} Client;
|
||||
|
||||
void ubus_listener();
|
||||
void wps_event(const char *key, const char *val);
|
||||
void removeNewline(char *buf);
|
||||
const char *chrCmd(const char *pFmt, ...);
|
||||
|
||||
const char *json_parse_and_get(const char *str, char *var);
|
||||
void json_parse_clients(Client *clnt);
|
||||
139
wifimngr/src/jsp.c
Normal file
139
wifimngr/src/jsp.c
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <json-c/json.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
const char*
|
||||
json_parse_and_get(const char *str, char *var)
|
||||
{
|
||||
json_object *obj;
|
||||
char result[128];
|
||||
|
||||
obj = json_tokener_parse(str);
|
||||
if (is_error(obj) || json_object_get_type(obj) != json_type_object) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_object_object_foreach(obj, key, val) {
|
||||
if(!strcmp(key, var)) {
|
||||
switch (json_object_get_type(val)) {
|
||||
case json_type_object:
|
||||
break;
|
||||
case json_type_array:
|
||||
break;
|
||||
case json_type_string:
|
||||
sprintf(result, "%s", json_object_get_string(val));
|
||||
break;
|
||||
case json_type_boolean:
|
||||
sprintf(result, "%d", json_object_get_boolean(val));
|
||||
break;
|
||||
case json_type_int:
|
||||
sprintf(result, "%d", json_object_get_int(val));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
json_object_put(obj);
|
||||
|
||||
if (strlen(result))
|
||||
return strdup(result);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Client clients[128];
|
||||
static int cno;
|
||||
|
||||
static int add_json_element(const char *key, json_object *obj);
|
||||
static int add_json_client_element(const char *key, json_object *obj);
|
||||
|
||||
static int add_json_object(json_object *obj)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
json_object_object_foreach(obj, key, val) {
|
||||
if (strstr(key, "client-")) {
|
||||
cno++;
|
||||
ret = add_json_element(key, val);
|
||||
} else if (!strcmp(key, "wireless") || !strcmp(key, "wdev") || !strcmp(key, "hostname") || !strcmp(key, "macaddr") || !strcmp(key, "connected")) {
|
||||
ret = add_json_client_element(key, val);
|
||||
}
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int add_json_client_element(const char *key, json_object *obj)
|
||||
{
|
||||
char *type;
|
||||
|
||||
if (!obj)
|
||||
return -1;
|
||||
|
||||
if (!strcmp(key, "hostname")) {
|
||||
strcpy(clients[cno].hostname, json_object_get_string(obj));
|
||||
} else if (!strcmp(key, "macaddr")) {
|
||||
strcpy(clients[cno].macaddr, json_object_get_string(obj));
|
||||
} else if (!strcmp(key, "connected")) {
|
||||
clients[cno].conntype = json_object_get_boolean(obj);
|
||||
} else if (!strcmp(key, "wireless")) {
|
||||
if (json_object_get_boolean(obj))
|
||||
clients[cno].conntype = 2;
|
||||
} else if (!strcmp(key, "wdev")) {
|
||||
strcpy(clients[cno].wdev, json_object_get_string(obj));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_json_element(const char *key, json_object *obj)
|
||||
{
|
||||
char *type;
|
||||
|
||||
if (!obj)
|
||||
return -1;
|
||||
|
||||
switch (json_object_get_type(obj)) {
|
||||
case json_type_object:
|
||||
add_json_object(obj);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
json_parse_clients(Client *clnt)
|
||||
{
|
||||
json_object *obj;
|
||||
FILE *in;
|
||||
char clist[50000];
|
||||
|
||||
cno = -1;
|
||||
memset(clients, '\0', sizeof(clients));
|
||||
|
||||
if ((in = popen("ubus -S call router clients", "r")))
|
||||
fgets(clist, sizeof(clist), in);
|
||||
pclose(in);
|
||||
|
||||
if(strlen(clist) < 64)
|
||||
return;
|
||||
|
||||
obj = json_tokener_parse(clist);
|
||||
if (is_error(obj) || json_object_get_type(obj) != json_type_object) {
|
||||
fprintf(stderr, "Failed to parse message data\n");
|
||||
return;
|
||||
}
|
||||
add_json_object(obj);
|
||||
json_object_put(obj);
|
||||
|
||||
memcpy(clnt, clients, sizeof(clients));
|
||||
}
|
||||
243
wifimngr/src/tools.cc
Normal file
243
wifimngr/src/tools.cc
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
extern "C"
|
||||
{
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
}
|
||||
|
||||
#include "wifi.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void
|
||||
removeNewline(char *buf)
|
||||
{
|
||||
int len;
|
||||
len = strlen(buf) - 1;
|
||||
if (buf[len] == '\n')
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
dotToUnderscore(char *buf)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (buf[i]) {
|
||||
if (buf[i] == '.')
|
||||
buf[i] = '_';
|
||||
i++;
|
||||
}
|
||||
buf[i] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
runCmd(const char *pFmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char cmd[256] = {0};
|
||||
int len=0, maxLen;
|
||||
|
||||
maxLen = sizeof(cmd);
|
||||
|
||||
va_start(ap, pFmt);
|
||||
|
||||
if (len < maxLen)
|
||||
{
|
||||
maxLen -= len;
|
||||
vsnprintf(&cmd[len], maxLen, pFmt, ap);
|
||||
}
|
||||
|
||||
system(cmd);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
const char*
|
||||
chrCmd(const char *pFmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char cmd[256] = {0};
|
||||
int len=0, maxLen;
|
||||
|
||||
maxLen = sizeof(cmd);
|
||||
|
||||
va_start(ap, pFmt);
|
||||
|
||||
if (len < maxLen)
|
||||
{
|
||||
maxLen -= len;
|
||||
vsnprintf(&cmd[len], maxLen, pFmt, ap);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
FILE *pipe;
|
||||
char buffer[128];
|
||||
if ((pipe = popen(cmd, "r")))
|
||||
fgets(buffer, sizeof(buffer), pipe);
|
||||
pclose(pipe);
|
||||
|
||||
if (strlen(buffer))
|
||||
return strdup(buffer);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string
|
||||
strCmd(const char *pFmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char cmd[256] = {0};
|
||||
int len=0, maxLen;
|
||||
|
||||
maxLen = sizeof(cmd);
|
||||
|
||||
va_start(ap, pFmt);
|
||||
|
||||
if (len < maxLen)
|
||||
{
|
||||
maxLen -= len;
|
||||
vsnprintf(&cmd[len], maxLen, pFmt, ap);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
FILE* pipe = popen(cmd, "r");
|
||||
string result = "";
|
||||
char buffer[128];
|
||||
if (pipe) {
|
||||
while(!feof(pipe)) {
|
||||
if(fgets(buffer, 128, pipe) != NULL)
|
||||
result += buffer;
|
||||
}
|
||||
}
|
||||
pclose(pipe);
|
||||
result.erase(result.find_last_not_of("\n")+1);
|
||||
return result;
|
||||
}
|
||||
|
||||
string
|
||||
readFile(char *path)
|
||||
{
|
||||
ifstream file(path);
|
||||
string str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
|
||||
return str;
|
||||
}
|
||||
|
||||
string
|
||||
toStr(int num)
|
||||
{
|
||||
ostringstream result;
|
||||
result << num;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
static struct uci_context *uci_ctx;
|
||||
static struct uci_ptr ptr;
|
||||
|
||||
struct uci_package *
|
||||
init_package(const char *config)
|
||||
{
|
||||
struct uci_context *ctx = uci_ctx;
|
||||
struct uci_package *p = NULL;
|
||||
|
||||
if (!ctx) {
|
||||
ctx = uci_alloc_context();
|
||||
uci_ctx = ctx;
|
||||
} else {
|
||||
p = uci_lookup_package(ctx, config);
|
||||
if (p)
|
||||
uci_unload(ctx, p);
|
||||
}
|
||||
|
||||
if (uci_load(ctx, config, &p))
|
||||
return NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline int
|
||||
uciGetPtr(const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
memset(&ptr, 0, sizeof(ptr));
|
||||
ptr.package = p;
|
||||
ptr.section = s;
|
||||
ptr.option = o;
|
||||
ptr.value = t;
|
||||
return uci_lookup_ptr(uci_ctx, &ptr, NULL, true);
|
||||
}
|
||||
|
||||
const char*
|
||||
uciGet(const char *p, const char *s, const char *o)
|
||||
{
|
||||
const char *value = NULL;
|
||||
|
||||
if(uciGetPtr(p, s, o, NULL))
|
||||
return NULL;
|
||||
|
||||
if(ptr.o->type == UCI_TYPE_STRING)
|
||||
value = ptr.o->v.string;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
uciSet(const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
uciGetPtr(p, s, o, (t)?(t):(""));
|
||||
uci_set(uci_ctx, &ptr);
|
||||
}
|
||||
|
||||
void
|
||||
uciCommit(const char *p)
|
||||
{
|
||||
if(uciGetPtr(p, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_commit(uci_ctx, &ptr.p, false);
|
||||
}
|
||||
|
||||
const char *
|
||||
ugets(struct uci_section *s, const char *opt)
|
||||
{
|
||||
const char *value = NULL;
|
||||
value = uci_lookup_option_string(uci_ctx, s, opt);
|
||||
return value;
|
||||
}
|
||||
|
||||
int
|
||||
ugeti(struct uci_section *s, const char *opt)
|
||||
{
|
||||
const char *value = NULL;
|
||||
int ret = 0;
|
||||
if ((value = uci_lookup_option_string(uci_ctx, s, opt))) ret = atoi(value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
uset(struct uci_section *s, const char *opt, const char *value)
|
||||
{
|
||||
int found = string(s->package->path).find_last_of('/');
|
||||
const char *path = string(s->package->path).substr(found+1).c_str();
|
||||
uciGetPtr(path, s->e.name, opt, (value)?(value):(""));
|
||||
uci_set(uci_ctx, &ptr);
|
||||
}
|
||||
|
||||
void
|
||||
ucommit(struct uci_section *s)
|
||||
{
|
||||
int found = string(s->package->path).find_last_of('/');
|
||||
const char *path = string(s->package->path).substr(found+1).c_str();
|
||||
if(uciGetPtr(path, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_commit(uci_ctx, &ptr.p, false);
|
||||
}
|
||||
|
||||
57
wifimngr/src/ubus.c
Normal file
57
wifimngr/src/ubus.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <libubox/blobmsg.h>
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include <libubox/uloop.h>
|
||||
#include <libubus.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static struct ubus_context *ctx;
|
||||
static struct ubus_event_handler event_listener;
|
||||
static struct blob_buf b;
|
||||
|
||||
static void
|
||||
receive_event(struct ubus_context *ctx, struct ubus_event_handler *ev, const char *type, struct blob_attr *msg)
|
||||
{
|
||||
char *str;
|
||||
const char *sta;
|
||||
|
||||
str = blobmsg_format_json(msg, true);
|
||||
|
||||
if(!strcmp(type, "wps")) {
|
||||
if(sta = json_parse_and_get(str, "status"))
|
||||
wps_event("status", sta);
|
||||
else if (sta = json_parse_and_get(str, "sta"))
|
||||
wps_event("sta", sta);
|
||||
}
|
||||
|
||||
free(str);
|
||||
}
|
||||
|
||||
void
|
||||
ubus_listener()
|
||||
{
|
||||
const char *ubus_socket = NULL;
|
||||
int ret;
|
||||
|
||||
uloop_init();
|
||||
|
||||
ctx = ubus_connect(ubus_socket);
|
||||
if (!ctx) {
|
||||
fprintf(stderr, "Failed to connect to ubus\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ubus_add_uloop(ctx);
|
||||
|
||||
event_listener.cb = receive_event;
|
||||
ret = ubus_register_event_handler(ctx, &event_listener, "wps");
|
||||
if (ret)
|
||||
fprintf(stderr, "Couldn't register to router events\n");
|
||||
|
||||
uloop_run();
|
||||
|
||||
ubus_free(ctx);
|
||||
uloop_done();
|
||||
}
|
||||
62
wifimngr/src/wifi.h
Normal file
62
wifimngr/src/wifi.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef WIFI_H
|
||||
#define WIFI_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
//class Wireless {
|
||||
// public:
|
||||
// string ssid, encryption, key;
|
||||
// string radio2g, radio5g;
|
||||
// int enable, channel2g, channel5g;
|
||||
// string getChannels (int);
|
||||
// void setChannel (int,int);
|
||||
// void setSsid (string);
|
||||
// void setKey (string);
|
||||
//};
|
||||
|
||||
//class WirelessRadio {
|
||||
// public:
|
||||
// string name, country, hwmode;
|
||||
// char band;
|
||||
// int bwCap, channel, autoChanTimer, dfsChanSelect, obssCoex, txPower, rxChainPwrSave;
|
||||
// int frameBursting, fragThresh, rtsThresh, dtimInterval, bcnInterval, wmmMode;
|
||||
// void setChannel (int);
|
||||
//};
|
||||
|
||||
//class WirelessInterface {
|
||||
// public:
|
||||
// string ifname;
|
||||
// string radio, mode, ssid, encryption, cipher, key;
|
||||
// int enable, gtkRekeyIntv, enableWps, macFilterMode;
|
||||
// int hidden, maxAssoc, isolate, enableWmf;
|
||||
// void setFilterList (string);
|
||||
// string getMacFilterList (void);
|
||||
//};
|
||||
|
||||
//class WPS {
|
||||
// public:
|
||||
// int enable;
|
||||
// void activate (int);
|
||||
// void changeStatus ();
|
||||
//};
|
||||
|
||||
#endif
|
||||
|
||||
#define MAX_WDEV 2
|
||||
#define MAX_WIFC 2
|
||||
|
||||
#include <uci.h>
|
||||
struct uci_package *init_package(const char *config);
|
||||
const char * ugets(struct uci_section *s, const char *opt);
|
||||
int ugeti(struct uci_section *s, const char *opt);
|
||||
void uset(struct uci_section *s, const char *opt, const char *value);
|
||||
void ucommit(struct uci_section *s);
|
||||
const char* uciGet(const char *p, const char *s, const char *o);
|
||||
void uciSet(const char *p, const char *s, const char *o, const char *t);
|
||||
void uciCommit(const char *p);
|
||||
void runCmd(const char *pFmt, ...);
|
||||
string strCmd(const char *pFmt, ...);
|
||||
string toStr(int num);
|
||||
//void populateWireless(void);
|
||||
755
wifimngr/src/wifimngr.cc
Normal file
755
wifimngr/src/wifimngr.cc
Normal file
|
|
@ -0,0 +1,755 @@
|
|||
#include <qcc/Debug.h>
|
||||
#include <qcc/Log.h>
|
||||
#include <qcc/Mutex.h>
|
||||
#include <qcc/String.h>
|
||||
#include <qcc/StringUtil.h>
|
||||
|
||||
#include <alljoyn/BusAttachment.h>
|
||||
#include <alljoyn/BusListener.h>
|
||||
#include <alljoyn/BusObject.h>
|
||||
#include <alljoyn/AboutObj.h>
|
||||
#include <alljoyn/AboutIconObj.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wifi.h"
|
||||
|
||||
extern "C" {
|
||||
#include "common.h"
|
||||
}
|
||||
|
||||
#define ArraySize(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
using namespace qcc;
|
||||
using namespace ajn;
|
||||
|
||||
static struct uci_package *uci_wireless;
|
||||
|
||||
static const char* wirelessInterfaceXML =
|
||||
"<node>"
|
||||
"<interface name='org.allseen.WiFi'>"
|
||||
"<property name='Version' type='i' access='read'/>"
|
||||
"<property name='Enable' type='i' access='readwrite'/>"
|
||||
"<property name='Ssid' type='s' access='readwrite'/>"
|
||||
"<property name='Key' type='s' access='readwrite'/>"
|
||||
"<property name='EnableWps' type='i' access='readwrite'/>"
|
||||
"<property name='Channel2g' type='i' access='readwrite'/>"
|
||||
"<property name='Channel5g' type='i' access='readwrite'/>"
|
||||
"<method name='ApplyChanges'>"
|
||||
"</method>"
|
||||
"<method name='CurrentChannel'>"
|
||||
"<arg name='freq' type='i' direction='in'/>"
|
||||
"<arg name='channel' type='i' direction='out'/>"
|
||||
"</method>"
|
||||
"<method name='GetChannels'>"
|
||||
"<arg name='freq' type='i' direction='in'/>"
|
||||
"<arg name='channels' type='ai' direction='out'/>"
|
||||
"</method>"
|
||||
"</interface>"
|
||||
"<interface name='org.allseen.WPS'>"
|
||||
"<property name='Version' type='i' access='read'/>"
|
||||
"<method name='WpsPushButton'>"
|
||||
"<arg name='active' type='i' direction='in'/>"
|
||||
"</method>"
|
||||
"<signal name='WpsResponse' sessionless='true'>"
|
||||
"<arg name='respCode' type='i'/>"
|
||||
"</signal>"
|
||||
"</interface>"
|
||||
"<interface name='org.allseen.Clients'>"
|
||||
"<property name='Version' type='i' access='read'/>"
|
||||
"<method name='GetClients'>"
|
||||
"<arg name='clients' type='a(ssiii)' direction='out'/>"
|
||||
"</method>"
|
||||
"</interface>"
|
||||
"</node>";
|
||||
|
||||
static SessionPort ASSIGNED_SESSION_PORT = 900;
|
||||
|
||||
class MySessionPortListener : public SessionPortListener {
|
||||
bool AcceptSessionJoiner(ajn::SessionPort sessionPort, const char* joiner, const ajn::SessionOpts& opts)
|
||||
{
|
||||
if (sessionPort != ASSIGNED_SESSION_PORT) {
|
||||
printf("Rejecting join attempt on unexpected session port %d\n", sessionPort);
|
||||
return false;
|
||||
}
|
||||
|
||||
// cout << "Accepting JoinSessionRequest from " << joiner << " (opts.proximity= " << opts.proximity
|
||||
// << ", opts.traffic=" << opts.traffic << ", opts.transports=" << opts.transports << ")." << endl;
|
||||
return true;
|
||||
}
|
||||
void SessionJoined(SessionPort sessionPort, SessionId id, const char* joiner)
|
||||
{
|
||||
printf("Session Joined SessionId = %u\n", id);
|
||||
}
|
||||
};
|
||||
|
||||
class WirelessBusObject : public BusObject {
|
||||
public:
|
||||
WirelessBusObject(BusAttachment& bus, const char* path);
|
||||
|
||||
QStatus Get(const char* ifcName, const char* propName, MsgArg& val);
|
||||
QStatus Set(const char* ifcName, const char* propName, MsgArg& val);
|
||||
QStatus SendWpsSignal(int respcode);
|
||||
|
||||
void ApplyChanges(const InterfaceDescription::Member* member, Message& msg);
|
||||
void CurrentChannel(const InterfaceDescription::Member* member, Message& msg);
|
||||
void GetChannels(const InterfaceDescription::Member* member, Message& msg);
|
||||
void WpsPushButton(const InterfaceDescription::Member* member, Message& msg);
|
||||
void GetClients(const InterfaceDescription::Member* member, Message& msg);
|
||||
|
||||
void setChannel(int freq);
|
||||
void setSsid();
|
||||
void setKey();
|
||||
void changeWifiStatus(void);
|
||||
void changeWpsStatus(void);
|
||||
void wpsPushButton(int status);
|
||||
|
||||
String ssid, encryption, key, radio2g, radio5g;
|
||||
int enableWifi, enableWps;
|
||||
int channel2g, channel5g;
|
||||
SessionId id;
|
||||
bool stop;
|
||||
Mutex lock;
|
||||
};
|
||||
|
||||
WirelessBusObject::WirelessBusObject(BusAttachment& bus, const char* path):BusObject(path) {
|
||||
const InterfaceDescription* wireless_iface = bus.GetInterface("org.allseen.WiFi");
|
||||
if (wireless_iface == NULL) {
|
||||
printf("The interfaceDescription pointer for org.allseen.WiFi was NULL when it should not have been.\n");
|
||||
return;
|
||||
}
|
||||
AddInterface(*wireless_iface, ANNOUNCED);
|
||||
|
||||
const InterfaceDescription* wps_iface = bus.GetInterface("org.allseen.WPS");
|
||||
if (wps_iface == NULL) {
|
||||
printf("The interfaceDescription pointer for org.allseen.WPS was NULL when it should not have been.\n");
|
||||
return;
|
||||
}
|
||||
AddInterface(*wps_iface, ANNOUNCED);
|
||||
|
||||
const InterfaceDescription* client_iface = bus.GetInterface("org.allseen.Clients");
|
||||
if (client_iface == NULL) {
|
||||
printf("The interfaceDescription pointer for org.allseen.Clients was NULL when it should not have been.\n");
|
||||
return;
|
||||
}
|
||||
AddInterface(*client_iface, ANNOUNCED);
|
||||
|
||||
/* Register the method handlers with the object */
|
||||
const MethodEntry methodEntries[] = {
|
||||
{ wireless_iface->GetMember("ApplyChanges"), static_cast<MessageReceiver::MethodHandler>(&WirelessBusObject::ApplyChanges) },
|
||||
{ wireless_iface->GetMember("CurrentChannel"), static_cast<MessageReceiver::MethodHandler>(&WirelessBusObject::CurrentChannel) },
|
||||
{ wireless_iface->GetMember("GetChannels"), static_cast<MessageReceiver::MethodHandler>(&WirelessBusObject::GetChannels) },
|
||||
{ wps_iface->GetMember("WpsPushButton"), static_cast<MessageReceiver::MethodHandler>(&WirelessBusObject::WpsPushButton) },
|
||||
{ client_iface->GetMember("GetClients"), static_cast<MessageReceiver::MethodHandler>(&WirelessBusObject::GetClients) }
|
||||
};
|
||||
AddMethodHandlers(methodEntries, sizeof(methodEntries) / sizeof(methodEntries[0]));
|
||||
}
|
||||
|
||||
void WirelessBusObject::ApplyChanges(const InterfaceDescription::Member* member, Message& msg) {
|
||||
printf("ApplyChanges method called\n");
|
||||
|
||||
string vifs;
|
||||
char vifsbuf[32];
|
||||
char *token;
|
||||
|
||||
vifs = strCmd("nvram show | grep vifs | cut -d'=' -f2 | tr '\n' ' '");
|
||||
snprintf(vifsbuf, 32, "%s", vifs.c_str());
|
||||
|
||||
token = strtok(vifsbuf, " ");
|
||||
while (token != NULL)
|
||||
{
|
||||
runCmd("nvram set %s_ssid=%s", token, ssid.c_str());
|
||||
runCmd("nvram set %s_wpa_psk=%s", token, key.c_str());
|
||||
runCmd("wlctl -i %s ssid %s", token, ssid.c_str());
|
||||
token = strtok (NULL, " ");
|
||||
}
|
||||
|
||||
runCmd("killall -9 nas; nas");
|
||||
runCmd("killall -SIGTERM wps_monitor; wps_monitor &");
|
||||
|
||||
QStatus status = MethodReply(msg, NULL, 1);
|
||||
if (status != ER_OK) {
|
||||
printf("Failed to create MethodReply for ApplyChanges.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void WirelessBusObject::CurrentChannel(const InterfaceDescription::Member* member, Message& msg) {
|
||||
printf("CurrentChannel method called: %d\n", msg->GetArg(0)->v_int32);
|
||||
int freq = msg->GetArg(0)->v_int32;
|
||||
String wl;
|
||||
string channel;
|
||||
int chn;
|
||||
|
||||
(freq == 5)?(wl = radio5g):(wl = radio2g);
|
||||
//channel = strCmd("wlctl -i %s channel | grep current | awk '{print$NF}'", wl.c_str());
|
||||
channel = strCmd("wlctl -i %s status | grep Primary | awk '{print$NF}'", wl.c_str());
|
||||
chn = atoi(channel.c_str());
|
||||
|
||||
MsgArg arg[1];
|
||||
arg[0].Set("i", chn);
|
||||
QStatus status = MethodReply(msg, arg, 1);
|
||||
if (status != ER_OK) {
|
||||
printf("Failed to create MethodReply for CurrentChannel.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void WirelessBusObject::GetChannels(const InterfaceDescription::Member* member, Message& msg) {
|
||||
printf("GetChannels method called: %d\n", msg->GetArg(0)->v_int32);
|
||||
int freq = msg->GetArg(0)->v_int32;
|
||||
int *chn = new int[16];
|
||||
String wl;
|
||||
string channels;
|
||||
char *token;
|
||||
char chbuf[128];
|
||||
int i = 0;
|
||||
|
||||
(freq == 5)?(wl = radio5g):(wl = radio2g);
|
||||
channels = strCmd("wlctl -i %s channels", wl.c_str());
|
||||
snprintf(chbuf, 128, "%s", channels.c_str());
|
||||
|
||||
token = strtok(chbuf, " ");
|
||||
while (token != NULL)
|
||||
{
|
||||
chn[i] = atoi(token);
|
||||
token = strtok (NULL, " ");
|
||||
i++;
|
||||
}
|
||||
|
||||
MsgArg arg[1];
|
||||
arg[0].Set("ai", i, chn);
|
||||
QStatus status = MethodReply(msg, arg, 1);
|
||||
if (status != ER_OK) {
|
||||
printf("Failed to create MethodReply for GetChannels.\n");
|
||||
}
|
||||
|
||||
delete[] chn;
|
||||
}
|
||||
|
||||
void WirelessBusObject::GetClients(const InterfaceDescription::Member* member, Message& msg) {
|
||||
printf("GetClients method called\n");
|
||||
Client clients[128];
|
||||
MsgArg cln[128];
|
||||
int freq, snr, noise, rssi;
|
||||
int i = 0;
|
||||
|
||||
json_parse_clients(clients);
|
||||
while(strlen(clients[i].macaddr) > 16) {
|
||||
freq = 0;
|
||||
snr = 0;
|
||||
if (clients[i].conntype == 2) {
|
||||
if (strcmp(clients[i].wdev, radio5g.c_str()) == 0)
|
||||
freq = 5;
|
||||
else if (strcmp(clients[i].wdev, radio2g.c_str()) == 0)
|
||||
freq = 2;
|
||||
noise = atoi(chrCmd("wlctl -i %s noise", clients[i].wdev));
|
||||
rssi = atoi(chrCmd("wlctl -i %s rssi %s", clients[i].wdev, clients[i].macaddr));
|
||||
snr = rssi - noise;
|
||||
}
|
||||
cln[i].Set("(ssiii)", clients[i].hostname, clients[i].macaddr, clients[i].conntype, freq, snr);
|
||||
i++;
|
||||
}
|
||||
|
||||
MsgArg arg[1];
|
||||
arg[0].Set("a(ssiii)", i, cln);
|
||||
QStatus status = MethodReply(msg, arg, 1);
|
||||
if (status != ER_OK) {
|
||||
printf("Failed to create MethodReply for GetClients.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void WirelessBusObject::WpsPushButton(const InterfaceDescription::Member* member, Message& msg) {
|
||||
printf("WpsPushButton method called: %d\n", msg->GetArg(0)->v_int32);
|
||||
QStatus status = MethodReply(msg, NULL, 1);
|
||||
if (status != ER_OK) {
|
||||
printf("Failed to create MethodReply for WpsPushButton.\n");
|
||||
}
|
||||
wpsPushButton(msg->GetArg(0)->v_int32);
|
||||
}
|
||||
|
||||
QStatus WirelessBusObject::SendWpsSignal(int respcode) {
|
||||
const InterfaceDescription* bus_ifc = bus->GetInterface("org.allseen.WPS");
|
||||
const InterfaceDescription::Member* wpsResponse = (bus_ifc ? bus_ifc->GetMember("WpsResponse") : NULL);
|
||||
uint8_t flags = ALLJOYN_FLAG_SESSIONLESS;
|
||||
|
||||
assert(wpsResponse);
|
||||
|
||||
MsgArg arg("i", respcode);
|
||||
QStatus status = Signal(NULL, 0, *wpsResponse, &arg, 1, 0, flags);
|
||||
|
||||
|
||||
const char *sgnl = NULL;
|
||||
if (respcode == 2)
|
||||
sgnl = "is activated";
|
||||
else if (respcode == 1)
|
||||
sgnl = "pairing is successful";
|
||||
else if (respcode == 0)
|
||||
sgnl = "pairing is timed out";
|
||||
else if (respcode == 3)
|
||||
sgnl = "is terminated";
|
||||
else if (respcode == -1)
|
||||
sgnl = "status is changed";
|
||||
|
||||
printf("Sending WPS %s signal\n", sgnl);
|
||||
|
||||
if (status != ER_OK) {
|
||||
printf("Failed to create WPS Signal.\n");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
QStatus WirelessBusObject::Get(const char* ifcName, const char* propName, MsgArg& val)
|
||||
{
|
||||
QStatus status = ER_BUS_NO_SUCH_PROPERTY;
|
||||
if (strcmp(ifcName, "org.allseen.WiFi") == 0) {
|
||||
lock.Lock();
|
||||
if (strcmp(propName, "Enable") == 0) {
|
||||
val.Set("i", enableWifi);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Get property %s (%d) at %s\n", propName, enableWifi, GetPath());
|
||||
} else if (strcmp(propName, "Ssid") == 0) {
|
||||
val.Set("s", ssid.c_str());
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Get property %s (%s) at %s\n", propName, ssid.c_str(), GetPath());
|
||||
} else if (strcmp(propName, "Key") == 0) {
|
||||
val.Set("s", key.c_str());
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Get property %s (%s) at %s\n", propName, key.c_str(), GetPath());
|
||||
} else if (strcmp(propName, "Channel2g") == 0) {
|
||||
val.Set("i", channel2g);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Get property %s (%d) at %s\n", propName, channel2g, GetPath());
|
||||
} else if (strcmp(propName, "Channel5g") == 0) {
|
||||
val.Set("i", channel5g);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Get property %s (%d) at %s\n", propName, channel5g, GetPath());
|
||||
} else if (strcmp(propName, "EnableWps") == 0) {
|
||||
val.Set("i", enableWps);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Get property %s (%d) at %s\n", propName, enableWps, GetPath());
|
||||
}
|
||||
lock.Unlock();
|
||||
// } else if (strcmp(ifcName, "org.allseen.WPS") == 0) {
|
||||
// lock.Lock();
|
||||
// if (strcmp(propName, "Enable") == 0) {
|
||||
// val.Set("i", enableWps);
|
||||
// status = ER_OK;
|
||||
// QCC_SyncPrintf("WPS Get property %s (%d) at %s\n", propName, enableWps, GetPath());
|
||||
// }
|
||||
// lock.Unlock();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
QStatus WirelessBusObject::Set(const char* ifcName, const char* propName, MsgArg& val)
|
||||
{
|
||||
QStatus status = ER_BUS_NO_SUCH_PROPERTY;
|
||||
if (strcmp(ifcName, "org.allseen.WiFi") == 0) {
|
||||
lock.Lock();
|
||||
if (strcmp(propName, "Enable") == 0) {
|
||||
val.Get("i", &enableWifi);
|
||||
EmitPropChanged(ifcName, propName, val, id);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Set property %s (%d) at %s\n", propName, enableWifi, GetPath());
|
||||
changeWifiStatus();
|
||||
} else if (strcmp(propName, "Ssid") == 0) {
|
||||
const char* s;
|
||||
val.Get("s", &s);
|
||||
ssid = s;
|
||||
EmitPropChanged(ifcName, propName, val, id);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Set property %s (%s) at %s\n", propName, ssid.c_str(), GetPath());
|
||||
setSsid();
|
||||
} else if (strcmp(propName, "Key") == 0) {
|
||||
const char* s;
|
||||
val.Get("s", &s);
|
||||
key = s;
|
||||
EmitPropChanged(ifcName, propName, val, id);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Set property %s (%s) at %s\n", propName, key.c_str(), GetPath());
|
||||
setKey();
|
||||
} else if (strcmp(propName, "Channel2g") == 0) {
|
||||
val.Get("i", &channel2g);
|
||||
EmitPropChanged(ifcName, propName, val, id);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Set property %s (%d) at %s\n", propName, channel2g, GetPath());
|
||||
setChannel(2);
|
||||
} else if (strcmp(propName, "Channel5g") == 0) {
|
||||
val.Get("i", &channel5g);
|
||||
EmitPropChanged(ifcName, propName, val, id);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Set property %s (%d) at %s\n", propName, channel5g, GetPath());
|
||||
setChannel(5);
|
||||
} else if (strcmp(propName, "EnableWps") == 0) {
|
||||
val.Get("i", &enableWps);
|
||||
EmitPropChanged(ifcName, propName, val, id);
|
||||
status = ER_OK;
|
||||
QCC_SyncPrintf("WiFi Set property %s (%d) at %s\n", propName, enableWps, GetPath());
|
||||
changeWpsStatus();
|
||||
}
|
||||
lock.Unlock();
|
||||
// } else if (strcmp(ifcName, "org.allseen.WPS") == 0) {
|
||||
// lock.Lock();
|
||||
// if (strcmp(propName, "Enable") == 0) {
|
||||
// val.Get("i", &enableWps);
|
||||
// EmitPropChanged(ifcName, propName, val, id);
|
||||
// status = ER_OK;
|
||||
// QCC_SyncPrintf("WPS Set property %s (%d) at %s\n", propName, enableWps, GetPath());
|
||||
// changeWpsStatus();
|
||||
// }
|
||||
// lock.Unlock();
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void WirelessBusObject::setChannel(int freq) {
|
||||
String wl;
|
||||
int ch;
|
||||
char channel[4];
|
||||
string acsifs;
|
||||
bool restartAcsd = true;
|
||||
|
||||
if (freq == 5) {
|
||||
wl = radio5g;
|
||||
ch = channel5g;
|
||||
} else {
|
||||
wl = radio2g;
|
||||
ch = channel2g;
|
||||
}
|
||||
|
||||
acsifs = strCmd("nvram get acs_ifnames");
|
||||
|
||||
if (ch == 0) {
|
||||
if (acsifs == "")
|
||||
runCmd("nvram set acs_ifnames=%s", wl.c_str());
|
||||
else if (acsifs.find(wl.c_str()) == string::npos)
|
||||
runCmd("nvram set acs_ifnames=\"%s %s\"", acsifs.c_str(), wl.c_str());
|
||||
else
|
||||
restartAcsd = false;
|
||||
|
||||
strncpy(channel, "auto", 4);
|
||||
if (restartAcsd || strCmd("pidof acsd") == "") {
|
||||
runCmd("killall -9 acsd; acsd");
|
||||
} else {
|
||||
runCmd("acs_cli -i %s mode 2", wl.c_str());
|
||||
runCmd("acs_cli -i %s autochannel", wl.c_str());
|
||||
}
|
||||
} else {
|
||||
snprintf(channel, 3, "%d", ch);
|
||||
runCmd("acs_cli -i %s mode 0", wl.c_str());
|
||||
runCmd("wlctl -i %s down", wl.c_str());
|
||||
runCmd("wlctl -i %s channel %d", wl.c_str(), ch);
|
||||
runCmd("wlctl -i %s up", wl.c_str());
|
||||
}
|
||||
|
||||
uciSet("wireless", wl.c_str(), "channel", channel);
|
||||
uciCommit("wireless");
|
||||
}
|
||||
|
||||
void WirelessBusObject::setSsid() {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-iface")) {
|
||||
uset(s, "ssid", ssid.c_str());
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
}
|
||||
|
||||
void WirelessBusObject::setKey() {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-iface")) {
|
||||
uset(s, "key", key.c_str());
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
}
|
||||
|
||||
void WirelessBusObject::changeWifiStatus() {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-device")) {
|
||||
uset(s, "radio", enableWifi?"on":"off");
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
|
||||
if (enableWifi)
|
||||
runCmd("wifi up &");
|
||||
else
|
||||
runCmd("wifi down &");
|
||||
|
||||
// uci_foreach_element(&uci_wireless->sections, e) {
|
||||
// s = uci_to_section(e);
|
||||
// if (!strcmp(s->type, "wifi-iface")) {
|
||||
// uset(s, "disabled", enableWifi?"0":"1");
|
||||
// }
|
||||
// }
|
||||
// ucommit(s);
|
||||
|
||||
// if (enableWifi)
|
||||
// runCmd("ubus call led.wifi set '{\"state\":\"ok\"}'");
|
||||
// else
|
||||
// runCmd("ubus call led.wifi set '{\"state\":\"off\"}'");
|
||||
|
||||
// string vifs;
|
||||
// char vifsbuf[32];
|
||||
// char *token;
|
||||
|
||||
// vifs = strCmd("nvram show | grep vifs | cut -d'=' -f2 | tr '\n' ' '");
|
||||
// snprintf(vifsbuf, 32, "%s", vifs.c_str());
|
||||
|
||||
// token = strtok(vifsbuf, " ");
|
||||
// while (token != NULL)
|
||||
// {
|
||||
// runCmd("wifi %s %s", enableWifi?"enable":"disable", token);
|
||||
// token = strtok (NULL, " ");
|
||||
// }
|
||||
}
|
||||
|
||||
void WirelessBusObject::changeWpsStatus() {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
/* send wps status changed signal */
|
||||
SendWpsSignal(-1);
|
||||
|
||||
char wps[2];
|
||||
snprintf(wps, 2, "%d", enableWps);
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-iface")) {
|
||||
uset(s, "wps_pbc", wps);
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
|
||||
string vifs;
|
||||
char vifsbuf[32];
|
||||
char *token;
|
||||
|
||||
vifs = strCmd("nvram show | grep vifs | cut -d'=' -f2 | tr '\n' ' '");
|
||||
snprintf(vifsbuf, 32, "%s", vifs.c_str());
|
||||
|
||||
token = strtok(vifsbuf, " ");
|
||||
while (token != NULL)
|
||||
{
|
||||
runCmd("nvram set %s_wps_mode=%s", token, (enableWps)?"enabled":"disabled");
|
||||
token = strtok (NULL, " ");
|
||||
}
|
||||
|
||||
if (enableWps) {
|
||||
printf("Enabling WPS\n");
|
||||
runCmd("nvram set wps_proc_status=0");
|
||||
if (strCmd("pidof wps_monitor") == "") {
|
||||
printf("Activating WPS\n");
|
||||
runCmd("wps_monitor &");
|
||||
}
|
||||
} else {
|
||||
printf("Disabling WPS\n");
|
||||
runCmd("killall -SIGTERM wps_monitor 2>/dev/null");
|
||||
}
|
||||
}
|
||||
|
||||
void WirelessBusObject::wpsPushButton(int status) {
|
||||
if (status) {
|
||||
if (strCmd("pidof wps_monitor") == "") {
|
||||
printf("Activating WPS\n");
|
||||
runCmd("wps_monitor &");
|
||||
usleep(100000);
|
||||
}
|
||||
printf("Starting WPS Pairing\n");
|
||||
runCmd("killall -SIGUSR2 wps_monitor");
|
||||
} else {
|
||||
printf("Terminating WPS Pairing\n");
|
||||
runCmd("nvram set wps_proc_status=0");
|
||||
runCmd("killall -SIGTERM wps_monitor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WirelessBusObject *MyBus;
|
||||
|
||||
void wps_event(const char *key, const char *val)
|
||||
{
|
||||
int respcode = 2;
|
||||
if(!strcmp(val, "timeout"))
|
||||
respcode = 0;
|
||||
else if (!strcmp(val, "terminated"))
|
||||
respcode = 3;
|
||||
else if (!strcmp(key, "sta"))
|
||||
respcode = 1;
|
||||
|
||||
if (respcode != 3)
|
||||
MyBus->SendWpsSignal(respcode);
|
||||
}
|
||||
|
||||
static void
|
||||
populateWireless()
|
||||
{
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
String channel, chanspec;
|
||||
const char *radio = NULL;
|
||||
|
||||
if(!(uci_wireless = init_package("wireless")))
|
||||
return;
|
||||
|
||||
MyBus->enableWifi = 1;
|
||||
MyBus->enableWps = 0;
|
||||
MyBus->channel2g = 0;
|
||||
MyBus->channel5g = -1;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-device")) {
|
||||
if(!strcmp(ugets(s, "band"), "a")) {
|
||||
MyBus->radio5g = s->e.name;
|
||||
chanspec = ugets(s, "channel");
|
||||
channel = chanspec.substr(0, chanspec.find('/'));
|
||||
if (!strcmp(channel.c_str(), "auto"))
|
||||
MyBus->channel5g = 0;
|
||||
else
|
||||
MyBus->channel5g = ugeti(s, "channel");
|
||||
} else {
|
||||
MyBus->radio2g = s->e.name;
|
||||
radio = ugets(s, "radio");
|
||||
if (radio && strcmp(radio, "off") == 0)
|
||||
MyBus->enableWifi = 0;
|
||||
chanspec = ugets(s, "channel");
|
||||
channel = chanspec.substr(0, chanspec.find('/'));
|
||||
if (channel == "auto")
|
||||
MyBus->channel2g = 0;
|
||||
else
|
||||
MyBus->channel2g = ugeti(s, "channel");
|
||||
}
|
||||
} else if (!strcmp(s->type, "wifi-iface")) {
|
||||
MyBus->ssid = ugets(s, "ssid");
|
||||
MyBus->encryption = ugets(s, "encryption");
|
||||
MyBus->key = ugets(s, "key");
|
||||
if (ugeti(s, "wps_pbc") == 1)
|
||||
MyBus->enableWps = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QStatus status;
|
||||
String advName = "org.alljoyn.alljoyn_wireless";
|
||||
|
||||
/* wait for for alljoyn to start */
|
||||
int tm = 10;
|
||||
while (tm && strCmd("pidof alljoyn-daemon") == "") {
|
||||
sleep(tm);
|
||||
tm--;
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
BusAttachment bus("Wireless", true);
|
||||
|
||||
status = bus.Start();
|
||||
if (ER_OK == status) {
|
||||
printf("BusAttachment started.\n");
|
||||
} else {
|
||||
printf("FAILED to start BusAttachment (%s)\n", QCC_StatusText(status));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
status = bus.Connect();
|
||||
if (ER_OK == status) {
|
||||
printf("BusAttachment connect succeeded. BusAttachment Unique name is %s\n", bus.GetUniqueName().c_str());
|
||||
} else {
|
||||
printf("FAILED to connect to router node (%s)\n", QCC_StatusText(status));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
status = bus.CreateInterfacesFromXml(wirelessInterfaceXML);
|
||||
|
||||
/* Request well-known name */
|
||||
status = bus.RequestName(advName.c_str(), DBUS_NAME_FLAG_DO_NOT_QUEUE);
|
||||
if (ER_OK == status) {
|
||||
printf("RequestName('%s') succeeded.\n", advName.c_str());
|
||||
} else {
|
||||
printf("RequestName('%s') failed (status=%s).\n", advName.c_str(), QCC_StatusText(status));
|
||||
}
|
||||
/*-------------------------------*/
|
||||
|
||||
WirelessBusObject wirelessBusObject(bus, "/org/alljoyn/wireless");
|
||||
|
||||
MyBus = &wirelessBusObject;
|
||||
|
||||
populateWireless();
|
||||
|
||||
bus.RegisterBusObject(wirelessBusObject);
|
||||
|
||||
SessionOpts opts(SessionOpts::TRAFFIC_MESSAGES, false, SessionOpts::PROXIMITY_ANY, TRANSPORT_ANY);
|
||||
SessionPort sp = ASSIGNED_SESSION_PORT;
|
||||
MySessionPortListener sessionPortListener;
|
||||
status = bus.BindSessionPort(sp, opts, sessionPortListener);
|
||||
if (ER_OK == status) {
|
||||
printf("BindSessionPort succeeded.\n");
|
||||
} else {
|
||||
printf("BindSessionPort failed (%s)\n", QCC_StatusText(status));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Advertise well-known name */
|
||||
status = bus.AdvertiseName(advName.c_str(), TRANSPORT_ANY);
|
||||
if (ER_OK == status) {
|
||||
printf("Advertisement of the service name '%s' succeeded.\n", advName.c_str());
|
||||
} else {
|
||||
printf("Failed to advertise name '%s' (%s).\n", advName.c_str(), QCC_StatusText(status));
|
||||
}
|
||||
/*-------------------------------*/
|
||||
|
||||
// // Setup the about data
|
||||
// AboutData aboutData("en");
|
||||
|
||||
// uint8_t appId[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
// status = aboutData.SetAppId(appId, 16);
|
||||
// status = aboutData.SetDeviceName(strCmd("db get hw.board.hardware").c_str());
|
||||
// status = aboutData.SetDeviceId(strCmd("db get hw.board.BaseMacAddr").c_str());
|
||||
// status = aboutData.SetAppName("WiFi Manager");
|
||||
// status = aboutData.SetManufacturer("Inteno");
|
||||
// status = aboutData.SetModelNumber(strCmd("db get hw.board.routerModel | cut -d'-' -f 2").c_str());
|
||||
// status = aboutData.SetDescription("Manage WiFi");
|
||||
// status = aboutData.SetDateOfManufacture(strCmd("db get hw.board.iopVersion | awk -F'[-,_]' '{print$4}'").c_str());
|
||||
// status = aboutData.SetSoftwareVersion(strCmd("db get hw.board.iopVersion | awk -F'[-,_]' '{print$3}'").c_str());
|
||||
// status = aboutData.SetHardwareVersion(strCmd("db get hw.board.hardwareVersion").c_str());
|
||||
// status = aboutData.SetSupportUrl("http://www.iopsys.eu");
|
||||
// if (!aboutData.IsValid()) {
|
||||
// printf("failed to setup about data.\n");
|
||||
// }
|
||||
|
||||
// AboutIcon icon;
|
||||
// status = icon.SetUrl("wp-content/uploads/2014/09/iopsys_logo_CMYK_invert_circle.png", "http://www.iopsys.eu");
|
||||
// if (ER_OK != status) {
|
||||
// printf("Failed to setup the AboutIcon.\n");
|
||||
// }
|
||||
// AboutIconObj aboutIconObj(bus, icon);
|
||||
|
||||
// // Announce about signal
|
||||
// AboutObj aboutObj(bus, BusObject::ANNOUNCED);
|
||||
// status = aboutObj.Announce(ASSIGNED_SESSION_PORT, aboutData);
|
||||
// if (ER_OK == status) {
|
||||
// printf("AboutObj Announce Succeeded.\n");
|
||||
// } else {
|
||||
// printf("AboutObj Announce failed (%s)\n", QCC_StatusText(status));
|
||||
// }
|
||||
|
||||
ubus_listener();
|
||||
|
||||
return 0;
|
||||
}
|
||||
261
wifimngr/src/wireless.cc
Normal file
261
wifimngr/src/wireless.cc
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* wifimngr -- wifi manager
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: sukru.senli@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "wifi.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
}
|
||||
|
||||
static struct uci_package *uci_wireless;
|
||||
|
||||
//WirelessRadio WDev[MAX_WDEV];
|
||||
//WirelessInterface WIfc[MAX_WIFC];
|
||||
|
||||
//void
|
||||
//populateWirelessInterfaces()
|
||||
//{
|
||||
// struct uci_element *e;
|
||||
// struct uci_section *s;
|
||||
// const char *device;
|
||||
// int idx = 0;
|
||||
// int vif;
|
||||
// int vif0 = 0;
|
||||
// int vif1 = 0;
|
||||
// char wif[8];
|
||||
|
||||
// uci_foreach_element(&uci_wireless->sections, e) {
|
||||
// s = uci_to_section(e);
|
||||
// if (!strcmp(s->type, "wifi-iface")) {
|
||||
// device = ugets(s, "device");
|
||||
// WIfc[idx].radio = device;
|
||||
// if (!strcmp(device, "wl0")) {
|
||||
// vif = vif0;
|
||||
// vif0++;
|
||||
// } else {
|
||||
// vif = vif1;
|
||||
// vif1++;
|
||||
// }
|
||||
// if (vif > 0)
|
||||
// sprintf(wif, "%s.%d", device, vif);
|
||||
// else
|
||||
// strcpy(wif, device);
|
||||
// WIfc[idx].ifname = std::string(wif);
|
||||
// WIfc[idx].ssid = ugets(s, "ssid");
|
||||
// WIfc[idx].encryption = ugets(s, "encryption");
|
||||
// WIfc[idx].key = ugets(s, "key");
|
||||
// idx++;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//void
|
||||
//populateWirelessRadios()
|
||||
//{
|
||||
// struct uci_element *e;
|
||||
// struct uci_section *s;
|
||||
// int idx = 0;
|
||||
|
||||
// if(!(uci_wireless = init_package("wireless")))
|
||||
// return;
|
||||
|
||||
// uci_foreach_element(&uci_wireless->sections, e) {
|
||||
// s = uci_to_section(e);
|
||||
// if (!strcmp(s->type, "wifi-device")) {
|
||||
// WDev[idx].name = s->e.name;
|
||||
// WDev[idx].bwCap = ugeti(s, "bandwidth");
|
||||
// WDev[idx].hwmode = ugets(s, "hwmode");
|
||||
// WDev[idx].channel = ugeti(s, "channel");
|
||||
// WDev[idx].autoChanTimer = ugeti(s, "scantimer");
|
||||
// idx++;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Wireless WL;
|
||||
WPS Wps;
|
||||
|
||||
string Wireless::getChannels(int freq) {
|
||||
string wl;
|
||||
if (freq == 5)
|
||||
wl = WL.radio5g;
|
||||
else
|
||||
wl = WL.radio2g;
|
||||
|
||||
return strCmd("wlctl -i %s channels", wl.c_str());
|
||||
}
|
||||
|
||||
void Wireless::setChannel(int freq, int ch) {
|
||||
string wl;
|
||||
|
||||
char channel[3];
|
||||
snprintf(channel, 3, "%d", ch);
|
||||
|
||||
if (freq == 5) {
|
||||
wl = WL.radio5g;
|
||||
WL.channel5g = ch;
|
||||
} else {
|
||||
wl = WL.radio2g;
|
||||
WL.channel2g = ch;
|
||||
}
|
||||
|
||||
uciSet("wireless", wl.c_str(), "channel", channel);
|
||||
uciCommit("wireless");
|
||||
runCmd("wlctl -i %s down", wl.c_str());
|
||||
runCmd("wlctl -i %s channel %d", wl.c_str(), ch);
|
||||
runCmd("wlctl -i %s up", wl.c_str());
|
||||
}
|
||||
|
||||
void Wireless::setSsid(string ssid) {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
if (WL.ssid == ssid)
|
||||
return;
|
||||
|
||||
WL.ssid = ssid;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-iface")) {
|
||||
uset(s, "ssid", ssid.c_str());
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
|
||||
runCmd("sed -i \"s/_ssid=.*/_ssid=%s/g\" /etc/config/broadcom", ssid.c_str());
|
||||
runCmd("killall -9 nas; nas");
|
||||
runCmd("killall -SIGTERM wps_monitor; wps_monitor &");
|
||||
}
|
||||
|
||||
void Wireless::setKey(string key) {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
if (WL.key == key)
|
||||
return;
|
||||
|
||||
WL.key = key;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-iface")) {
|
||||
uset(s, "key", key.c_str());
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
|
||||
runCmd("sed -i \"s/_wpa_psk=.*/_wpa_psk=%s/g\" /etc/config/broadcom", key.c_str());
|
||||
runCmd("killall -9 nas; nas");
|
||||
runCmd("killall -SIGTERM wps_monitor; wps_monitor &");
|
||||
}
|
||||
|
||||
void WPS::activate(int status) {
|
||||
if (status) {
|
||||
if (strCmd("pidof wps_monitor") == "") {
|
||||
runCmd("wps_monitor &");
|
||||
usleep(100000);
|
||||
}
|
||||
runCmd("killall -SIGUSR2 wps_monitor");
|
||||
} else
|
||||
runCmd("killall -SIGTERM wps_monitor");
|
||||
}
|
||||
|
||||
void WPS::changeStatus() {
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
|
||||
char wps[2];
|
||||
snprintf(wps, 2, "%d", Wps.enable);
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-iface")) {
|
||||
uset(s, "wps_pbc", wps);
|
||||
}
|
||||
}
|
||||
ucommit(s);
|
||||
|
||||
if (Wps.enable) {
|
||||
runCmd("sed -i \"s/wps_mode 'disabled'/wps_mode 'enabled'/g\" /etc/config/broadcom");
|
||||
if (strCmd("pidof wps_monitor") == "")
|
||||
runCmd("wps_monitor &");
|
||||
} else {
|
||||
runCmd("sed -i \"s/wps_mode 'enabled'/wps_mode 'disabled'/g\" /etc/config/broadcom");
|
||||
runCmd("killall -SIGTERM wps_monitor 2>/dev/null");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
populateWireless()
|
||||
{
|
||||
struct uci_element *e;
|
||||
struct uci_section *s;
|
||||
string channel, chanspec;
|
||||
|
||||
if(!(uci_wireless = init_package("wireless")))
|
||||
return;
|
||||
|
||||
Wps.enable = 0;
|
||||
WL.channel2g = 0;
|
||||
WL.channel5g = -1;
|
||||
|
||||
uci_foreach_element(&uci_wireless->sections, e) {
|
||||
s = uci_to_section(e);
|
||||
if (!strcmp(s->type, "wifi-device")) {
|
||||
if(!strcmp(ugets(s, "band"), "a")) {
|
||||
WL.radio5g = s->e.name;
|
||||
chanspec = ugets(s, "channel");
|
||||
channel = chanspec.substr(0, chanspec.find('/'));
|
||||
if (!strcmp(channel.c_str(), "auto"))
|
||||
WL.channel5g = 0;
|
||||
else
|
||||
WL.channel5g = ugeti(s, "channel");
|
||||
} else {
|
||||
WL.radio2g = s->e.name;
|
||||
chanspec = ugets(s, "channel");
|
||||
channel = chanspec.substr(0, chanspec.find('/'));
|
||||
if (channel == "auto")
|
||||
WL.channel2g = 0;
|
||||
else
|
||||
WL.channel2g = ugeti(s, "channel");
|
||||
}
|
||||
} else if (!strcmp(s->type, "wifi-iface")) {
|
||||
WL.ssid = ugets(s, "ssid");
|
||||
WL.encryption = ugets(s, "encryption");
|
||||
WL.key = ugets(s, "key");
|
||||
if (ugeti(s, "wps_pbc") == 1)
|
||||
Wps.enable = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue