Change dir of openwrt and refactor sh script
This commit is contained in:
73
openwrt/Makefile
Normal file
73
openwrt/Makefile
Normal file
@@ -0,0 +1,73 @@
|
||||
#
|
||||
# Copyright (C) 2018-2021 skjaro
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=usbserial-dw
|
||||
PKG_VERSION:=0.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://git.bh.ttx.sk/jaro/usbserial-dw.git
|
||||
PKG_MIRROR_HASH:=
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=6179fdee75ee3fcdb766aef5eb791c38e75ee33b
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
CMAKE_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
|
||||
PKG_MAINTAINER:=SkJaro
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
TARGET_CXXFLAGS += -Wall -Wextra
|
||||
TARGET_CXXFLAGS += $(FPIC)
|
||||
|
||||
# LTO
|
||||
TARGET_CXXFLAGS += -flto
|
||||
TARGET_LDFLAGS += -flto
|
||||
|
||||
# CXX standard
|
||||
TARGET_CXXFLAGS += -std=c++11
|
||||
|
||||
TARGET_CXXFLAGS := $(filter-out -O%,$(TARGET_CXXFLAGS)) -O3
|
||||
|
||||
TARGET_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DENABLE_MYSQL=OFF \
|
||||
-DBoost_DEBUG=ON \
|
||||
-DBoost_NO_BOOST_CMAKE=ON
|
||||
|
||||
define Package/usbserial-dw
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Little program for downloading camera and temprature from usbserial
|
||||
URL:=https://git.bh.ttx.sk/jaro/usbserial-dw.git
|
||||
DEPENDS:=+libpthread +libstdcpp \
|
||||
+boost +boost-system +boost-program_options +boost-date_time +boost-log
|
||||
endef
|
||||
|
||||
|
||||
|
||||
define Package/usbserial-dw/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/usbserial-dw $(1)/usr/bin/usbserial-dw
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/usbserial-dw.config $(1)/etc/config/usbserial
|
||||
endef
|
||||
|
||||
define Package/usbserial-dw/conffiles
|
||||
/etc/config/usbserial-dw
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,usbserial-dw))
|
||||
7
openwrt/files/usbserial-dw.config
Normal file
7
openwrt/files/usbserial-dw.config
Normal file
@@ -0,0 +1,7 @@
|
||||
config capture
|
||||
option port /dev/ttyUSB0
|
||||
option speed 115200
|
||||
option directory /tmp
|
||||
option file camera.jpg
|
||||
option url https://meranie.bh.ttx.sk/upload/image
|
||||
option time 300
|
||||
29
openwrt/files/usbserial-dw.sh
Normal file
29
openwrt/files/usbserial-dw.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2018 wongsyrone
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
PROG=/usr/bin/usbserial-dw
|
||||
CURL=/usr/bin/curl
|
||||
|
||||
parse_capture() {
|
||||
local section="$1"
|
||||
local _port
|
||||
local _speed
|
||||
local _dir
|
||||
local _file
|
||||
|
||||
config_get _port "$section" "port"
|
||||
config_get _speed "$section" "speed"
|
||||
config_get _dir "$section" "dir"
|
||||
config_get _file "$section" "file"
|
||||
config_get _url "$section" "url"
|
||||
|
||||
$PROG --port $_port --speed $_speed --dir $_dir --file $_file
|
||||
cd $_dir
|
||||
$CURL -v -X POST -F "submit=OK" -F "file=@camera.jpg" $_url
|
||||
rm $_file
|
||||
}
|
||||
|
||||
config_load usbserial
|
||||
config_foreach parse_capture capture
|
||||
Reference in New Issue
Block a user