Exemple #1
0
/*======================================================================= 
Function: Loc_WriteGPSSettings()

Description: 
   Write the GPS configuration settings from the configuration file.

Prototype:

   uint32 Loc_WriteGPSSettings(CLoc *pMe, IFile * pIFile);
=======================================================================*/
static uint32 Loc_WriteGPSSettings( IFile * pIFile , AEEGPSConfig *gpsConfig)
{
   char    *pszBuf;
   int32    nResult;

   if (pIFile == NULL || gpsConfig == NULL)
      return EFAILED;

   pszBuf = MALLOC( 1024 );

   // Truncate the file, in case it already contains data
   IFILE_Truncate( pIFile, 0 );

   // Write out the optimization setting:
   SPRINTF( pszBuf, LOC_CONFIG_OPT_STRING"%d;\r\n", gpsConfig->optim );
   nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
   if ( 0 == nResult ) {
      FREE(pszBuf);
      return EFAILED;
   }
   
   // Write out the QoS setting:
   SPRINTF( pszBuf, LOC_CONFIG_QOS_STRING"%d;\r\n", gpsConfig->qos );
   nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
   if ( 0 == nResult ) {
      FREE(pszBuf);
      return EFAILED;
   }
   
   // Write out the server type setting:
   SPRINTF( pszBuf, LOC_CONFIG_SVR_TYPE_STRING"%d;\r\n", gpsConfig->server.svrType );
   nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
   if ( 0 == nResult ) {
      FREE(pszBuf);
      return EFAILED;
   }
   
   if ( AEEGPS_SERVER_IP == gpsConfig->server.svrType ) {
      // Write out the IP address setting:
      INET_NTOA( gpsConfig->server.svr.ipsvr.addr, pszBuf, 50 );
      nResult = IFILE_Write( pIFile, LOC_CONFIG_SVR_IP_STRING, STRLEN( LOC_CONFIG_SVR_IP_STRING ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }
      nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }
      nResult = IFILE_Write( pIFile, ";\r\n", STRLEN( ";\r\n" ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }

      // Write out the port setting:
      SPRINTF( pszBuf, LOC_CONFIG_SVR_PORT_STRING"%d;\r\n", AEE_ntohs(gpsConfig->server.svr.ipsvr.port) );
      nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }
   }

   FREE( pszBuf );

   return SUCCESS;
}
Exemple #2
0
/*======================================================================= 
Function: SamplePosDet_WriteGPSSettings()

Description: 
   Write the GPS configuration settings from the configuration file.

Prototype:

   uint32 SamplePosDet_WriteGPSSettings(CSamplePosDet *pMe, IFile * pIFile);

Parameters:
   pMe: [in]. CSamplePosDet instance.
   pIFile: [in].  Pointer to the IFile instance representing the config
                  file.

Return Value:

  SUCCESS - If the settings were written successfully.
  EFAILED - If an error occured.
 
Comments:  
   None

Side Effects: 
   None

See Also:
   None
=======================================================================*/
uint32 SamplePosDet_WriteGPSSettings( CSamplePosDet *pMe, IFile * pIFile )
{
   char    *pszBuf;
   int32    nResult;

   pszBuf = MALLOC( 1024 );

   // Truncate the file, in case it already contains data
   IFILE_Truncate( pIFile, 0 );

   // Write out the optimization setting:
   SPRINTF( pszBuf, SPD_CONFIG_OPT_STRING"%d;\r\n", pMe->gpsSettings.optim );
   nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
   if ( 0 == nResult ) {
      FREE(pszBuf);
      return EFAILED;
   }
   
   // Write out the QoS setting:
   SPRINTF( pszBuf, SPD_CONFIG_QOS_STRING"%d;\r\n", pMe->gpsSettings.qos );
   nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
   if ( 0 == nResult ) {
      FREE(pszBuf);
      return EFAILED;
   }
   
   // Write out the server type setting:
   SPRINTF( pszBuf, SPD_CONFIG_SVR_TYPE_STRING"%d;\r\n", pMe->gpsSettings.server.svrType );
   nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
   if ( 0 == nResult ) {
      FREE(pszBuf);
      return EFAILED;
   }
   
   if ( AEEGPS_SERVER_IP == pMe->gpsSettings.server.svrType ) {
      // Write out the IP address setting:
      INET_NTOA( pMe->gpsSettings.server.svr.ipsvr.addr, pszBuf, 50 );
      nResult = IFILE_Write( pIFile, SPD_CONFIG_SVR_IP_STRING, STRLEN( SPD_CONFIG_SVR_IP_STRING ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }
      nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }
      nResult = IFILE_Write( pIFile, ";\r\n", STRLEN( ";\r\n" ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }

      // Write out the port setting:
      SPRINTF( pszBuf, SPD_CONFIG_SVR_PORT_STRING"%d;\r\n", AEE_ntohs(pMe->gpsSettings.server.svr.ipsvr.port) );
      nResult = IFILE_Write( pIFile, pszBuf, STRLEN( pszBuf ) );
      if ( 0 == nResult ) {
         FREE(pszBuf);
         return EFAILED;
      }
   }

   FREE( pszBuf );

   return SUCCESS;
}