Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Incoming Calls Announcements

7 Jan 2013 1  
There are several events and cool information you can get from the devices and how they are being used.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

 

There are several events and cool information that you can get from Plantronics devices and how they are being used.

For example, an easy one to implement yet, it tells you a lot already, are the Don/Doff events (used in my previous post) that fire when the user puts the headset one or removes it from their ear/head.

In this example, I'm leveraging a post by Ramesh on caller ID and integrating it with the Skype API and with the Microsoft Speech API, to play announcements on incoming Skype calls and messages, as well as incoming mobile calls.

First, I'll start with the announcements portion, which can be as simple as:

void Speak (String message)
{
     SpVoice Voice = new SpVoice();
     Voice.Speak(message);
}

Now, for the Skype portion, similar to the Spokes events, you must register to receive them:

            Skype skype = new Skype();
            if (!skype.Client.IsRunning)
            {
                skype.Client.Start();
            }

            ((_ISkypeEvents_Event)skype).CallStatus += new _ISkypeEvents_CallStatusEventHandler(SkypeCallStatusEventHandler);
            ((_ISkypeEvents_Event)skype).MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(SkypeMessageStatusEventHandler);
            skype.Attach();

Now connecting some of the other dots, for the incoming Skype calls and messages:

...
       SkypeCallStatusEventHandler(Call call, TCallStatus status)
...
            if (status == TCallStatus.clsRinging && 
                (call.Type == TCallType.cltIncomingP2P || call.Type == TCallType.cltIncomingPSTN))
                Speak(String.Format("Incoming call from {0}", call.PartnerDisplayName));

            
...
        SkypeMessageStatusEventHandler(ChatMessage message, TChatMessageStatus status)
...
            if (status == TChatMessageStatus.cmsReceived)
                Speak(String.Format("Incoming message from {0}", message.FromDisplayName));

And the same for the Spokes mobile incoming calls announcements:

           IATDCommand cmd = m_device.HostCommand as IATDCommand;
           String callerId = cmd.CallerID;
          Speak(String.Format("Incoming mobile call from {0}", callerId));

And an extra nice step to make sure the announcements are only played when the user has the device on we log the current state of the device:

           if (e.HeadsetStateChange == HeadsetStateChange.Don)  
               m_Don = true;  
           else if (e.HeadsetStateChange == HeadsetStateChange.Doff)  
               m_Don = false;

Now, lets use that in our Speak method to only speak when the device is on.

void Speak(String message)
{
     if (m_Don)
     {
...

     }
}

That's all there's to it. Pretty straight forward and tells you who's calling you without the need for you to pull your mobile out of your pocket or have to look at your screen. Just press answer from the device itself and you're set.

Now, go ahead and implement your own butler for when you put your headset in the morning to tell you about the weather for the day, your calendar and how's traffic for your commute -- or anything else that may be important to you like saying how awesome you are every morning.

This article was written by Ricardo de Andrade. Ricardo is a Systems Architect and Evangelist at Plantronics helping the developer community, clients and partners with the Spokes SDK and building solutions around current and future offerings. Ricardo has an extensive background in software and cloud distributed architectures, and in specific telecommunications. Ricardo previously worked for Microsoft where he helped clients and partners to develop cloud based speech recognition applications and integrate their web services into the Microsoft Tellme services.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here