From 10f2cdebcb23e608d41d4fceea0abe4e5b74b795 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 13 Apr 2013 15:52:30 +0200 Subject: broadband-modem-mbim: process signal state indications --- src/mm-broadband-modem-mbim.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index cad53173..cc55fc2c 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -1359,11 +1359,57 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self, /*****************************************************************************/ /* Setup/cleanup unsolicited events */ +static void +basic_connect_notification_signal_state (MMBroadbandModemMbim *self, + MbimMessage *notification) +{ + guint32 rssi; + + if (mbim_message_signal_state_notification_parse ( + notification, + &rssi, + NULL, /* error_rate */ + NULL, /* signal_strength_interval */ + NULL, /* rssi_threshold */ + NULL, /* error_rate_threshold */ + NULL)) { + guint32 quality; + + /* Normalize the quality. 99 means unknown, we default it to 0 */ + quality = CLAMP (rssi == 99 ? 0 : rssi, 0, 31) * 100 / 31; + + mm_dbg ("Signal state indication: %u --> %u%%", rssi, quality); + mm_iface_modem_update_signal_quality (MM_IFACE_MODEM (self), quality); + } +} + +static void +basic_connect_notification (MMBroadbandModemMbim *self, + MbimMessage *notification) +{ + switch (mbim_message_indicate_status_get_cid (notification)) { + case MBIM_CID_BASIC_CONNECT_SIGNAL_STATE: + basic_connect_notification_signal_state (self, notification); + break; + default: + /* Ignore */ + break; + } +} + static void device_notification_cb (MbimDevice *device, MbimMessage *notification, MMBroadbandModemMbim *self) { + switch (mbim_message_indicate_status_get_service (notification)) { + case MBIM_SERVICE_BASIC_CONNECT: + basic_connect_notification (self, notification); + break; + default: + /* Ignore */ + break; + } } static gboolean -- cgit v1.2.3