static void bearer_query_resp_cb(const GIsiMessage *msg, void *data) { struct isi_cb_data *cbd = data; ofono_sms_bearer_query_cb_t cb = cbd->cb; GIsiSubBlockIter iter; uint8_t sb, cs, ps; if (!check_sms(msg, SMS_SETTINGS_READ_RESP, SMS_OK)) goto error; if (!g_isi_msg_data_get_byte(msg, 1, &sb)) goto error; for (g_isi_sb_iter_init_full(&iter, msg, 2, TRUE, sb); g_isi_sb_iter_is_valid(&iter); g_isi_sb_iter_next(&iter)) { if (g_isi_sb_iter_get_id(&iter) != SMS_SB_ROUTE_INFO) continue; if (!g_isi_msg_data_get_byte(msg, 5, &cs)) goto error; if (!g_isi_msg_data_get_byte(msg, 6, &ps)) goto error; CALLBACK_WITH_SUCCESS(cb, cs_ps_pref_to_bearer(cs, ps), cbd->data); return; } error: CALLBACK_WITH_FAILURE(cb, 0, cbd->data); }
static void submit_gsm_tpdu_resp_cb(const GIsiMessage *msg, void *data) { struct isi_cb_data *cbd = data; ofono_sms_submit_cb_t cb = cbd->cb; struct sms_report *report; size_t len = sizeof(struct sms_report); GIsiSubBlockIter iter; if (!check_sms(msg, SMS_MESSAGE_SEND_RESP, -1)) goto error; for (g_isi_sb_iter_init(&iter, msg, 2); g_isi_sb_iter_is_valid(&iter); g_isi_sb_iter_next(&iter)) { if (g_isi_sb_iter_get_id(&iter) != SMS_GSM_REPORT) continue; if (!g_isi_sb_iter_get_struct(&iter, (void **) &report, len, 2)) goto error; if (report->type == SMS_CAUSE_TYPE_COMMON && report->cause == SMS_OK) { CALLBACK_WITH_SUCCESS(cb, report->ref, cbd->data); return; } submit_failure_debug(report); } error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); }
static void submit_tpdu_resp_cb(const GIsiMessage *msg, void *data) { struct isi_cb_data *cbd = data; ofono_sms_submit_cb_t cb = cbd->cb; struct sms_report *report; size_t len = sizeof(struct sms_report); if (!check_sms(msg, SMS_MESSAGE_SEND_RESP, -1)) goto error; if (g_isi_msg_data_len(msg) < len) goto error; if (!g_isi_msg_data_get_struct(msg, 0, (const void **) &report, len)) goto error; if (report->type == SMS_CAUSE_TYPE_COMMON && report->cause == SMS_OK) { CALLBACK_WITH_SUCCESS(cb, report->ref, cbd->data); return; } submit_failure_debug(report); error: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); }
static void bearer_set_resp_cb(const GIsiMessage *msg, void *data) { struct isi_cb_data *cbd = data; ofono_sms_bearer_set_cb_t cb = cbd->cb; if (check_sms(msg, SMS_SETTINGS_UPDATE_RESP, SMS_OK)) CALLBACK_WITH_SUCCESS(cb, cbd->data); else CALLBACK_WITH_FAILURE(cb, cbd->data); }
static void routing_resp_cb(const GIsiMessage *msg, void *data) { struct ofono_sms *sms = data; if (sms == NULL) return; if (!check_sms(msg, SMS_PP_ROUTING_RESP, SMS_OK)) return; ofono_sms_register(sms); }
static void reception_resp_cb(const GIsiMessage *msg, void *data) { struct ofono_sms *sms = data; if (sms == NULL) return; if (!check_sms(msg, SMS_RECEIVE_MESSAGE_RESP, SMS_RECEPTION_ACTIVE)) return; ofono_sms_register(sms); }
int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT /* Use Calibration values for 1MHz Clock DCO*/ DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; /* Configure Pin Muxing P1.1 RXD and P1.2 TXD */ P1SEL |= BIT1 | BIT2; P1SEL2 |= BIT1 | BIT2; /* Place UCA0 in Reset to be configured */ UCA0CTL1 = UCSWRST; /* Configure */ UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 104; // 1MHz 9600 UCA0BR1 = 0; // 1MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 /* Take UCA0 out of reset */ UCA0CTL1 &= ~UCSWRST; /* Enable USCI_A0 RX interrupt */ IE2 |= UCA0RXIE; /* Enable leds*/ P1DIR |= LED_GREEN + LED_RED; LED_OFF(LED_GREEN|LED_RED); /* Blink leds when reset */ blink_led(LED_RED | LED_GREEN, 5); /* Init Button */ P1REN |= BIT3; // Enable internal pull-up/down resistors P1OUT |= BIT3; //Select pull-up mode for P1.3 P1IE |= BIT3; // P1.3 interrupt enabled P1IES |= BIT3; // P1.3 Hi/lo edge P1IFG &= ~BIT3; // P1.3 IFG cleared /* Power up Sim900A */ P2DIR |= SIM_POW; power_sim(); __enable_interrupt(); if (check_status_sim()) blink_led(LED_GREEN, 5); else { blink_led(LED_RED, 5); } while (1) { if (isSendSMS) { isSendSMS = 0; send_sms("0934384878", "Hello Duong"); } if (isHasSMS) { blink_led(LED_GREEN,3); check_sms(); isHasSMS = 0; isSimSendData = 0; index_reic = 0; data_prev = 0; data_current = 0; } } }
static void report_resp_cb(const GIsiMessage *msg, void *data) { if (!check_sms(msg, SMS_RECEIVED_MSG_REPORT_RESP, SMS_OK)) DBG("Sending report failed"); }