#!/bin/sh /etc/rc.common # Copyright 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=< /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 }