xbee: add support for multiple XBee interfaces

XBEE_RESET_N_GPIO and XBEE_SLEEP_RQ_GPIO can now be comma-separated lists of
GPIO indexes instead of just a single index. Modify the xbee-init script to
support this change and modify the sed script in xbee.bb to allow commas
in the aforementioned variables.

https://jira.digi.com/browse/DEL-6887

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2020-01-21 15:54:33 +01:00
parent e9108338f3
commit eb4ef72610
2 changed files with 29 additions and 11 deletions

View File

@ -18,8 +18,8 @@ do_install() {
install -d ${D}${sysconfdir}/init.d/ install -d ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/xbee-init ${D}${sysconfdir}/ install -m 0755 ${WORKDIR}/xbee-init ${D}${sysconfdir}/
ln -sf /etc/xbee-init ${D}${sysconfdir}/init.d/xbee-init ln -sf /etc/xbee-init ${D}${sysconfdir}/init.d/xbee-init
sed -i -e "s,##XBEE_RESET_N_GPIO##,${XBEE_RESET_N_GPIO},g" \ sed -i -e "s/##XBEE_RESET_N_GPIO##/${XBEE_RESET_N_GPIO}/g" \
-e "s,##XBEE_SLEEP_RQ_GPIO##,${XBEE_SLEEP_RQ_GPIO},g" \ -e "s/##XBEE_SLEEP_RQ_GPIO##/${XBEE_SLEEP_RQ_GPIO}/g" \
${D}${sysconfdir}/xbee-init ${D}${sysconfdir}/xbee-init
install -d ${D}${systemd_unitdir}/system/ install -d ${D}${systemd_unitdir}/system/

View File

@ -33,29 +33,47 @@ set_gpio_value() {
xbee_init() { xbee_init() {
# Power cycle XBEE_RESET_N # Power cycle XBEE_RESET_N
request_gpio_out ${XBEE_RESET_N_GPIO} request_gpio_out ${1}
set_gpio_value ${XBEE_RESET_N_GPIO} 0 set_gpio_value ${1} 0
set_gpio_value ${XBEE_RESET_N_GPIO} 1 set_gpio_value ${1} 1
# Set low XBEE_SLEEP_RQ # Set low XBEE_SLEEP_RQ
request_gpio_out ${XBEE_SLEEP_RQ_GPIO} request_gpio_out ${2}
set_gpio_value ${XBEE_SLEEP_RQ_GPIO} 0 set_gpio_value ${2} 0
} }
xbee_stop() { xbee_stop() {
free_gpio ${XBEE_RESET_N_GPIO} free_gpio ${1}
free_gpio ${XBEE_SLEEP_RQ_GPIO} free_gpio ${2}
}
xbee_iterate_list() {
i=0
for RESET in $(echo ${XBEE_RESET_N_GPIO} | sed "s/,/ /g"); do
j=0
for SLEEP in $(echo ${XBEE_SLEEP_RQ_GPIO} | sed "s/,/ /g"); do
if [ "${i}" = "${j}" ]; then
if [ "${1}" = "start" ]; then
xbee_init ${RESET} ${SLEEP}
elif [ "${1}" = "stop" ]; then
xbee_stop ${RESET} ${SLEEP}
fi
fi
j="$((j + 1))"
done
i="$((i + 1))"
done
} }
case "$1" in case "$1" in
start) start)
echo -n "Starting XBee hardware: " echo -n "Starting XBee hardware: "
xbee_init xbee_iterate_list start
echo "done." echo "done."
;; ;;
stop) stop)
echo -n "Stopping XBee hardware: " echo -n "Stopping XBee hardware: "
xbee_stop xbee_iterate_list stop
echo "done." echo "done."
;; ;;
restart) restart)