introduce new "Cell Info" Event

This commit is contained in:
Harald Welte 2012-06-01 21:58:06 +02:00
parent eaea30c774
commit b0c5b8a269
3 changed files with 19 additions and 0 deletions

View File

@ -19,6 +19,7 @@ enum gsmd_events {
GSMD_EVT_IN_CBM = 14, /* Incoming Cell Broadcast message */
GSMD_EVT_IN_DS = 15, /* SMS Status Report */
GSMD_EVT_IN_ERROR = 16, /* CME/CMS error */
GSMD_EVT_CELLINFO = 17, /* Cell Information (MCC/MNC/LAC/CI) */
__NUM_GSMD_EVT
};

View File

@ -519,6 +519,15 @@ struct gsmd_evt_auxdata {
char alpha[GSMD_ALPHA_MAXLEN+1];
u_int8_t cli;
} ccwa;
struct {
u_int16_t mcc;
u_int16_t mnc;
u_int16_t lac;
u_int16_t ci;
u_int8_t bsic;
u_int16_t arfcn;
u_int8_t rxlev;
} cell_info;
} u;
u_int8_t data[0];
} __attribute__ ((packed));

View File

@ -253,6 +253,14 @@ static int error_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdat
return 0;
}
static int cinfo_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
{
printf("EVENT: Cell Info: %03u-%03u-%04x-%04x @ %04u (%02u)\n",
aux->u.cell_info.mcc, aux->u.cell_info.mnc, aux->u.cell_info.lac,
aux->u.cell_info.ci, aux->u.cell_info.arfcn, aux->u.cell_info.rxlev);
return 0;
}
int event_init(struct lgsm_handle *lh)
{
int rc;
@ -268,6 +276,7 @@ int event_init(struct lgsm_handle *lh)
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_OUT_STATUS, &cprog_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_IN_ERROR, &error_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_CALL_WAIT, &ccwa_handler);
rc |= lgsm_evt_handler_register(lh, GSMD_EVT_CELLINFO, &cinfo_handler);
return rc;
}