ril-qmi string support & fidl files
Change-Id: I47a4a4ddcabb9515139a6aa0fe6c3cb229c19ac5
diff --git a/bin/telephony/ril-qmi/src/client.rs b/bin/telephony/ril-qmi/src/client.rs
index 3fc252e..d464ba1 100644
--- a/bin/telephony/ril-qmi/src/client.rs
+++ b/bin/telephony/ril-qmi/src/client.rs
@@ -66,8 +66,8 @@
}
if request_id {
use qmi_protocol::CTL::{GetClientIdReq, GetClientIdResp};
- let resp: QmiResult<GetClientIdResp> = await!(self.send_msg_actual(GetClientIdReq::new(0)))?;
- eprintln!("res: {:?}", resp);
+ fx_log_info!("allocating a client ID for service: {}", svc_id.0);
+ let resp: QmiResult<GetClientIdResp> = await!(self.send_msg_actual(GetClientIdReq::new(svc_id.0)))?;
let client_id_resp = resp.unwrap(); // TODO from trait for QmiError to QmuxError
let mut map = self.clients.write();
assert_eq!(client_id_resp.svc_type, svc_id.0);
@@ -135,7 +135,7 @@
msg_buf.extend(payload_bytes);
let bytes = msg_buf.freeze();
- eprintln!("byte payload {:X?}", bytes.as_ref());
+ // eprintln!("byte payload {:X?}", bytes.as_ref());
if let Some(ref transport) = self.inner.transport_channel {
if transport.is_closed() {
@@ -151,7 +151,7 @@
transport: Some(self.inner.clone())
})?;
- eprintln!("response {:?}", resp);
+ // eprintln!("response {:?}", resp);
let buf = std::io::Cursor::new(resp.bytes());
let decoded = D::from_bytes(buf);
diff --git a/bin/telephony/ril-qmi/src/main.rs b/bin/telephony/ril-qmi/src/main.rs
index f13c472..1c44e59 100644
--- a/bin/telephony/ril-qmi/src/main.rs
+++ b/bin/telephony/ril-qmi/src/main.rs
@@ -14,6 +14,7 @@
use failure::{Error, ResultExt};
use fidl::endpoints::{RequestStream, ServerEnd, ServiceMarker};
use fidl_fuchsia_telephony_ril::{RadioInterfaceLayerMarker, RadioInterfaceLayerRequest, RadioInterfaceLayerRequestStream};
+use fidl_fuchsia_telephony_ril::RadioPowerState;
use fuchsia_app::server::ServicesServer;
use fuchsia_async as fasync;
use fuchsia_syslog::{self as syslog, macros::*};
@@ -79,7 +80,7 @@
if let Some(ref inner) = self.inner {
let transport_inner = inner.clone();
let client = QmiClient::new(transport_inner);
- Ok(client) // Arc::new(RwLock::new(client)))
+ Ok(client)
} else {
Err(QmuxError::NoClient.into())
}
@@ -113,34 +114,41 @@
if client_lock.is_none() {
fx_log_info!("Requested client connect.");
- eprintln!("strong count: {}", Arc::strong_count(&client));
- let modem_lock = modem.lock();
-
// TODO RIL Error type
- //if !lock.connected() {
- // return responder.send(false);
- //}
- //let client = client.lock();
+ let modem_lock = modem.lock();
+ let alloced_client = await!(modem_lock.create_client()).unwrap();
+ *client_lock = Some(alloced_client);
+ }
+
+ if let Some(ref client) = *client_lock {
+ let resp: QmiResult<DMS::GetDeviceSerialNumbersResp> =
+ await!(client.send_msg(DMS::GetDeviceSerialNumbersReq::new())).unwrap();
+ return responder.send(&resp.unwrap().imei);
+ }
+ responder.send("none")
+ }
+ RadioInterfaceLayerRequest::RadioPowerStatus { responder } => {
+ let mut client_lock = client.lock();
+
+ if client_lock.is_none() {
+ fx_log_info!("Requested client connect.");
+ // TODO RIL Error type
+ let modem_lock = modem.lock();
let alloced_client = await!(modem_lock.create_client()).unwrap();
*client_lock = Some(alloced_client);
}
if let Some(ref client) = *client_lock {
fx_log_info!("send serial request!");
- //let resp: Result<QmiResult<DMS::GetDeviceSerialNumbersResp>, QmuxError>
- // = await!(client.send_msg(DMS::GetDeviceSerialNumbersReq::new()));
- //fx_log_info!("Device serial numbers resp: {:?}", resp);
- //let resp: Result<QmiResult<CTL::GetVersionInfoResp>, QmuxError>
- // = await!(client.send_msg(CTL::GetVersionInfoReq::new()));
- //fx_log_info!("Device version info {:?}", resp);
+ let resp: DMS::GetOperatingModeResp =
+ await!(client.send_msg(DMS::GetOperatingModeReq::new())).unwrap().unwrap();
+ if (resp.operating_mode == 0x00) {
+ return responder.send(RadioPowerState::On);
+ } else {
+ return responder.send(RadioPowerState::Off);
+ }
}
-
- // if client.is_ok() {
- // QmiClientService::spawn(channel, client.unwrap());
- // responder.send(true)
- // } else {
- responder.send(3)
- // }
+ responder.send(RadioPowerState::Off)
}
}
}
diff --git a/bin/telephony/ril-qmi/src/transport.rs b/bin/telephony/ril-qmi/src/transport.rs
index f0a366f..1af624d 100644
--- a/bin/telephony/ril-qmi/src/transport.rs
+++ b/bin/telephony/ril-qmi/src/transport.rs
@@ -114,13 +114,18 @@
let ctrl_flags = buf.get_u8();
let svc_type = buf.get_u8();
let client_id = buf.get_u8();
- let svc_ctrl_flags = buf.get_u8();
+ let svc_ctrl_flags;
let transaction_id;
+ // TODO(bwb): Consider passing these paramaters in from the Decodable trait'd object,
+ // more generic than a hardcode for CTL interfaces
if (svc_type == 0x00) {
+ svc_ctrl_flags = buf.get_u8();
// ctl service is one byte
transaction_id = buf.get_u8() as u16;
} else {
+ svc_ctrl_flags = buf.get_u8() >> 1;
transaction_id = buf.get_u16_le();
+ // The bits for the ctrl flags are shifted by one in non CTL messages
}
(QmuxHeader {
length,
@@ -203,10 +208,10 @@
Poll::Ready(Err(e)) => return Err(QmuxError::ClientRead(e)),
Poll::Pending => return Ok(false),
}
- eprintln!("recieved msg: {:X?}", buf.bytes());
let buf = Cursor::new(buf.bytes());
let (header, buf) = parse_qmux_header(buf);
+ eprintln!("recieved msg: {:#?}", header);
// TODO add indication support here, only handles responses for now
// This is a response for ONLY the CTL interface, will need indication support
// just throw them away for now
diff --git a/public/fidl/fuchsia.telephony.ril/ril.fidl b/public/fidl/fuchsia.telephony.ril/ril.fidl
index ca506be..9605e5e 100644
--- a/public/fidl/fuchsia.telephony.ril/ril.fidl
+++ b/public/fidl/fuchsia.telephony.ril/ril.fidl
@@ -4,6 +4,12 @@
library fuchsia.telephony.ril;
+/// Power State of the radio
+enum RadioPowerState: uint8 {
+ OFF = 0x00;
+ ON = 0x01;
+};
+
/// The Standard Fuchsia RIL (FRIL)
interface RadioInterfaceLayer {
/// Connect to the underlying transport |channel|. Most modems will require this
@@ -11,8 +17,10 @@
/// not per client connection.
100: ConnectTransport(handle<channel> channel) -> (bool success);
- // TODO more complex identity type
+ // TODO more complete identity type
/// Retrieve the identity of the modem (currently |imei| only)
- 200: GetDeviceIdentity() -> (uint64 imei);
+ 200: GetDeviceIdentity() -> (string imei);
+
+ 201: RadioPowerStatus() -> (RadioPowerState state);
};