C# interface to a Alcatel-Lucent OmniPCX Office system

Post Reply
G-HART
Member
Posts: 13
Joined: 27 Jun 2019 15:34

C# interface to a Alcatel-Lucent OmniPCX Office system

Post by G-HART »

Hello,

I'm trying to create an interface that will allow my Company's software to interrogate the phones, change their status etc as well as record calls logged for bill purposes.

While the O.L.D driver is I metering mode, I have created an application that monitors TicketCollecotr.xml, and pulls the information out.
What I need to do now is expand on this, so that when the driver is in hotel mode, I can get the call data, but also send Handset commands ( changed the name on the display, block/unblock the handset etc .

with the code (below) and the driver in hotel mode, I can make a connection to port 2561 and send data, but I get no response back. On looking at the log.txt file, I see the data arriving, and then

Thu Sep 08 13:10:54 2022 WARN 32320 AlcAHLLinkLayer::extractMessage : 34 unexpected bytes received, ignored

I've tried with messagesent = (STX)@FFFF(ETX) , but get a simial error ( Less unexcepted bytes ) .


Can anyone expand on what the error means ? do I need to send something prior ? What am I doing wrong ?

Any help is grateful :-)

Thank you

Code: Select all

    public static async Task Main()
    {
        string barfpath = (@"barf.log");

        Int32 port = 2561;
        IPAddress ipAddr = IPAddress.Parse("127.0.0.1");

        try
        {
            // Establish the remote endpoint for the socket.
            IPEndPoint localEndPoint = new IPEndPoint(ipAddr, port);

            // Creation TCP/IP Socket using Socket Class Constructor
            Socket sender = new Socket(ipAddr.AddressFamily,
                       SocketType.Stream, ProtocolType.Tcp);

            try
            {
                // Connect Socket to the remote endpoint using method Connect()
                sender.Connect(localEndPoint);

                // We print EndPoint information that we are connected
                Console.WriteLine("Socket connected to -> {0} ",
                              sender.RemoteEndPoint.ToString());
                System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Socket connected to -> " + sender.RemoteEndPoint.ToString() + "... " + Environment.NewLine);

                // Creation of message that we will send to Server
                byte[] messageSent = Encoding.ASCII.GetBytes("0x02 0x40 0x46 0x46 0x46 0x46 0x03");
                int byteSent = sender.Send(messageSent);

                // Data buffer
                byte[] messageReceived = new byte[1024];

                // We receive the message using the method Receive(). This method returns number of bytes
                // received, that we'll use to convert them to string
                int byteRecv = sender.Receive(messageReceived);
                Console.WriteLine("Message from Server -> {0}",
                      Encoding.ASCII.GetString(messageReceived,
                                                 0, byteRecv));
                System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Message from Server -> " + Encoding.ASCII.GetString(messageReceived,0, byteRecv) + Environment.NewLine);

                // Close Socket using the method Close()
                sender.Shutdown(SocketShutdown.Both);
                sender.Close();
            }

            // Manage of Socket's Exceptions
            catch (ArgumentNullException ane)
            {
                Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
                System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - ArgumentNullException " + ane.ToString() + Environment.NewLine);
            }

            catch (SocketException se)
            {
                Console.WriteLine("SocketException : {0}", se.ToString());
                System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - SocketException " + se.ToString() + Environment.NewLine);
            }

            catch (Exception e)
            {
                Console.WriteLine("Unexpected exception : {0}", e.ToString());
                System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Unexpected exception " + e.ToString() + Environment.NewLine);
            }
        }

        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
            System.IO.File.AppendAllText(barfpath, DateTime.Now.ToString() + " - Mains Unexpected exception " + e.ToString() + Environment.NewLine);
        }
    }
Untitled.png
You do not have the required permissions to view the files attached to this post.
sadim
Alcatel Unleashed Certified Guru
Alcatel Unleashed Certified Guru
Posts: 692
Joined: 02 Jun 2006 07:11
Location: Portugal

Re: C# interface to a Alcatel-Lucent OmniPCX Office system

Post by sadim »

Hi,
The problem is that what you are sending the initial string in text "0x02 0x40 0x46 0x46 0x46 0x46 0x03" and not the hex values of stx, @, ...
You can try changing your code to:
....
byte[] messageSent = { 0x02, '@', 'F', 'F', 'F', 'F', 0x03 };
....

BRegards
Post Reply

Return to “AHL / OHL”