smswindows-10mobile-broadband-api

How to send and receive SMS programmatically in Windows 10 using MBN?


We have a program that sends and receives SMS messages via the MBN IMbnSms interface and a 2G/3G/4G modem. Our code works in Windows 7 and Windows 8.x, but fails in Windows 10. IMbnSms.GetSmsStatus() always returns 0x8000000A (E_PENDING) error, even when the modem has been camped on a network for 10 minutes. IMbnSms.SmsSendPdu() gets E_MBN_FAILURE at the OnSmsSendComplete event.

Here is a simple test code for GetSmsStatus() that reproduces this issue:

    using MbnApi;
    using System;

    namespace GetSmsStatusTest
    {
        class Program
        {
            static void Main(string[] args)
            {
                GetSmsStatus(args[0]);
            }

            static void GetSmsStatus(string interfaceID)
            {
                try
                {
                    MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
                    IMbnInterfaceManager infManager = (IMbnInterfaceManager)mbnInfMgr;

                    //obtain the IMbnInterface passing interfaceID
                    IMbnInterface mbnInterface = infManager.GetInterface(interfaceID);
                    IMbnSms mbnSms = mbnInterface as IMbnSms;
                    if (mbnSms == null)
                    {
                        Console.WriteLine("Got no IMbnSms");
                        return;
                    }
                    MBN_SMS_STATUS_INFO mbnSmsStatusInfo;
                    mbnSms.GetSmsStatus(out mbnSmsStatusInfo);
                    Console.WriteLine("flag={0}, index={1}", mbnSmsStatusInfo.flag, mbnSmsStatusInfo.messageIndex);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }   
            }
    }

Call it with the network interface GUID that you can get with "netsh mbn sho int".


Solution

  • Microsoft solved this issue with the Windows 10 update package that I got on 7th. I retested it with several data cards, it works now.