Charging Script Setup
While a device is set to Charge mode, it's unavailable for use and cannot be communicated with through GigaFox. Although Data mode will charge a device, Charge mode may be required for some devices to properly fill their batteries, for example an Amazon Kindle.
To avoid having a device be unavailable during testing hours, a scheduled crontab script can be set to routinely change a device's mode during off hours.
To set up crontab charge script on the GigaFox GEM:
- Open terminal and navigate to the deviceConnect folder: /usr/local/deviceConnect.
- Create a folder to store charging scripts (This folder does not need to have a specific name, but for this tutorial, it will be called deviceChargingScripts):
- Navigate into deviceChargingScripts:
- Using Vim or GNUnano create a Charge mode script file:
- In the deviceChargeScript.sh file, enter the Charge mode script:
- Enter command ZZ to save changes to the file and quit.
- Using Vim or GNUnano, create a Data mode script:
- In the deviceDataScript.sh file, enter the Data mode script:
- Enter command ZZ to save changes to the file and quit.
- Open the crontab scheduler:
- Enter the time to routinely run the Charge and Data mode scripts
in the following crontab format:
Example: To automatically run the deviceChargeScript.sh script everyday at 2:30am and run deviceDataScript.sh script at 6:30am everyday: - Enter ctrl+x to save changes and run the scripts.
mkdir deviceChargingScripts
cd deviceChargingScripts
vi deviceChargeScript.sh
curl -XPOST -u : "http://$service/apiv1/Device/UsbPort?update&id=&usbHubPortState=Charge"
vi deviceChargeScript.sh
curl -XPOST -u : "http://$service/apiv1/Device/UsbPort?update&id=&usbHubPortState=Data"
sudo crontab -e
30 02 * * * bash /usr/local/deviceConnect/deviceChargingScripts/deviceChargeScript.sh
30 06 * * * bash /usr/local/deviceConnect/deviceChargingScripts/deviceDataScript.sh