0

I'm trying to retrieve the SignalStrength (i.e. like the info behind the bars cellular phones), but on a desktop application developed in C# .NET 4.0, that has a GSM adapter connected to it. I've managed to connect and disconnect to the service provider using RasDialer, but I can't find anyway to get the SignalStrength. I've tried MbnApi, but it runs great until I receive the connected interfaces, and after I use one of them for ANYthing, it crashes with a COM exception saying "the data necessary to complete this operation is not yet available". Here's a piece of code that crashes with this exception on the last line:

 MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
 IMbnInterfaceManager infMgr = (IMbnInterfaceManager)mbnInfMgr;

 MbnConnectionManager mbnConnectionMgr = new MbnConnectionManager();
 IMbnConnectionManager ImbnConnectionMgr = (IMbnConnectionManager)mbnConnectionMgr;

 var mobileInterface = infMgr.GetInterfaces() as IMbnInterface[];

 IMbnSignal sig = (IMbnSignal)mobileInterface[0];

 uint signalStrength = sig.GetSignalStrength();

Can anyone assist, either by explaining what I'm doing wrong with MbnApi or directing me to another alternative?

Thank you so much in advance, Yaron.

Yaron Adler
  • 492
  • 1
  • 5
  • 15

1 Answers1

0

I couldn't see any obvious errors, so I pasted your exact code into a .NET 4.0 test project, referenced MbnApi built on a Windows 8 system and ran it, and it ran fine. I got the signal strength of my integrated modem out.

I assume that in your code, you would normally have try/catch blocks, tests for null etc.

Have you investigated how many interfaces are present, and whether you really want interface[0] or another one? Also obvious things like re-booting Windows etc.

You asked about other possibilities for getting this information. When using MBN API for signal strength, you should be aware of this factor. The AT command AT+CESQ gives a more accurate value. Section 8.69 of this document describes it. There is plenty of information on SO and the internet on how to use AT commands with C# - try the at-command tag, or do a search for [c#][at-command] on SO.

Community
  • 1
  • 1
user1725145
  • 3,993
  • 2
  • 37
  • 58
  • @aldridmc AT+CESQ if supported, gives accurate values for GSM, UMTS and LTE. – user1725145 May 22 '14 at 20:38
  • Never seen this command except for in ETSI standard documents. Do you know of any modems that actually support this command? – Matt Aldridge May 23 '14 at 06:17
  • I haven't see one, but I haven't done a lot of AT command testing on different LTE modems either. But I think it's helpful to study this command anyway, because of all the options, it is actually the best designed way to get correct information. If you study the responses to this AT command, at least you know what you should be getting. For reference, the Android interface also tries to deliver correct values for different networks. – user1725145 May 26 '14 at 08:56