AT: Better failure handling and removed wrong unlock
[hayes-ril.git] / power.c
diff --git a/power.c b/power.c
index a497629..50ab7a9 100644 (file)
--- a/power.c
+++ b/power.c
@@ -62,37 +62,19 @@ int at_cfun_disable_expect(struct at_response *response, void *data, RIL_Token t
 
 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);
-
-       // 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_expect);
+
+       ril_device_at_power_on(ril_device);
 }
 
 void ril_power_off(void)
 {
+       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);
 }
 
@@ -103,12 +85,12 @@ 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();
        }
 
-       // Send AT+CPIN
-       at_send_expect_to_func("AT+CPIN?", NULL, NULL, 0x0000, at_cpin_expect);
-
        RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
 }