$Imei=$pcGPS->GetImei(); //Extract the module's IMEI code like "123456789012345" to see if we created pending commads for it. //***NEW MODULE SETTINGS*** $FileName="$DownloadMap$Imei.tms"; //Construct file name like: 123456789012345.tms if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //The file is expected to contain settings from the CGPSsettings class or written to disk with the settings application. //When the new settings are received by the module, it will let the result know via a transmission type SV_SettingsAccepted or SV_SettingsRejected. $pcGPS->mSettings=@file_get_contents($FileName); LogInfo("Download TMS to $Imei from file \"$FileName\"\r\n"); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); } else { //***GPS ASSIST FILE?*** $FileName1="$DownloadMap$Imei.gps"; //Construct file name like: 123456789012345.tms $FileName2="$DownloadMapGPSAssist.txt"; if ( (@is_file($FileName1)) && //Does a file with this name exist in the same directory as this script? (@is_file($FileName2)) && ($pcGPS->CanGetFix() ) && ($pcGPS->GetFix()<3 ) ) { //The file is expected to contain settings from the CGPSsettings class or written to disk with the settings application. //When the new settings are received by the module, it will let the result know via a transmission type SV_SettingsAccepted or SV_SettingsRejected. $pcGPS->mSettings=@file_get_contents($FileName2); LogInfo("Download GPS to $Imei from file \"$FileName2\"\r\n"); @chmod($FileName, 0777); if(!@unlink($FileName1)) LogError("!!!PROBLEM!!! The file '$FileName1' could not be deleted."); } } //***UPDATING FIRMWARE*** $FileName="$DownloadMap$Imei.tmf"; //Construct filename like: 123456789012345.tmf if(@is_file($FileName)) //Does a file with this name exist in the same directory as this script? { //An ASCII text file is expected, containing only the 3 digits of the new firmware version. //If the file exists and contains for example the following three digits: 385 //the module will try to download this file from your server: traceme385.hex //NOTES: //- The tracemeXXX.hex firmware file must be downloadable from the root directory of your HTTP server. // You can manually check if the file can be downloaded from your server's HTTP root // directory with a web browser by entering an URL like: http://YourServerIP/tracemeXXX.hex // You may need to configure your server's settings and/or add a new mime type // (e.g. binary octet-stream) before it allows downloads of binary files with the .hex // extension that you put in the HTTP root directory. //- A module will only reboot and start using downloaded firmware data if the version number // of the firmware is higher than the one already in use. //- Some GPRS providers use limits and filters in their system that can prohibit the module // from downloading a firmware file unmodified and in it's full length. // In this case you can only upload new firmware into a module with the settings program // via a direct cable connection. $FileSize=@filesize($FileName); if(($FileSize>=3) && $FileSize<=3+2) { $FirmwareVersion=@substr(@file_get_contents($FileName), 0, 3); if(@strspn($FirmwareVersion, '0123456789')==3) { $pcGPS->mFirmware=$FirmwareVersion; //Store firmware version in the response member of the class. LogInfo("Module $Imei has been instructed to download the firmware file \"traceme$FirmwareVersion.hex\" from the root of your HTTP server"); // LogInfo("Upload HEX to $Imei from file \"traceme$FirmwareVersion.hex\"\r\n"); } else LogError("Firmware command file \"$FileName\" contained invalid characters and must contain only the 3 digits of the firmware version."); } else LogError("Firmware command file \"$FileName\" file size was incorrect. It must contain only the 3 digits of the firmware version."); @chmod($FileName, 0777); if(!@unlink($FileName)) LogError("!!!PROBLEM!!! The file '$FileName' could not be deleted."); }