Changeset 3390


Ignore:
Timestamp:
11/12/07 10:38:04 (6 years ago)
Author:
tick
Message:

keeping track of current registration state internally in gsmd. Without this the"gsmd->dev_state.registered" variable had bogus values. (Andrew)

Location:
trunk/src/target/gsm/src/gsmd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/gsm/src/gsmd/atcmd.c

    r3308 r3390  
    669669         
    670670        llist_add(&cmd->list, &g->pending_atcmds); 
    671         return atcmd_done(g, cur, "OK"); 
     671        return atcmd_done(g, cur, "ERROR"); 
    672672} 
    673673 
  • trunk/src/target/gsm/src/gsmd/unsolicited.c

    r3267 r3390  
    146146{ 
    147147        const char *comma = strchr(param, ','); 
    148         struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_NETREG, 
    149                                              sizeof(struct gsmd_evt_auxdata)); 
     148        struct gsmd_ucmd *ucmd; 
    150149        struct gsmd_evt_auxdata *aux; 
     150        int prev_registered = gsmd->dev_state.registered; 
     151        int state; 
     152        char *end; 
     153 
     154        state = strtol(param, &end, 10); 
     155        if (!(end > param)) { 
     156                gsmd_log(GSMD_ERROR, "Bad +CREG format, not updating state\n"); 
     157                return -EINVAL; 
     158        } 
     159 
     160        /* Update our knowledge about our state */ 
     161        gsmd->dev_state.registered = 
     162                (state == GSMD_NETREG_REG_HOME || 
     163                 state == GSMD_NETREG_REG_ROAMING); 
     164 
     165        /* Intialise things that depend on network registration */ 
     166        if (gsmd->dev_state.registered && !prev_registered) { 
     167                sms_cb_network_init(gsmd); 
     168        } 
     169 
     170        /* Notify clients */ 
     171        ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_NETREG, 
     172                        sizeof(struct gsmd_evt_auxdata)); 
    151173        if (!ucmd) 
    152174                return -ENOMEM; 
     
    164186                aux->u.netreg.lac = aux->u.netreg.ci = 0; 
    165187 
    166         /* Intialise things that depend on network registration */ 
    167         if (aux->u.netreg.state == GSMD_NETREG_REG_HOME || 
    168                         aux->u.netreg.state == GSMD_NETREG_REG_ROAMING) { 
    169                 sms_cb_network_init(gsmd); 
    170         } 
    171  
    172188        return usock_evt_send(gsmd, ucmd, GSMD_EVT_NETREG); 
     189 
    173190} 
    174191 
Note: See TracChangeset for help on using the changeset viewer.