Beispiel #1
0
        public CellTower getTowerInfo()
        {
            IntPtr radioInterfaceLayerHandle = IntPtr.Zero;
            IntPtr radioResponseHandle = IntPtr.Zero;

            // Initialize the radio layer with a result callback parameter.
            radioResponseHandle = RIL_Initialize(1, new RILRESULTCALLBACK(CellDataCallback),
                null, 0, 0, out radioInterfaceLayerHandle);

            // The initialize API call will always return 0 if initialization is successful.
            if (radioResponseHandle != IntPtr.Zero)
            {
                return null;
            }

            // Query for the current tower data.
            radioResponseHandle = RIL_GetCellTowerInfo(radioInterfaceLayerHandle);

            // Wait for cell tower info to be returned since RIL_GetCellTowerInfo invokes the
            // callback method asynchronously.
            waithandle.WaitOne();

            // Release the RIL handle
            RIL_Deinitialize(radioInterfaceLayerHandle);

            // Convert the raw tower data structure data into a CellTower object
            CellTower ct = new CellTower();
            ct.setTowerId(Convert.ToInt32(_towerDetails.dwCellID));
            ct.setLocationAreaCode(Convert.ToInt32(_towerDetails.dwLocationAreaCode));
            ct.setMobileCountryCode(Convert.ToInt32(_towerDetails.dwMobileCountryCode));
            ct.setMobileNetworkCode(Convert.ToInt32(_towerDetails.dwMobileNetworkCode));

            return ct;
        }