[an error occurred while processing this directive]
|
у меня работает вот такой вот код на девайсах - нареканий не было
switch(Modem_PowerOff(&MS))
{
case AT_OK:
/* Power off */
CLEARBIT(GSM_ON_OFF_PORT, GSM_ON_OFF);
DEBUG_PRINT_STRING("Wismo soft power off", DEBUG_ALL)
ChangeModemStateMachine(pModemSMStatus, MODEM_CONTROL_HARDWARE_RESET);
break;
case AT_ERROR:
DEBUG_PRINT_STRING("Wismo soft cant power off", DEBUG_ALL)
ChangeModemStateMachine(pModemSMStatus, MODEM_CONTROL_HARDWARE_RESET);
break;
}unsigned char Modem_PowerOff(ModemStatusStruct *pMS)
{
static unsigned char PowerOFFStatus = POWER_OFF_1;
unsigned char Result;/* Reset state mashine to starting state */
if ( pMS == MODEM_RESET_STATE_MACHINE )
{
PowerOFFStatus = POWER_OFF_1;
return(AT_OK);
}
switch(PowerOFFStatus)
{
default:
ERROR_PRINT_STRING("Unknown state in PowerOFF state mashine")
PowerOFFStatus = POWER_OFF_1;
break;
case POWER_OFF_1:
/* Disable CGREG */
Result = SendATCommandAndCheckResult(&ATCommand_INIT13, "AT+CGREG=0\r", DONT_CHECK_SEND_COMMAND);
if (Result == AT_OK)
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL)
Result = AT_BUSY;
PowerOFFStatus = POWER_OFF_2;
}
else if (Result == AT_ERROR)
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL)
DEBUG_PRINT_STRING("Module POWEROFF. Command CGREG is error.", DEBUG_ALL)
Result = AT_ERROR;
PowerOFFStatus = POWER_OFF_1;
}
break;
case POWER_OFF_2:
/* Disable CREG */
Result = SendATCommandAndCheckResult(&ATCommand_INIT13, "AT+CREG=0\r", DONT_CHECK_SEND_COMMAND);
if (Result == AT_OK)
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL)
Result = AT_BUSY;
PowerOFFStatus = POWER_OFF_3;
}
else if (Result == AT_ERROR)
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL)
DEBUG_PRINT_STRING("Module POWEROFF. Command CREG is error.", DEBUG_ALL)
Result = AT_ERROR;
PowerOFFStatus = POWER_OFF_1;
}
break;
case POWER_OFF_3:
/* Disable WIND */
Result = SendATCommandAndCheckResult(&ATCommand_INIT13, "AT+WIND=0\r", DONT_CHECK_SEND_COMMAND);
if (Result == AT_OK)
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL)
Result = AT_BUSY;
PowerOFFStatus = POWER_OFF_4;
}
else if (Result == AT_ERROR)
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL)
DEBUG_PRINT_STRING("Module POWEROFF. Command WIND is error.", DEBUG_ALL)
Result = AT_ERROR;
PowerOFFStatus = POWER_OFF_1;
}
break;
case POWER_OFF_4:
Result = SendATCommandAndCheckResult(&ATCommand_CPOF, 0, DONT_CHECK_SEND_COMMAND);
if ( Result == AT_ERROR || Result == AT_OK )
{
DEBUG_PRINT("%s", ModemBuffer, DEBUG_ALL);
PowerOFFStatus = POWER_OFF_1;
}
break;
}
return (Result);
}