Beispiel #1
0
/**
 * @name gammu_destroy:
 */
void gammu_destroy(gammu_state_t *s) {

  GSM_TerminateConnection(s->sm);
  GSM_FreeStateMachine(s->sm);

  free(s);
}
Beispiel #2
0
/* Function to handle errors */
void error_handler(void)
{
	if (error != ERR_NONE) {
		printf("ERROR: %s\n", GSM_ErrorString(error));
		if (GSM_IsConnected(s))
			GSM_TerminateConnection(s);
		exit(error);
	}
}
Beispiel #3
0
THREAD_RETURN SearchPhoneThread(void * arg)
{
	int j;
	OneDeviceInfo *Info = arg;
	GSM_Error error;
	GSM_StateMachine *search_gsm;
	GSM_Config *smcfg;
	GSM_Config *globalcfg;

	/* Iterate over all connections */
	for (j = 0; strlen(Info->Connections[j].Connection) != 0; j++) {

		/* Allocate state machine */
		search_gsm = GSM_AllocStateMachine();
		if (search_gsm == NULL)
			return THREAD_RETURN_VAL;

		/* Get configuration pointers */
		smcfg = GSM_GetConfig(search_gsm, 0);
		globalcfg = GSM_GetConfig(gsm, 0);

		/* We share some configuration with global one */
		smcfg->UseGlobalDebugFile = globalcfg->UseGlobalDebugFile;
		smcfg->DebugFile = strdup(globalcfg->DebugFile);
		strcpy(smcfg->DebugLevel, globalcfg->DebugLevel);

		/* Configure the tested state machine */
		smcfg->Device = strdup(Info->Device);
		smcfg->Connection = strdup(Info->Connections[j].Connection);
		smcfg->SyncTime = FALSE;
		smcfg->Model[0] = 0;
		smcfg->LockDevice = FALSE;
		smcfg->StartInfo = FALSE;

		/* We have only one configured connection */
		GSM_SetConfigNum(search_gsm, 1);

		/* Let's connect */
		error = GSM_InitConnection(search_gsm, 1);

		printf(_("Connection \"%s\" on device \"%s\"\n"),
		       Info->Connections[j].Connection, Info->Device);

		/* Did we succeed? Show info */
		if (error == ERR_NONE) {
			SearchPrintPhoneInfo(search_gsm);
		} else {
			SearchPrintf("\t%s\n", GSM_ErrorString(error));
		}

		if (error != ERR_DEVICEOPENERROR) {
			GSM_TerminateConnection(search_gsm);
		}

		if (error == ERR_DEVICEOPENERROR)
			break;

		/* Free allocated buffer */
		GSM_FreeStateMachine(search_gsm);
	}
	return THREAD_RETURN_VAL;
}