2

How can I programatically illuminate Cisco IP Phones Visual message waiting indicator (VMWI or MWI) ?

For sipwiz Answer:

IP Adress 10.1.1.2 => is local IP in which I will send SIP Notify Message

IP Address 10.1.1.9 => is IP Address of Cisco Phone that I will send SIP Message

The Cisco Phone that I send SIP Message does "care" my messages, and I got exception while i try to get response messge from Cisco Phone :"An existing connection was forcibly closed by the remote host".

Actully it does not seem to right to directly send an SIP message to Cisco Phone to change its behaviour.Because it is open to many security violations.And I think Cisco will not allow this.

"sipwiz" do I need to do extra configuration on Cisco Phone to make this feature work? Do you actually able to make it work on a real Cisco Phone? If so, what kind of extra config yo do on the Phone?

Hippias Minor
  • 1,917
  • 2
  • 21
  • 46

1 Answers1

3

Below is some crude code that constructs a dummy SIP NOTIFY request that can be sent to a Cisco IP Phone (only tested with a Cisco 7960) that will allow the visual Message Waiting Indicator to be set and unset.

You will need to change the sip:user@server.com to a SIP URI that your Cisco phone recognises. And also of course adjust the IP addresses and ports as required.

Update: Updated the code sample to make it a bit clearer where the IP addresses need to go in the SIP request.

using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Cisco MWI Test Console:");

        string setMWIRequest =
            "NOTIFY {0} SIP/2.0\r\n" +
            "Via: SIP/2.0/UDP {1}:{2};branch=z9hG4bK{3}\r\n" +
            "To: <{0}>\r\n" +
            "From: <{0}>\r\n" +
            "Call-ID: {4}\r\n" +
            "CSeq: 1 NOTIFY\r\n" +
            "Max-Forwards: 70\r\n" +
            "Contact: {1}:{2}\r\n" +
            "Content-Length: {5}\r\n" +
            "Content-Type: application/simple-message-summary\r\n" +
            "Event: message-summary\r\n" +
            "\r\n" +
            "{6}";

        string mwiBody = "Messages-Waiting: no"; // Change to no to unset MWI.

        var localSIPEP = new IPEndPoint(IPAddress.Parse("192.168.33.116"), 5091);
        Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        udpSocket.Bind(localSIPEP);

        setMWIRequest = String.Format(setMWIRequest, "sip:user@server.com", localSIPEP.Address.ToString(), localSIPEP.Port, Guid.NewGuid().ToString().Replace("-", ""), Guid.NewGuid().ToString().Replace("-", ""), mwiBody.Length, mwiBody);

        byte[] buffer = Encoding.UTF8.GetBytes(setMWIRequest);

        Console.WriteLine("Sending to Cisco:");
        Console.WriteLine(setMWIRequest);

        udpSocket.SendTo(buffer, new IPEndPoint(IPAddress.Parse("192.168.33.155"), 5060));

        byte[] recvBuffer = new byte[4096];
        int bytesRead = udpSocket.Receive(recvBuffer);

        Console.WriteLine(Encoding.UTF8.GetString(recvBuffer.Take(bytesRead).ToArray()));

        Console.ReadLine();
    }
}
sipsorcery
  • 30,273
  • 24
  • 104
  • 155
  • Thanks sipwiz. But it does not seem to work in my case. Can see more details on my question. – Hippias Minor Jan 27 '14 at 12:20
  • I tested on my Cisco 7941 work phone and it works. You must have the SIP firmware installed on your Cisco phone for it to work. If you have the default Cisco Call Manager software then SIP requests will not be understood by the phone. Apart from that no special configuration is required on the phone and there is no additional security around the phone accepting SIP NOTIFY requests. – sipsorcery Jan 28 '14 at 00:08
  • I have Cisco 7942.Will try to install SIP firmware and check – Hippias Minor Jan 28 '14 at 08:57
  • It seems that I have no chance to install SIP firmware to each Cisco Phones. – Hippias Minor Jan 30 '14 at 08:51
  • 1
    I should have to do with Cisco API. But you got bounty: since seems that no one interested in my question.... – Hippias Minor Jan 30 '14 at 08:53
  • In fairness you did tag the question with "SIP" which would indicate you were using your Cisco phone with a SIP firmware. I wouldn't have provided an answer if you hadn't wanted a SIP solution as I've no idea how to do it using Skinny or if there is even any kind of web API on the phones (I don't believe there is but have never looked into it). – sipsorcery Jan 30 '14 at 09:15