*
* Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr>
*
- * Based on htcgeneric-ril, reference-ril:
+ * Parts of this code are based on htcgeneric-ril, reference-ril:
* Copyright 2006-2011, htcgeneric-ril contributors
* Copyright 2006, The Android Open Source Project
*
#include <hayes-ril.h>
-int at_cfun_enable(struct at_response *response, void *data, RIL_Token t)
+int at_cfun_enable_expect(struct at_response *response, void *data, RIL_Token t)
{
if(response->status == AT_STATUS_UNDEF)
return AT_RESPONSE_UNHANDELD_REASON_STATUS;
return AT_RESPONSE_HANDLED_OK;
}
-int at_cfun_disable(struct at_response *response, void *data, RIL_Token t)
+int at_cfun_disable_expect(struct at_response *response, void *data, RIL_Token t)
{
if(response->status == AT_STATUS_UNDEF)
return AT_RESPONSE_UNHANDELD_REASON_STATUS;
void ril_power_on(void)
{
- int status;
-
LOGD("Powering on");
- // Echo enabled, send results, verbose enabled
- at_send_expect_status("ATE1Q0V1", NULL);
-
- // Extended errors
- at_send_expect_status("AT+CMEE=1", NULL);
-
- // Detailed rings, service reporting
- at_send_expect_status("AT+CRC=1;+CR=1", NULL);
-
- // SMS PDU mode
- at_send_expect_status("AT+CMGF=0", NULL);
-
- // SMS PDU mode
- at_send_expect_status("AT+CMGF=0", NULL);
+ at_send_expect_to_func("AT+CFUN=1", NULL, NULL, 0x0000, at_cfun_enable_expect);
- // Network registration notifications
- status = at_send_expect_status("AT+CREG=2", NULL);
- if(at_status_error(status)) {
- LOGD("Modem doesn't support AT+CREG=2");
- at_send_expect_status("AT+CREG=1", NULL);
- }
-
- at_send_expect_to_func("AT+CFUN=1", NULL, NULL, 0x0000, at_cfun_enable);
+ ril_device_at_power_on(ril_device);
}
void ril_power_off(void)
{
- at_send_expect_to_func("AT+CFUN=0", NULL, NULL, 0x0000, at_cfun_disable);
+ LOGD("Powering off");
+
+ ril_device_at_power_off(ril_device);
+
+ at_send_expect_to_func("AT+CFUN=0", NULL, NULL, 0x0000, at_cfun_disable_expect);
}
void ril_request_radio_power(RIL_Token t, void *data, size_t length)
if(power_state > 0) {
ril_power_on();
+
+ // Ask for PIN status
+ at_send_expect_to_func("AT+CPIN?", NULL, NULL, 0x0000, at_cpin_expect);
} else {
ril_power_off();
}