Index: scripts/autostart =================================================================== diff -u --- scripts/autostart (revision 0) +++ scripts/autostart (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,30 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file autostart +# +# @author (last) Behrouz NematiPour +# @date (last) 15-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 28-Oct-2019 +# +############################################################################ +case "$1" in + start) + logger "Starting autostart scripts" + HOME="/home/root" + cd "$HOME" + ./run.sh "$HOME" + logger $? + exit 0 + ;; + *) + echo "It's just a startup script and has no arguments or commands" + exit 1 + ;; +esac Index: scripts/bluetooth_main.conf =================================================================== diff -u --- scripts/bluetooth_main.conf (revision 0) +++ scripts/bluetooth_main.conf (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,130 @@ +[General] + +# Default adapter name +# Defaults to 'BlueZ X.YZ' +Name = 'DEVICE_NAME' + +# Default device class. Only the major and minor device class bits are +# considered. Defaults to '0x000000'. +#Class = 0x000100 + +# How long to stay in discoverable mode before going back to non-discoverable +# The value is in seconds. Default is 180, i.e. 3 minutes. +# 0 = disable timer, i.e. stay discoverable forever +#DiscoverableTimeout = 0 + +# Always allow pairing even if there are no agent registered +# Possible values: true, false +# Default: false +AlwaysPairable = true + +# How long to stay in pairable mode before going back to non-discoverable +# The value is in seconds. Default is 0. +# 0 = disable timer, i.e. stay pairable forever +#PairableTimeout = 0 + +# Use vendor id source (assigner), vendor, product and version information for +# DID profile support. The values are separated by ":" and assigner, VID, PID +# and version. +# Possible vendor id source values: bluetooth, usb (defaults to usb) +#DeviceID = bluetooth:1234:5678:abcd + +# Do reverse service discovery for previously unknown devices that connect to +# us. For BR/EDR this option is really only needed for qualification since the +# BITE tester doesn't like us doing reverse SDP for some test cases, for LE +# this disables the GATT client functionally so it can be used in system which +# can only operate as peripheral. +# Defaults to 'true'. +#ReverseServiceDiscovery = true + +# Enable name resolving after inquiry. Set it to 'false' if you don't need +# remote devices name and want shorter discovery cycle. Defaults to 'true'. +#NameResolving = true + +# Enable runtime persistency of debug link keys. Default is false which +# makes debug link keys valid only for the duration of the connection +# that they were created for. +DebugKeys = true + +# Restricts all controllers to the specified transport. Default value +# is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW). +# Possible values: "dual", "bredr", "le" +#ControllerMode = dual + +# Enables Multi Profile Specification support. This allows to specify if +# system supports only Multiple Profiles Single Device (MPSD) configuration +# or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple +# Devices (MPMD) configurations. +# Possible values: "off", "single", "multiple" +# CHANGE_THIS_VALUE_TO: multiple +MultiProfile = "multiple" + +# Permanently enables the Fast Connectable setting for adapters that +# support it. When enabled other devices can connect faster to us, +# however the tradeoff is increased power consumptions. This feature +# will fully work only on kernel version 4.1 and newer. Defaults to +# 'false'. +#FastConnectable = false + +# Default privacy setting. +# Enables use of private address. +# Possible values: "off", "device", "network" +# "network" option not supported currently +# Defaults to "off" +# Privacy = off + +# Specify the policy to the JUST-WORKS repairing initiated by peer +# Possible values: "never", "confirm", "always" +# Defaults to "never" +JustWorksRepairing = always + +[GATT] +# GATT attribute cache. +# Possible values: +# always: Always cache attributes even for devices not paired, this is +# recommended as it is best for interoperability, with more consistent +# reconnection times and enables proper tracking of notifications for all +# devices. +# yes: Only cache attributes of paired devices. +# no: Never cache attributes +# Default: always +#Cache = always + +# Minimum required Encryption Key Size for accessing secured characteristics. +# Possible values: 0 and 7-16. 0 means don't care. +# Defaults to 0 +#KeySize = 0 + +# Exchange MTU size. +# Possible values: 23-517 +# Defaults to 517 +#ExchangeMTU = 517 + +# Number of ATT channels +# Possible values: 1-5 (1 disables EATT) +# Default to 3 +#Channels = 3 + +[Policy] +# +# The ReconnectUUIDs defines the set of remote services that should try +# to be reconnected to in case of a link loss (link supervision +# timeout). The policy plugin should contain a sane set of values by +# default, but this list can be overridden here. By setting the list to +# empty the reconnection feature gets disabled. +#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb + +# ReconnectAttempts define the number of attempts to reconnect after a link +# lost. Setting the value to 0 disables reconnecting feature. +#ReconnectAttempts=7 + +# ReconnectIntervals define the set of intervals in seconds to use in between +# attempts. +# If the number of attempts defined in ReconnectAttempts is bigger than the +# set of intervals the last interval is repeated until the last attempt. +#ReconnectIntervals=1,2,4,8,16,32,64 + +# AutoEnable defines option to enable all controllers when they are found. +# This includes adapters present on start as well as adapters that are plugged +# in later on. Defaults to 'false'. +AutoEnable=true Index: scripts/bluetooth_paired_clear.sh =================================================================== diff -u --- scripts/bluetooth_paired_clear.sh (revision 0) +++ scripts/bluetooth_paired_clear.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,39 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_paired_clear.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-Nov-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-Nov-2021 +# +############################################################################ + +# @details +# This file is called by UI Software to removed all the currnelty paired or cached devices. +# This is done before each scan to clean up and start a fresh scan. + +DEVICES=$(echo "devices" | bluetoothctl | grep ^Device | cut -b 8-25) +if [ ! -z "$DEVICES" ]; then + for device in $DEVICES; do + if [ ! -z "$device" ]; then + echo "remove $device" | bluetoothctl + fi + done +fi + +PAIRED_DEVICES=$(echo "paired-devices" | bluetoothctl | grep ^Device | cut -b 8-25) +if [ ! -z "$PAIRED_DEVICES" ]; then + for paired_device in $PAIRED_DEVICES; do + if [ ! -z "$paired_device" ]; then + echo "remove $paired_device" | bluetoothctl + fi + done +fi + Index: scripts/bluetooth_paired_query.sh =================================================================== diff -u --- scripts/bluetooth_paired_query.sh (revision 0) +++ scripts/bluetooth_paired_query.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,30 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file bluetooth_paired_query.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 12-Dec-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-Nov-2021 +# +############################################################################ + +# @details +# This file is called by UI Software to query the Blood Pressure paired Bluetooth device. +# There should be only one device paired at a time regarding our design. +# The returned value is the devive mac address and the name assigned to it in the system. + +#test code +#PAIRED_DEVICE_INFO="28:FF:B2:78:5B:BF BP7000" +#PAIRED_DEVICE_INFO="" + +PAIRED_DEVICE_INFO=$(echo "paired-devices" | bluetoothctl | grep ^Device | cut -b 8-125) + +echo $PAIRED_DEVICE_INFO + Index: scripts/brightness_get.sh =================================================================== diff -u --- scripts/brightness_get.sh (revision 0) +++ scripts/brightness_get.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,18 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file brightness_get.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 07-Jun-2021 +# @author (original) Behrouz NematiPour +# @date (original) 07-Jun-2021 +# +############################################################################ + +echo "$(cat /sys/class/backlight/backlight-mipi/brightness)" Index: scripts/brightness_set.sh =================================================================== diff -u --- scripts/brightness_set.sh (revision 0) +++ scripts/brightness_set.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,26 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file brightness_set.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 16-Dec-2021 +# @author (original) Behrouz NematiPour +# @date (original) 23-May-2021 +# +############################################################################ + +if [ "$#" -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile ''" + exit 0 +fi + +echo "$1" > /sys/class/backlight/backlight-mipi/brightness # realtime +echo "$1" > /var/lib/systemd/backlight/platform-backlight-mipi\:backlight\:backlight-mipi # preserve for reboot + Index: scripts/date_time_set.sh =================================================================== diff -u --- scripts/date_time_set.sh (revision 0) +++ scripts/date_time_set.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,28 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file date_time_set.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 20-Apr-2021 +# @author (original) Behrouz NematiPour +# @date (original) 20-Apr-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile 'yyyy-mm-dd HH:MM:SS'" + exit 0 +fi + +date -s "$1" + +# set the hwclock from the system time +hwclock -w + Index: scripts/export_logs.sh =================================================================== diff -u --- scripts/export_logs.sh (revision 0) +++ scripts/export_logs.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,54 @@ +#!/bin/bash +########################################################################### +# +# Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file export_logs.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 14-Jan-2022 +# @author (original) Behrouz NematiPour +# @date (original) 14-Jan-2022 +# +############################################################################ + +CURRNET_DATE=$(date +%Y_%m_%d) +PATH_SRC="$1" +PATH_DST="$2" +PASS_HAS="$3" + +function echo_usage() { + if [[ -z "$PATH_SRC" || -z "$PATH_DST" ]]; then + echo "Usage:" + echo "./export_logs.sh " + echo "" + fi +} + +function export_logs() { + OPTP="" + PASS="Empty Password" + if [[ -n "$PASS_HAS" ]]; then + PASS=$(pwgen -ABcsnv1 16) + OPTP=--password="$PASS" + fi + + EXPORT_FILE=$CURRNET_DATE"_logs" + + echo "$PATH_DST"/"$EXPORT_FILE".zip # echo the out zip + rm -frd "$PATH_DST"/"$EXPORT_FILE".zip && # remove the old zip from dest + rm -frd $HOME/"$EXPORT_FILE".zip && # remove the old zip from home + zip -jr9 $HOME/"$EXPORT_FILE".zip "$PATH_SRC" "$OPTP" && # compress the new zip to home neesd to change to 7zzs + cp $HOME/"$EXPORT_FILE".zip "$PATH_DST" && # copy the new zip to dest + echo $PASS > "$PATH_DST"/"$EXPORT_FILE".pas && # copy the new pas to dest + rm -frd $HOME/"$EXPORT_FILE".zip # remove the tmp zip from home +} + +if [[ "$1" == "" ]]; then + echo_usage +fi + +export_logs Index: scripts/globals.sh =================================================================== diff -u --- scripts/globals.sh (revision 0) +++ scripts/globals.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,200 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file globals.sh +# +# @author (last) Vy +# @date (last) 20-May-2023 +# @author (original) Behrouz NematiPour +# @date (original) 15-Dec-2022 +# +############################################################################ + +# @details +# This script includes the global variables and functions to be used in the setup and start scripts. + +TRUE=1 +FALSE=0 + +COMMENT_STAR="********************************************************************************" +COMMENT_DASH="--------------------------------------------------------------------------------" + +DATETIME="$1 $2" + +#DO NOT MODIFY VARIABLES, unless the denali applicaiton is updated as well to match. +SDCARD_DEV=/dev/mmcblk1 +SDCARD_PRT=/dev/mmcblk1p1 +SDCARD_MNT=/media/sd-card +SDCARD_TYP_NAME=ext4 +SDCARD_TYP_NUMB=83 + +USB_DEV=/dev/sda1 +USB_MNT=/media/usb + +CLOUDSYNC_FOLDER=cloudsync # both for log and application + +LOG_LOCATION=$HOME/Desktop +LOG_OUT_FILE="" +LOG_ERR_FILE="" + +ERR_MISSING_FOLDER=101 +ERR_MISSING_FILE=102 +ERR_CONNECTION=103 +ERR_DENALI_BIN=104 +ERR_FONTS_EMTY=105 +ERR_FONTS_PATH=106 +ERR_KILLPROMPT=107 +ERR_MISSING_KEY=109 +ERR_SCP_FAIL=110 +ERR_INVALID_IP=111 +ERR_SD_CARD=112 + +SRC_FILE_SSHKEY="$HOME/.ssh/id_rsa" +SRC_FILE_SSHKEY_PUB=$SRC_FILE_SSHKEY.pub +SRC_PATH_SCRIPTS="scripts" +SRC_PATH_CONFIG="settings" +SRC_PATH_CLOUDSYNC="cloudsync" +SRC_PATH_FONTS="fonts" + +DST_IP="" +DST_USER=root +DST_PATH_CONFIG="/home/$DST_USER/.config" +DST_PATH_HOME="/home/$DST_USER" +DST_PATH_SCRIPTS="/home/$DST_USER/scripts" +DST_PATH_CLOUDSYNC="/home/$DST_USER/cloudsync" +DST_PATH_FONTS="/usr/share/fonts/truetype" +DST_PATH_BT_CONF="/etc/bluetooth/" + +POSTLOG=$HOME/post.log +POSTERR=$HOME/post.err +POSTOUT=$HOME/post.out +POSTMSG_POSTFIX_PASSED=" passed" +POSTMSG_POSTFIX_FAILED=" failed" +POSTMSG_CANBUS="CANBus" +POSTMSG_SDCARD="SD-CARD" +POSTMSG_TOUCH="Touch" +POSTMSG_RTC="RTC" +POSTMSG_WIFI="WiFi" +POSTMSG_BLUETOOTH="Bluetooth" +POSTMSG_SHASUM="App shasum" +POSTMSG_CLOUDSYNC="CloudSync" +POSTMSG_CLOUDSYNC_RUNNING="CloudSync app IS running" + +TDCTL_NTP_USED=$FALSE +TDCTL_RTC_LOCL=$TRUE +TDCTL_TIMEZONE=America/Los_Angeles + +IP_SEG_MAX_LEN=3 +IP_EMT="192.168.10." +SSH_PARAM="-oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -oLogLevel=ERROR -oConnectTimeout=2" + +CMD_RTC_EPOCH="cat /sys/class/rtc/rtc0/since_epoch" +CMD_SDCARD_DEV="ls $SDCARD_DEV" +CMD_SDCARD_PRT="ls $SDCARD_PRT" +CMD_LINUX_TYPE="sfdisk --part-type $SDCARD_DEV 1" + +INITD_LOCATION=/etc/init.d/ +INITD_AUTOSTART=autostart +DENALI_BIN=denali +LAUNCH_SCR=run.sh + +function confirm() { + read -p "$1? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" == "y" ]; then + echo "" + return $TRUE + else + echo "" + return $FALSE + fi +} + +string_trim() { + local var="$*" + # remove leading whitespace characters + var="${var#"${var%%[![:space:]]*}"}" + # remove trailing whitespace characters + var="${var%"${var##*[![:space:]]}"}" + printf '%s' "$var" +} + +function echo_star_comment() { + echo "$COMMENT_STAR"" $1 " +} + +function echo_star_message() { + echo " * $1" +} + +function echo_dash_comment() { + echo "$COMMENT_DASH"" $1 " +} + +function echo_dash_message() { + echo " $1" +} + +function timestamp() { + echo $(date +"%Y%m%d-%H%M%S") +} + +function validIP() +{ + local ip=$1 + if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + OIFS=$IFS + IFS='.' + ip=($ip) + IFS=$OIFS + if [[ ${ip[0]} -gt 255 && \ + ${ip[1]} -gt 255 && \ + ${ip[2]} -gt 255 && \ + ${ip[3]} -gt 255 ]]; then + return $ERR_INVALID_IP + fi + else + return $ERR_INVALID_IP + fi + return 0 +} + +function existsFolder() { + if [ ! -d "$1" ]; then + return "$ERR_MISSING_FOLDER" + fi +} + +function existsFile() { + if [ ! -f "$1" ]; then + return "$ERR_MISSING_FILE" + fi +} + +COUT="/dev/null" + +function post_log_clear () { echo "" > $POSTLOG; } +function post_err_clear () { echo "" > $POSTERR; } +function post_out_clear () { echo "" > $POSTOUT; } + +function post_log_pass () { echo "$1" >> $POSTLOG; echo "[ OK ] $1" > "$COUT"; } +function post_log_fail () { echo "$1" >> $POSTLOG; echo "[FAILED] $1" > "$COUT"; } +function post_log_dash () { echo "$COMMENT_DASH$1" >> $POSTLOG; echo "$COMMENT_DASH$1" > "$COUT"; } +function post_log_star () { echo "$COMMENT_DASH$1" >> $POSTLOG; echo "$COMMENT_STAR$1" > "$COUT"; } +function post_log () { echo "$1" >> $POSTLOG; echo " $1" > "$COUT"; } + +function post_err () { echo "$1" >> $POSTERR; } +function post_err_dash () { echo "$COMMENT_DASH$1" >> $POSTERR; } + +function post_out () { echo "$1" >> $POSTOUT; } +function post_out_dash () { echo "$COMMENT_DASH$1" >> $POSTOUT; } + +function debug () { + echo_dash_comment + echo_dash_message "$1" + echo_dash_comment +} Index: scripts/run.sh =================================================================== diff -u --- scripts/run.sh (revision 0) +++ scripts/run.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,210 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file run.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 05-Apr-2023 +# @author (original) Behrouz NematiPour +# @date (original) 28-Oct-2019 +# +############################################################################ + +echo "HOME : $HOME " > /home/root/post.debug +HOME="$1" +source ./globals.sh +COUT="/dev/$(echo $(dmesg | grep "printk: console") | sed 's/.*printk: console.*\(tty.*\)].*/\1/')" +echo "COMMENT_DASH: $COMMENT_DASH " >> /home/root/post.debug +echo "HOME : $HOME " >> /home/root/post.debug +echo "COUT : $COUT " >> /home/root/post.debug +echo "POSTLOG : $POSTLOG " >> /home/root/post.debug + +# cleanup the POST log file +post_log_clear +post_err_clear +post_out_clear + +post_log_star " ***** " +post_log "Start: $(timestamp)" # log the current date, time + +#create folders for sd-card and usb if not exist +mkdir -p $SDCARD_MNT +mkdir -p $USB_MNT + + +# ---------------------------------------- STOP denali in case running (sys not rebooted) +killall $DENALI_BIN + + +#setting up ethernet----------------------- Ethernet +post_log_dash " Ethernet " +udhcpc eth0 & + + +#setting up can interface ----------------- CANBus +post_log_dash " CANBus " +#current settings can be retrieved by the command below +#$ ip -details -statistics link show can0 +ip link set can0 up type can bitrate 250000 restart-ms 100 +ifconfig can0 txqueuelen 4000 +candump can0 -T1 # check if candump can successfully use the port. will terminate in 1ms +if [ $? -eq 0 ]; then + post_log_pass "$POSTMSG_CANBUS$POSTMSG_POSTFIX_PASSED" + post_log "$(ip link show can0)" # -details -statistics +else + post_log_fail "$POSTMSG_CANBUS$POSTMSG_POSTFIX_FAILED" +fi + + +#mounting sdcard -------------------------- SD-CARD +post_log_dash " SD-CARD " +mount $SDCARD_PRT $SDCARD_MNT +SDCTEST="$(mount | grep "$SDCARD_PRT on $SDCARD_MNT type $SDCARD_TYP_NAME (rw,")" +if ! [ -z "$SDCTEST" ]; then + SDINFO="$(df -h | grep -i $SDCARD_MNT)" + post_log_pass "$POSTMSG_SDCARD$POSTMSG_POSTFIX_PASSED" + post_log "$SDCTEST" + post_log "$SDINFO" +else + post_log_fail "$POSTMSG_SDCARD$POSTMSG_POSTFIX_FAILED" +fi + + +#test the RTC ----------------------------- RTC +post_log_dash " RTC" +#may not be an accurate test but sufficient for now +#and could not find a way to get the rtc clock with the higher resolusion +#it should not be confused with date command which is system date/time and not hwclock +hwclock -r # if there is any issue with rtc hwclock will show errors +if [ $? -eq 0 ]; then + RTC1=$($CMD_RTC_EPOCH) + sleep 1 + RTC2=$($CMD_RTC_EPOCH) + if [ $(($RTC2 - $RTC1)) -eq 1 ]; then + post_log_pass "$POSTMSG_RTC$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_RTC$POSTMSG_POSTFIX_FAILED" + fi +fi + + +# ----------------------------------------- Bluetooth +post_log_dash " Bluetooth " +/usr/share/silex-uart/silex-uart.sh start 1>> $POSTOUT 2>> $POSTERR +sleep 5 +hciconfig hci0 up +if [ $? -eq 0 ]; then + post_log_pass "$POSTMSG_BLUETOOTH$POSTMSG_POSTFIX_PASSED" + post_log "$(hciconfig hci0)" +else + post_log_fail "$POSTMSG_BLUETOOTH$POSTMSG_POSTFIX_FAILED" +fi + + +#test the touch screen -------------------- Touch +post_log_dash " Touch " +# when successfully connected and can be loaded +# Sitronix touch driver 2.10.2 Release date: 20180809 +# atmel_mxt_ts 3-004a: Direct firmware load for maxtouch.cfg failed with error -2 +# atmel_mxt_ts 3-004a: Touchscreen size X1279Y799 +# input: Atmel maXTouch Touchscreen as /devices/platform/soc@0/soc@0:bus@30800000/30a50000.i2c/i2c-3/3-004a/input/input2 +# When NOT connected +# Sitronix touch driver 2.10.2 Release date: 20180809 +TSTEST="$(dmesg | grep "input: Atmel maXTouch Touchscreen as ")" +if [ "$?" -eq 0 ]; then + post_log_pass "$POSTMSG_TOUCH$POSTMSG_POSTFIX_PASSED" + post_log "$TSTEST" +else + post_log_fail "$POSTMSG_TOUCH$POSTMSG_POSTFIX_FAILED" +fi + + +# ----------------------------------------- WiFi +post_log_dash " WiFi " + +# create the wpa supplicant folder for conf storing +WPA_SUPPLICANT_DIR="/etc/wpa_supplicant/" +mkdir -p $WPA_SUPPLICANT_DIR + +# remove any software blocks +rfkill unblock wlan + +if [[ ! -z $(dmesg | grep "wlan: driver loaded") ]]; then + post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED" + post_log "$(dmesg | grep -i wlan:)" + post_log "$(ip link show wlan0)" # -details -statistics +else + post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" +fi + +# start the wpa_supplicant service +systemctl start wpa_supplicant@wlan0.service +if [ $? -eq 0 ]; then +    post_log_pass "$POSTMSG_WIFI$POSTMSG_POSTFIX_PASSED" +else +    post_log_fail "$POSTMSG_WIFI$POSTMSG_POSTFIX_FAILED" +    post_log      "$(systemctl --failed | grep wpa)" +fi + + +# ----------------------------------------- Sha256Sum +post_log_dash " Sha256Sum " +#check the denali applicatoin checksum +SHA_ACT=$(tail -c 83 $HOME/$DENALI_BIN | cut -c19-82) +SHA_EXP=$(head -c -83 $HOME/$DENALI_BIN | sha256sum -b --tag | cut -c14-77) +if [ "$SHA_ACT" == "$SHA_EXP" ]; then + post_log_pass "$POSTMSG_SHASUM$POSTMSG_POSTFIX_PASSED" +else + post_log_fail "$POSTMSG_SHASUM$POSTMSG_POSTFIX_FAILED" +fi + + +# ----------------------------------------- CloudSync +post_log_dash " CloudSync " +if [ -d $HOME/$CLOUDSYNC_FOLDER ]; then + # moving/ backing up the previous treatment logs so the new buff starts with fresh sequence + echo "Backing up CloudSync I/O buff" + CLOUDSYNC_PATH="$SDCARD_MNT"/"$CLOUDSYNC_FOLDER" + CLOUDSYNC_BACKUP="$CLOUDSYNC_PATH"_backup/$(timestamp)/ + mkdir -p $CLOUDSYNC_BACKUP + mv $CLOUDSYNC_PATH/* $CLOUDSYNC_BACKUP 1>> $POSTOUT 2>> $POSTERR + rm $HOME/$CLOUDSYNC_FOLDER/data/* 1>> $POSTOUT 2>> $POSTERR + cd $HOME/$CLOUDSYNC_FOLDER/ + python3 ./cs.py start & + sleep 2 + CLOUDSYNC_STATUS="$(python3 ./cs.py status)" + if [ "$CLOUDSYNC_STATUS" == "$POSTMSG_CLOUDSYNC_RUNNING" ]; then + post_log_pass "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_PASSED" + else + post_log_fail "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_FAILED" + fi + post_log "$CLOUDSYNC_STATUS" + cd +else + post_log_fail "$POSTMSG_CLOUDSYNC$POSTMSG_POSTFIX_FAILED" +fi + + +# ----------------------------------------- Denali +post_log_dash " Denali " +#launching denali application +DENALI_VERSION="$($HOME/$DENALI_BIN -v)" +if [ -n "$DENALI_VERSION" ]; then + post_log_pass "$($HOME/$DENALI_BIN -v)" # log UI Software version + $HOME/$DENALI_BIN -u -C & # -C to disable cloudsync for now sync it blocks the system and no cloudsync has been installed. +else + post_log_fail "Unknown Applicaion Version" +fi + + +# ----------------------------------------- END +# tag the end time in the POST log file +post_log "End: $(timestamp)" +post_log_star " ***** " + +exit 0 Index: scripts/setup.sh =================================================================== diff -u --- scripts/setup.sh (revision 0) +++ scripts/setup.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,152 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2020-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file setup.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 16-Dec-2022 +# @author (original) Behrouz NematiPour +# @date (original) 13-Mar-2020 +# +############################################################################ + +# @details +# This script is part of setting up the newly flashed SoM which will run on the device +# after the start.sh script is done copying files on the device. + +source ./globals.sh "$1" "$2" + +function check_sdcard() { + while true; do + if [ ! "$($CMD_SDCARD_DEV)" == "$SDCARD_DEV" ];then # if no SD-Card found ask operator to install on and retry after power-cycle. + echo_dash_comment + echo_dash_message "No SD-Card detected" + echo_dash_message "UI Software logging will not work without a SD-Card" + echo_dash_message "Insert a SD-Card and continue when ready" + echo_dash_comment + confirm "Continue" + if [ $? -eq $FALSE ]; then + # Since the UI will still work without the SD-Card, but won't log, + #exit $ERR_SD_CARD # Do not exit the setup for now, + return $FALSE # And let the user to format and insert the sd-card later. + fi + else + break + fi + done + + if [ ! "$($CMD_SDCARD_PRT)" == "$SDCARD_PRT" ]; then return $FALSE; fi # if partition 1 doesn't exist , do the format + if [ ! "$($CMD_LINUX_TYPE)" == "$SDCARD_TYP_NUMB" ]; then return $FALSE; fi # if partition 1 type is not Linux(83) , do the format + return $TRUE # otherwise , do not format +} + +function format_sdcard() { + check_sdcard + if [ $? -eq $TRUE ]; then # if sd-card is OK + echo "Found the SD-Card $SDCARD_DEV" + confirm "Do you want to format the SD-Card" + if [ $? -eq $FALSE ]; then # give user an option to skip the format + return $? + fi + fi + + echo "Unmount the SD-Card if is in use" + umount "$SDCARD_PRT" + echo "Removing current partitions" + sfdisk --delete $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "Create new partition" + echo "label:MBR" | sfdisk $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "type=83" | sfdisk $SDCARD_DEV 1>/dev/null 2>/dev/null + echo "Create a ext4 file system" + mkfs.ext4 $SDCARD_PRT -L "Denali_Log" -F # 1>/dev/null 2>/dev/null + + check_sdcard + if [ $? -eq $TRUE ]; then + echo "SD-Card format PASSED" + else + echo "SD-Card format FAILED !!!" + fi +} + +function set_timezone() { + echo "setup the time/date controller" + # to use the system time/date and not use the network time protocol + timedatectl set-ntp $TDCTL_NTP_USED + + echo "Setup the timezone (PDT Pacific)" + timedatectl set-timezone $TDCTL_TIMEZONE + timedatectl set-local-rtc $TDCTL_RTC_LOCL +} + +function set_datetime() { + echo "Setup the time/date" + while true; do + timedatectl set-time "$DATETIME" 1>/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + break + else + read -p "please enter the date (yyyy-MM-dd HH:mm): " -e -i "$DATETIME" -r DATETIME + fi + done +} + +function diable_b2qt_services() { + echo "Disabling boot2Qt setvices" + systemctl disable b2qt + systemctl disable connman + systemctl disable qtlauncher + systemctl disable ebikedata +} + +function setup_denali() { + echo "Setting denali as default auto start application" + + chmod a+x $HOME/$INITD_AUTOSTART + chmod a+x $HOME/$LAUNCH_SCR + chmod a+x $HOME/$DENALI_BIN + + rm -f "$POSTLOG" "$POSTERR" "$POSTOUT" + + echo "Syncing file system updates" + sync;sync;sync +} + +function disable_autostart() { + # in case the device is alread setup, disable the autostart of the application until the setup script enables it. + rm -f $INITD_LOCATION$INITD_AUTOSTART +} + +function enable_autostart() { + mkdir -p $INITD_LOCATION + mv $INITD_AUTOSTART $INITD_LOCATION + update-rc.d $INITD_AUTOSTART defaults +} + +function confirm_reboot() { + read -p "ready to reboot? [y,n]" -n 1 -r CONFIRM + if [ "$CONFIRM" == "y" ]; then + rm $0 + reboot + fi + echo "" +} + +function main() { + disable_autostart + format_sdcard + set_timezone + set_datetime "$1" "$2" + diable_b2qt_services + setup_denali + enable_autostart +} + +main "$1" "$2" +confirm_reboot + +exit 0 Index: scripts/start.sh =================================================================== diff -u --- scripts/start.sh (revision 0) +++ scripts/start.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,260 @@ +#!/bin/bash +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file start.sh +# +# @author (last) Vy +# @date (last) 20-May-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-Aug-2021 +# +############################################################################ + +# @details +# This file is used to setup newly flashed SoM to copy everythin on the device. + +source ./globals.sh + +function displayHelp() { + if [ "$1" = "-h" -o "$1" = "--help" ]; then + echo -e "-h \t This help" + echo "usage start.sh [ [xxx] or [xxx.xxx.xxx.xxx] or [] ]" + exit 0 + fi +} + +function exitConfirm() { + read -p "Continue? [y,n]" -n 1 -r CONTINUE + if [ "$CONTINUE" != "y" ]; then + echo "" + exit "$1" + else + echo "" + fi +} + +function defaultIP() { + if [ -n "$1" ]; then + if [ ${#1} -gt $IP_SEG_MAX_LEN ]; then + DST_IP=$1 + else + DST_IP=$IP_EMT"$1" + fi + fi +} + +function setupLogs() { + local log_location=$LOG_LOCATION/$DST_IP + mkdir -p $log_location + LOG_OUT_FILE="$log_location/update-$(timestamp).log" + LOG_ERR_FILE="$log_location/update-$(timestamp).err" + touch $LOG_OUT_FILE + touch $LOG_ERR_FILE +} + +function sshKeyExists() { + existsFile $SRC_FILE_SSHKEY_PUB + return $? +} + +function sshKeyGen() { + sshKeyExists + if [ ! $? -eq 0 ]; then + echo "No ssh key found,Generating ssh key" + ssh-keygen -N "" -f $SRC_FILE_SSHKEY 1>>$LOG_OUT_FILE 2>>$LOG_ERR_FILE + return $? + else + echo "Found ssh key " $SRC_FILE_SSHKEY_PUB + fi + return 0 +} + +function sshKeyCopy() { + echo "Registering the ssh key on the device $DST_IP" + echo "Please wait ..." + ssh-copy-id $SSH_PARAM -f -i $SRC_FILE_SSHKEY_PUB $DST_USER@$DST_IP 1>>$LOG_OUT_FILE 2>>$LOG_ERR_FILE + if [ ! $? -eq 0 ]; then + echo "Connection to host $DST_IP failed." | tee -a $LOG_OUT_FILE + exitConfirm $? + return $? + fi +} + +function sshRun() { + ssh $SSH_PARAM $DST_USER@$DST_IP $1 + return $? +} + +function copyFolderTo() { + existsFolder "$1" + if [ $? -eq 0 ]; then + echo -n "Copy folder" >> $LOG_OUT_FILE + scp -r $SSH_PARAM $1/* $DST_USER@$DST_IP:$2 + if [ $? -eq 0 ]; then + echo " Successfull - $1" >> $LOG_OUT_FILE + else + echo " Failed" >> $LOG_OUT_FILE + exitConfirm $? + return $? + fi + else + echo "File '$1' doesn't exist" | tee -a $LOG_OUT_FILE + exitConfirm $? + fi + return 0 +} + +function copyFileTo() { + existsFile "$1" + if [ $? -eq 0 ]; then + echo -n "Copy file" >> $LOG_OUT_FILE + scp $SSH_PARAM $1 $DST_USER@$DST_IP:$2 + if [ $? -eq 0 ]; then + echo " Successfull - $1" >> $LOG_OUT_FILE + else + echo " Failed" >> $LOG_OUT_FILE + exitConfirm $? + return $? + fi + else + echo "File '$1' doesn't exist" | tee -a $LOG_OUT_FILE + exitConfirm $? + fi + return 0 +} + +function killPrompt() { + echo_star_comment + echo_star_message "Current running UI Software on the device will be stopped." + echo_star_message "All the settings, configurations and binaries will be overwritten" + echo_star_comment + exitConfirm $ERR_KILLPROMPT +} + +function getDeviceIP() { + while true; do + validIP "$DST_IP" + if [ $? -eq 0 ]; then + break + else + read -p "Please enter the device Ip address: " -e -i "$IP_EMT" -r DST_IP + validIP "$DST_IP" + if [ $? -eq 0 ]; then + break + else + echo "The entered IP address is not valid [$DST_IP]" + exitConfirm $? + fi + fi + done +} + +function setupBootupScripts() { + echo_dash_comment + echo_dash_message "Installing bootup scripts" | tee -a $LOG_OUT_FILE + echo_dash_comment + copyFileTo "globals.sh" $DST_PATH_HOME + copyFileTo "autostart" $DST_PATH_HOME + copyFileTo "run.sh" $DST_PATH_HOME + copyFileTo "setup.sh" $DST_PATH_HOME +} + +#TODO to be removed when yocto recipes updated +function setupBluetoothConfFile() { + echo_dash_comment + echo_dash_message "Installing bluetooth conf file" | tee -a $LOG_OUT_FILE + echo_dash_comment + copyFileTo $SRC_PATH_SCRIPTS/"bluetooth_main.conf" $DST_PATH_BT_CONF/main.conf + +} + +function setupSettingsScripts() { + echo_dash_comment + echo_dash_message "Installing settings scripts" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "rm -frd $DST_PATH_SCRIPTS;" + sshRun "mkdir -p $DST_PATH_SCRIPTS;" + copyFolderTo $SRC_PATH_SCRIPTS $DST_PATH_SCRIPTS + sshRun "cd $1; chmod a+x *.sh;" +} + +function setupConfigurations() { + echo_dash_comment + echo_dash_message "Installing configurations" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "rm -frd $DST_PATH_CONFIG;" + sshRun "mkdir -p $DST_PATH_CONFIG;" + copyFolderTo $SRC_PATH_CONFIG $DST_PATH_CONFIG +} + +function setupCloudSync() { + echo_dash_comment + echo_dash_message "Installing CloudSync" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "killall python3" + sshRun "rm -frd $DST_PATH_CLOUDSYNC;" + sshRun "mkdir -p $DST_PATH_CLOUDSYNC;" + copyFolderTo $SRC_PATH_CLOUDSYNC $DST_PATH_CLOUDSYNC +} + +function setupFonts() { + echo_dash_comment + echo_dash_message "Installing fonts" | tee -a $LOG_OUT_FILE + echo_dash_comment + copyFolderTo $SRC_PATH_FONTS $DST_PATH_FONTS +} + +function setupApplication() { + echo_dash_comment + echo_dash_message "Installing UI Software" | tee -a $LOG_OUT_FILE + echo_dash_comment + sshRun "killall $DENALI_BIN" + copyFileTo $DENALI_BIN $DST_PATH_HOME +} + +function connect() { + echo_dash_comment + echo_dash_message "please ssh into device $DST_IP and run ./setup.sh " + echo_dash_comment + read -p "Hit enter to continue" + sshRun # the setup.sh has to run on the device while user has logged into the device. +} + +function wipe_device() { + sshRun "rm -frd *" + sshRun "rm -frd .*" +} + +function main() { + displayHelp "$1" + + defaultIP "$1" + getDeviceIP + setupLogs + + sshKeyGen + sshKeyCopy + + killPrompt + wipe_device + + setupBootupScripts + setupSettingsScripts + setupConfigurations + setupBluetoothConfFile + setupCloudSync + setupFonts + + setupApplication +} + +# running the main function +main "$1" +connect + +exit 0 Index: scripts/wifi_disconnect_network.sh =================================================================== diff -u --- scripts/wifi_disconnect_network.sh (revision 0) +++ scripts/wifi_disconnect_network.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,35 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_disconnect_network.sh +# +# @author (last) Vy +# @date (last) 26-Jan-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 + +# stop the wpa service +systemctl stop wpa_supplicant@"$iface".service + +#remove the wpa configuration file +rm -f /etc/wpa_supplicant/wpa_supplicant-"$iface".conf + +#Shutoff wifi interface +ip link set $iface down + + Index: scripts/wifi_generate_wpa_supplicant.sh =================================================================== diff -u --- scripts/wifi_generate_wpa_supplicant.sh (revision 0) +++ scripts/wifi_generate_wpa_supplicant.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,57 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_generate_wpa_supplicant.sh +# +# @author (last) Vy +# @date (last) 30-Jan-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ssid=$1 +password=$2 +dest=$3 +securityType=$4 +psk=$(wpa_passphrase "$ssid" "$password" | grep "psk=" | grep -v "#psk" | sed -nr 's/.*psk=(.*)/\1/p') +case $securityType in + wpa2) + echo "Security: wpa2"; + echo "ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 + +network={ + ssid=\"$ssid\" + key_mgmt=WPA-PSK + pairwise=CCMP TKIP + group=CCMP TKIP + scan_ssid=1 + #psk=\"\" + psk="$psk" +}" > $dest;; + wpa) + echo "Security: wpa"; + echo "ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 + +network={ + ssid=\"$ssid\" + #psk=\"\" + psk="$psk" +}" > $dest;; + +esac Index: scripts/wifi_read_dns.sh =================================================================== diff -u --- scripts/wifi_read_dns.sh (revision 0) +++ scripts/wifi_read_dns.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,22 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_dns.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile" + exit 0 +fi +cat /etc/resolv.conf | grep "nameserver" Index: scripts/wifi_read_gateway.sh =================================================================== diff -u --- scripts/wifi_read_gateway.sh (revision 0) +++ scripts/wifi_read_gateway.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_gateway.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile" + exit 0 +fi + +ip route show | grep "default via" Index: scripts/wifi_read_ip_settings.sh =================================================================== diff -u --- scripts/wifi_read_ip_settings.sh (revision 0) +++ scripts/wifi_read_ip_settings.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_ip_settings.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +ifconfig $iface | grep "inet " Index: scripts/wifi_read_network_info.sh =================================================================== diff -u --- scripts/wifi_read_network_info.sh (revision 0) +++ scripts/wifi_read_network_info.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,26 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2023-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_read_network_info.sh +# +# @author (last) Vy +# @date (last) 16-May-2023 +# @author (original) Vy +# @date (original) 16-May-2023 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +iwconfig wlan0 + Index: scripts/wifi_request_auto_assigned_ip.sh =================================================================== diff -u --- scripts/wifi_request_auto_assigned_ip.sh (revision 0) +++ scripts/wifi_request_auto_assigned_ip.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,26 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_request_auto_assigned_ip.sh +# +# @author (last) Vy +# @date (last) 24-Jan-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +killall udhcpc +udhcpc --timeout=5 --retries=1 -n -i $iface Index: scripts/wifi_reset_adapter.sh =================================================================== diff -u --- scripts/wifi_reset_adapter.sh (revision 0) +++ scripts/wifi_reset_adapter.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_reset_adapter.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile" + exit 0 +fi + +rfkill block wifi +rfkill unblock wifi Index: scripts/wifi_reset_interface.sh =================================================================== diff -u --- scripts/wifi_reset_interface.sh (revision 0) +++ scripts/wifi_reset_interface.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_reset_interface.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ip link set $1 down +ip link set $1 up Index: scripts/wifi_save_dhcp_interface.sh =================================================================== diff -u --- scripts/wifi_save_dhcp_interface.sh (revision 0) +++ scripts/wifi_save_dhcp_interface.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,28 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_save_dhcp_interface.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 25-Feb-2022 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +echo "auto $iface +iface $iface inet dhcp + wpa-driver wext + wpa-conf /etc/wpa_supplicant.conf" > /etc/network/interfaces Index: scripts/wifi_save_static_interface_assignments.sh =================================================================== diff -u --- scripts/wifi_save_static_interface_assignments.sh (revision 0) +++ scripts/wifi_save_static_interface_assignments.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,35 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_save_static_interface_assignments.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +ip=$2 +gateway=$3 +subnet_mask=$4 + +echo "auto $iface +iface $iface inet static + address $ip + netmask $subnet_mask + gateway $3" > /etc/network/interfaces + +./wifi_set_gateway.sh $gateway Index: scripts/wifi_scan_for_networks.sh =================================================================== diff -u --- scripts/wifi_scan_for_networks.sh (revision 0) +++ scripts/wifi_scan_for_networks.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_scan_for_networks.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iwlist $1 scan Index: scripts/wifi_set_auto_assigned_ip.sh =================================================================== diff -u --- scripts/wifi_set_auto_assigned_ip.sh (revision 0) +++ scripts/wifi_set_auto_assigned_ip.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,27 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_auto_assigned_ip.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 + +echo "auto $iface +iface $iface inet dhcp" >> /etc/network/interfaces Index: scripts/wifi_set_dns.sh =================================================================== diff -u --- scripts/wifi_set_dns.sh (revision 0) +++ scripts/wifi_set_dns.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_dns.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +echo "nameserver $1" >> /etc/resolv.conf Index: scripts/wifi_set_gateway.sh =================================================================== diff -u --- scripts/wifi_set_gateway.sh (revision 0) +++ scripts/wifi_set_gateway.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_gateway.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ip route del default +ip route add default via $1 Index: scripts/wifi_set_static_ip.sh =================================================================== diff -u --- scripts/wifi_set_static_ip.sh (revision 0) +++ scripts/wifi_set_static_ip.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_static_ip.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ifconfig $1 $2 \ No newline at end of file Index: scripts/wifi_set_subnetmask.sh =================================================================== diff -u --- scripts/wifi_set_subnetmask.sh (revision 0) +++ scripts/wifi_set_subnetmask.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,24 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_set_subnetmask.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +ifconfig $1 netmask $2 \ No newline at end of file Index: scripts/wifi_start_wpa_supplicant.sh =================================================================== diff -u --- scripts/wifi_start_wpa_supplicant.sh (revision 0) +++ scripts/wifi_start_wpa_supplicant.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,31 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_start_wpa_supplicant.sh +# +# @author (last) Vy +# @date (last) 07-Feb-2023 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ $# -eq 0 ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +wpa_supplicant_path=$2 + +# make sure hardware is up +ip link set $iface up + +# restart the wpa_supplicant service for wifi +systemctl restart wpa_supplicant@"$iface".service Index: scripts/wifi_test_internet.sh =================================================================== diff -u --- scripts/wifi_test_internet.sh (revision 0) +++ scripts/wifi_test_internet.sh (revision d4988df80c5d03fe46e42c9563043ae281247278) @@ -0,0 +1,25 @@ +#!/bin/sh +########################################################################### +# +# Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file wifi_test_internet.sh +# +# @author (last) Behrouz NematiPour +# @date (last) 11-May-2021 +# @author (original) Behrouz NematiPour +# @date (original) 11-May-2021 +# +############################################################################ + +if [ "$1" == "-h" ]; then + currentFile=$(basename "$0") + echo "Usage: ./$currentFile " + exit 0 +fi + +iface=$1 +ping -I $iface -c 4 www.linuxfoundation.org