Click here to Skip to main content
15,350,008 members
Articles / Programming Languages / C#
Posted 20 Nov 2012

Tagged as


3 bookmarked

Incoming Calls Announcements

7 Jan 2013CPOL2 min read
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();

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

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

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

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
Today’s smart devices and applications have untapped potential in the realm of context-aware computing. Plantronics is making it possible for its audio devices to deliver contextual information to a range of applications through Plantronics headsets. The Plantronics Spokes SDK allows developers to create a range of business applications that will have the power to change the way we communicate and collaborate.

Please check out our DevZone for more info on the Spokes SDK:

Comments and Discussions

-- There are no messages in this forum --