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:

  1. Open terminal and navigate to the deviceConnect folder: /usr/local/deviceConnect.
  2. 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):
  3. 
       mkdir deviceChargingScripts
        
  4. Navigate into deviceChargingScripts:
  5. 
       cd deviceChargingScripts
        
  6. Using Vim or GNUnano create a Charge mode script file:
  7. 
       vi deviceChargeScript.sh
        
  8. In the deviceChargeScript.sh file, enter the Charge mode script:
  9. 
       curl -XPOST -u : "http://$service/apiv1/Device/UsbPort?update&id=&usbHubPortState=Charge"
        
  10. Enter command ZZ to save changes to the file and quit.
  11. Using Vim or GNUnano, create a Data mode script:
  12. 
       vi deviceChargeScript.sh
        
  13. In the deviceDataScript.sh file, enter the Data mode script:
  14. 
       curl -XPOST -u : "http://$service/apiv1/Device/UsbPort?update&id=&usbHubPortState=Data"
        
  15. Enter command ZZ to save changes to the file and quit.
  16. Open the crontab scheduler:
  17. 
       sudo crontab -e
       
  18. 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:
  19. 
       30 02 * * * bash /usr/local/deviceConnect/deviceChargingScripts/deviceChargeScript.sh 
       30 06 * * * bash /usr/local/deviceConnect/deviceChargingScripts/deviceDataScript.sh
        
  20. Enter ctrl+x to save changes and run the scripts.