Reverted last changes
This commit is contained in:
parent
da50d43cae
commit
8e8c887592
24
src/gsm.c
24
src/gsm.c
|
@ -50,8 +50,8 @@ typedef enum _GSMPriority
|
||||||
typedef enum _GSMQuirk
|
typedef enum _GSMQuirk
|
||||||
{
|
{
|
||||||
GSM_QUIRK_NONE = 0,
|
GSM_QUIRK_NONE = 0,
|
||||||
GSM_QUIRK_CPIN_QUOTES = 1,
|
GSM_QUIRK_CPIN_QUOTES_NEWLINE,
|
||||||
GSM_QUIRK_NO_CARRIAGE_RETURN = 2
|
GSM_QUIRK_COPS_NEWLINE
|
||||||
} GSMQuirk;
|
} GSMQuirk;
|
||||||
|
|
||||||
typedef void (*GSMCommandCallback)(GSM * gsm);
|
typedef void (*GSMCommandCallback)(GSM * gsm);
|
||||||
|
@ -166,8 +166,8 @@ static struct
|
||||||
} _gsm_models[] =
|
} _gsm_models[] =
|
||||||
{
|
{
|
||||||
{ "\"Neo1973 GTA02 Embedded GSM Modem\"",
|
{ "\"Neo1973 GTA02 Embedded GSM Modem\"",
|
||||||
GSM_QUIRK_CPIN_QUOTES
|
GSM_QUIRK_CPIN_QUOTES_NEWLINE
|
||||||
| GSM_QUIRK_NO_CARRIAGE_RETURN },
|
| GSM_QUIRK_COPS_NEWLINE },
|
||||||
{ NULL, 0 }
|
{ NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -853,11 +853,11 @@ static int _gsm_modem_enter_sim_pin(GSM * gsm, char const * code)
|
||||||
_gsm_event(gsm, GSM_EVENT_TYPE_ERROR, GSM_ERROR_SIM_PIN_WRONG);
|
_gsm_event(gsm, GSM_EVENT_TYPE_ERROR, GSM_ERROR_SIM_PIN_WRONG);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
len = sizeof(cmd) + 1 + strlen(code) + 1;
|
len = sizeof(cmd) + 1 + strlen(code) + 2;
|
||||||
if((buf = malloc(len)) == NULL)
|
if((buf = malloc(len)) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
if(gsm->quirks & GSM_QUIRK_CPIN_QUOTES)
|
if(gsm->quirks & GSM_QUIRK_CPIN_QUOTES_NEWLINE)
|
||||||
snprintf(buf, len, "%s\"%s\"", cmd, code);
|
snprintf(buf, len, "%s\"%s\"\n", cmd, code);
|
||||||
else
|
else
|
||||||
snprintf(buf, len, "%s%s", cmd, code);
|
snprintf(buf, len, "%s%s", cmd, code);
|
||||||
ret = _gsm_queue_full(gsm, GSM_PRIORITY_HIGH, buf,
|
ret = _gsm_queue_full(gsm, GSM_PRIORITY_HIGH, buf,
|
||||||
|
@ -1188,7 +1188,7 @@ static int _gsm_modem_set_operator_format(GSM * gsm, GSMOperatorFormat format)
|
||||||
/* gsm_modem_set_operator_mode */
|
/* gsm_modem_set_operator_mode */
|
||||||
static int _gsm_modem_set_operator_mode(GSM * gsm, GSMOperatorMode mode)
|
static int _gsm_modem_set_operator_mode(GSM * gsm, GSMOperatorMode mode)
|
||||||
{
|
{
|
||||||
char cmd[] = "AT+COPS=X";
|
char cmd[] = "AT+COPS=X\0";
|
||||||
|
|
||||||
switch(mode)
|
switch(mode)
|
||||||
{
|
{
|
||||||
|
@ -1202,6 +1202,8 @@ static int _gsm_modem_set_operator_mode(GSM * gsm, GSMOperatorMode mode)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
cmd[8] = mode + '0';
|
cmd[8] = mode + '0';
|
||||||
|
if(gsm->quirks & GSM_QUIRK_COPS_NEWLINE)
|
||||||
|
cmd[9] = '\n';
|
||||||
return (_gsm_queue(gsm, cmd) != NULL) ? 0 : 1;
|
return (_gsm_queue(gsm, cmd) != NULL) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1510,8 +1512,6 @@ static void _gsm_queue_pop(GSM * gsm)
|
||||||
static int _gsm_queue_push(GSM * gsm)
|
static int _gsm_queue_push(GSM * gsm)
|
||||||
{
|
{
|
||||||
GSMCommand * gsmc;
|
GSMCommand * gsmc;
|
||||||
char const * suffix = (gsm->quirks & GSM_QUIRK_NO_CARRIAGE_RETURN)
|
|
||||||
? "\n" : "\r\n";
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
|
@ -1519,11 +1519,11 @@ static int _gsm_queue_push(GSM * gsm)
|
||||||
if(gsm->queue == NULL)
|
if(gsm->queue == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
gsmc = gsm->queue->data;
|
gsmc = gsm->queue->data;
|
||||||
gsm->wr_buf_cnt = strlen(gsmc->command) + strlen(suffix);
|
gsm->wr_buf_cnt = strlen(gsmc->command) + 2;
|
||||||
if((gsm->wr_buf = malloc(gsm->wr_buf_cnt + 1)) == NULL)
|
if((gsm->wr_buf = malloc(gsm->wr_buf_cnt + 1)) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
snprintf(gsm->wr_buf, gsm->wr_buf_cnt + 1, "%s%s", gsmc->command,
|
snprintf(gsm->wr_buf, gsm->wr_buf_cnt + 1, "%s%s", gsmc->command,
|
||||||
suffix);
|
"\r\n");
|
||||||
if(gsm->channel != NULL && gsm->wr_source == 0)
|
if(gsm->channel != NULL && gsm->wr_source == 0)
|
||||||
gsm->wr_source = g_io_add_watch(gsm->channel, G_IO_OUT,
|
gsm->wr_source = g_io_add_watch(gsm->channel, G_IO_OUT,
|
||||||
_on_watch_can_write, gsm);
|
_on_watch_can_write, gsm);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user