Git Product home page Git Product logo

atapi.net's People

Contributors

flensrocker avatar markjulmar avatar portison avatar qdaniel avatar ssedlmaier avatar vfabregat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atapi.net's Issues

Trouble getting a SIP Device

Hi, I am working using the atapi 64 bit dll and using it to query the CUCM 11.5 system for lines. However, I only see the lines associated with Cisco devices, not SIP devices. Any ideas why this maybe?

My configuration settings in the CUCM admin part is exactly the same for all 3 devices and my SIP Device can "talk" and "call" the other devices OK. I have associated a line, device and unique user to the SIP device, similar to the other ones.

_tapiManager = new TapiManager("Hills.CiscoCallManager");
                
                _tapiManager.LineAdded += this._tapiManager_LineAdded;
                _tapiManager.LineRemoved += this._tapiManager_LineRemoved;

                Logger.Info("Initialising Tapi Manager..");
                var pass = _tapiManager.Initialize();

// now when I query the Lines Property, I do not see the SIP Device in there.

thanks,
Randeep

Can't find phones in a line.

... ...
int numLines = InitializeLineDevices();
int numPhones = InitializePhoneDevices();
... ...

above, one line has more than one phone.
But the "numPhones = 0" , why?
I'd like to know the reason. And when incoming call, the called id is line's id.
I wanna know the exact phone number, not line id.
I wish your help. Thank you!

64 and 32 bit builds

Hi all,
It rather a question than an issue, I've just wanted to understand what issues can be faced if I compile and use the library in AnyCPU configuration? I tried, and there is no any compilation issues. I used the compiled assembly in both 32 and 64 bit applications to query USB modems, and didn't noticed any issues either...

I didn't found any other place to post this question, so sorry if it is not a right place.

Shutdown fails, if Initialize fails because of no lines and no phones

Shutdown wants to join the _workerThread, but this thread has never been started, if there are no lines and no phones.

Maybe _workerThread.ThreadState should be tested on ThreadState.Unstarted. Otherwise there is a ThreadStateException in Dispose or if I explicitly Shutdown the TapiManager on app-shutdown.

tapiManager.Initialize() is alwayse false!

hi men.
as you told me in past issues i install tsp and connected it to my panasonic kx-ns500 pbx.
its seems connected succesfully and have send and recieve data in tsp monitor.
but when i run your test projects (Tcmon and phone) tapiManager.Initialize() is allwayse false.
i cant find any part of your code that you set ip and port of pbx. how can i config your test project to run on my pbx?

thank you.

lineGenerateTone failed; "The operation is not supported by the underlying service provider"

Error code is 0xFFFFFFFF80000049

This happens if I try to generate a custom tone. Is this a limitation of the modem, or a problem with how I'm using the function? I can dial a number normally when placing a call, but can't dial numbers once the call is running.

EDIT: Same for lineGenerateDigits! I need to be able to send DTMF tones during a call (e.g. "press 1 to..." continue in menus), so how am I supposed to do this?

The modem reports "InteractiveVoice | DataModem" as its capabilities. Are more capabilities needed to produce custom tones?

[BUG] Ringing event does not fire

This is when leveraging the DLL in other code (sample code seems to work fine):

Neither the TapiManager nor the open line will fire off their Ringing events. If I manually pick up the call, it will connect, but I'm unable to rely on being told when the line is ringing.

I can place calls and dial, so everything is initialized correctly to my knowledge.

Possible ObjectDisposedException on starting a call - SafeHandle may have been disposed

On starting a new call, the used SafeHandle might be already closed on calling GatherCallStatus. This might have happened in the GatherCallInfo method, which is called in TapiCall ctor before GatherCallStatus. In a certain case, the handle is deallocated in that method.

System.ObjectDisposedException: Safe handle has been closed
bei System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
bei System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
bei JulMar.Atapi.Interop.NativeMethods.lineGetCallStatus(HTCALL hCall, IntPtr lpCallStatus)
bei JulMar.Atapi.TapiCall.GatherCallStatus()
bei JulMar.Atapi.TapiCall..ctor(TapiAddress addrOwner, UInt32 hCall)
bei JulMar.Atapi.TapiAddress.MakeCall(String address, Int32 countryCode, MakeCallParams param)

Exception while using GetRelatedConferenceCalls() from within OnCallStateChange() callback

Hi @markjulmar,

We are using ATAPI to monitor Cisco phones. During a conference scenario we are sporadically getting an issue where ATAPI reported zero calls on monitored line although there was a call on physical phone. After adding logs in ATAPI source we found a race condition for updating the TapiCall::CallsMap dictionary. Log file : ATAPI_Logs_Log4net.txt
Below is the scenario:

  • A call is delivered on monitored line.
  • Answer the call
  • The calling party adds this call to conference
  • On getting OnCallStateChange callback with state as Conferenced, from within the callback we call the GetRelatedConferenceCalls to see all calls in the conference on the line.

From the logs/source code of GetRelatedConferenceCalls, we can see that this function created a new TapiCall and added to CallsMap. Soon, the LineCallback recceived TapiEvent.LINE_APPNEWCALL which also tried to add a new TapiCall to CallsMap but got exception "An item with the same key has already been added." As a result of this exception, TapiAddress::HandleNewCall was not called and there was no entry made in TapiAddress::_calls. So in the logs we still see the total call count =2 instead of 3 after call is added to conference: Log snippet : "hCall-66515 On LineId-515-TotalCallCount-2".
When the conferencing party drops out, the ATAPI library reported zero calls on line 515 as it missed this new call due to the exception.

Proposed changes:

  • Create a new function TapiCall::FindOrCreateCallByHandle to be used from TapiCall::GetRelatedConferenceCalls() and TapiLine::LineCallback() which locks the CallsMap and creates a new TapiCall if there is not already.
  • When calling GetRelatedConferenceCalls(), we sometimes saw call GUID as all zeros string. To fix this we need to update the TapiCall constructor to add the call to CallsMap at the very end.
  • TapiAddress::AddCall() needs to first check if there is a call with GUID already present before adding an entry to the _calls list.
  • Add try-catch block and traces to help debugging

These changes are in our local repo. I'm not able to create a branch on markjulmar/atapi.net to post the changes for your review.
image

Could you please share the information on submitting a pull-request to this repo ?

Best Regards,
Adinath

Main UI thread deadlocks when using WaitAny

After getting the latest release of ATAPI.dll
I have increased number of UI thread deadlocks because of this line
switch (WaitHandle.WaitAny(arrWait))
in ProcessTapiMessages()

(.net framework 4.8 win form application in a STA thread)

Tapi restart line monitor

We have a problem with our network and Panasonic tapi service provider status become disconnected is there a way to detect that and re register the lines?

No call events for newly created lines

Hi, This issue was originally submitted on Codeplex, but I see it is still an issue in the latest version on GitHub. This issue had me scratching my head for a while back in 2016. The suggested change below is now part of my standard ATAPI build and running live with a number of different phone systems - although we have only found it to be a major issue on Cisco CUCM (tested with CUCM 9.x, 10.x and 11.x) with extension mobility.

Original Codeplex Issue Text below:-

Lines added after the initial ATAPI initialisation do not fire any call events, although the lines are controllable.

The fix for this issue is a code change to register the TapiManager event handlers immediately following creation of the new TAPILine in TapiManager.ProcessTapiMessage.

This is tested against CUCM 9.1 where lines are removed and added when mobility users log-out and log-in to handsets.

TapiManager.cs:

case TapiEvent.LINE_CREATE:
{
	var newLine = new TapiLine(this, msg.dwParam1.ToInt32());

	// Change to add event handler registration
	newLine.NewCall += HandleNewCall;
	newLine.CallStateChanged += HandleCallStateChanged;
	newLine.CallInfoChanged += HandleCallInfoChanged;
	newLine.AddressChanged += HandleAddressChanged;
	newLine.Changed += HandleLineChanged;
	newLine.Ringing += HandleLineRinging;
	// End of change

	lock (_lineArray)
	{
	_lineArray.Add(newLine);
	}
	if (LineAdded != null)
	LineAdded(this, new LineAddedEventArgs(newLine));
}
break;

NuGet package no longer targets .NET 4.0

Hello.

I'm trying to update ATAPI from v. 2013.1.4 to last stable 2018.3.9 but I get an error about the target .NET framework (in my project, I'm still using .NET 4.0). Following is the error:

Could not install package 'ATAPI 2018.3.9'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I see that currently you're targeting .NET 4.6. Please can you confirm me that ATAPI requires at least .NET 4.6? If not, is it possible to target also previous versions (and .NET 4.0 in particular)?

Thank you.

ArgumentOutOfRangeException while getting forwarding information on TAPI < 3.1

How to reproduce

  1. Subscribe to a TAPI line that negotiates version < 3.1
  2. Set up that line to forward calls to a number having less than 3 digits
  3. Try invoking the getter of property JulMar.Atapi.AddressStatus.ForwardingInformation

The result will be an ArgumentOutOfRangeException:

Exception in user work item (PID=3244): System.ArgumentOutOfRangeException: 
Requested range extends past the end of the array.
   at System.Runtime.InteropServices.Marshal.CopyToNative(Object source, Int32 startIndex, IntPtr destination, Int32 length)
   at JulMar.Atapi.AddressStatus.get_ForwardingInformation()

Quick analysis

TAPI LINEFORWARD structure has changed since version 3.1, adding two new fields (dwCallerAddressType and dwDestAddressType).

Anyway, if the negotiated version is < 3.1, those two fields will not be in the TAPI message:

12:11:01.642 |   TSPI_lineGetAddressStatus() 
            TSPI_lineGetAddressStatus returns = 0x00000000
            lpAddressStatus->dwNumInUse = 1
            lpAddressStatus->dwNumActiveCalls = 0
            lpAddressStatus->dwNumOnHoldCalls = 0
            lpAddressStatus->dwNumOnHoldPendCalls = 0
            lpAddressStatus->dwAddressFeatures = 0x00001003
            lpAddressStatus->dwNumRingsNoAnswer = 0
            lpAddressStatus->dwForwardNumEntries = 1
            lpAddressStatus->dwForwardSize = 0x0000001E
            lpAddressStatus->dwForwardOffset = 0x00000040
            lpAddressStatus->dwTerminalModesSize = 0x00000000
            lpAddressStatus->dwTerminalModesOffset = 0x00000000
            lpAddressStatus->dwDevSpecificSize = 0x00000000
            lpAddressStatus->dwDevSpecificOffset = 0x00000000
12:11:01.642 |   TSPI_lineGetAddressStatus() 
            LINEFORWARD[0] structure
                    dwForwardMode = 0x00000001
                    dwCallerAddressSize = 0x00000000
                    dwCallerAddressOffset = 0x00000000
                    dwDestCountryCode = 0
                    dwDestAddressSize = 0x00000006
                    dwDestAddressOffset = 0x00000058
12:11:01.642 |   TSPI_lineGetAddressStatus() 
                    Dest Address = 55
12:11:01.642 |   TSPI_lineGetAddressStatus() TSPI_lineGetAddressStatus returns = 0x00000000
12:11:01.643 |<--TSPI_lineGetAddressStatus() 

Regardless of this, ATAPI is trying to read the whole LINEFORWARD structure from the message (with any TAPI version), resulting in two possible outcomes:

  • If the message contains enough bytes to be copied into the structure, no explicit error is given, but the last two fields contain garbage data
  • If the message doesn't contain enough bytes (i.e. the destination address has less than 3 digits), the above exception is thrown

lineOpen failed [0xFFFFFFFF8000004B]

Hi, we have been using our TAPI driver on Windows 2012 server - no problems whatsoever. Recently we upgraded to Windows 2019 OS, and ever since we have been getting the following error at random times , we are struggling to determine the cause of this.

Does anyone have a suggestion at to what this error code relates to?

Opening line Exception: lineOpen failed [0xFFFFFFFF8000004B] A resource needed to fulfill the request is not available

minor changes

Hi! nice library!

Just a remark, in the codeplex site, the url to the moved github is pointing to https://github.com/markjulmar/atapi/ and this site is the C/C++ wrapper.

Do you accept pull request? I my current project we add some minor features:

  • Abstractions for the main entities, such as TapiLine, TapiCall, TapiAddress. In order to allow mocking those entities in unit tests.
  • Added a GUID in the calls to identify it each call as unique.

I can send you a pull request if you want.

Regards.

.NET Core support: "System.PlatformNotSupportedException" for delegate BeginInvoke

I can make a call...BUT I get an exception:

Note: the call continues in the background while this exception has stopped execution of the program

Looks like if I want to use .NET Core, I have to change how the async calls are done:

https://devblogs.microsoft.com/dotnet/migrating-delegate-begininvoke-calls-for-net-core/

The fix appears to be relatively simple. Here are the necessary changes:

async public Task<bool> Initialize()
{
    ...
    
    /*
    _workerThread = new Thread(ProcessTapiMessages)
    {
        Name = "Tapi Message Processor",
        IsBackground = true,
    };
    _workerThread.Start();
    */

    var _workerTask = new Task(async () =>
    { 
        await ProcessTapiMessages();
    });
    
    _workerTask.Start();
    ...
}

async private Task ProcessTapiMessages()
{
    ...

    /*
    ptmCb.BeginInvoke(msg, ar =>
                        {
                            try
                            {
                                ptmCb.EndInvoke(ar);
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine("TAPI message exception: " + ex.Message);
                            }
                        }, null);
    */

     // invoke and await delegate
        await Task.Run(() =>
        {
            try
            {
                ptmCb.Invoke(msg);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("TAPI message exception: {0}", ex.Message);
            }
        });
    ...
}
                 

in TapiManager.cs

Now I no longer get the exception, and the call continues normally. Both the async changes were required, or else the UI would hang.

This fix should be compatible with existing applications, and now it supports .NET Core!

Worker thread prevents closing of the application

Originally reported as CodePlex issue #13315 and still relevant for the new version:

The Thread that is created and started in the TapiManager.Initialize method doesn't have the IsBackground property set to true and therefore prevents the closing of applications if the TapiManager.Shutdown method is never called.

lineOpen failed; The operation failed for unspecified reasons

The sample apps work fine, but in my own app (Win 10, .NET Core 3.1 -> referencing ATAPI project source), the line fails to open:

lineOpen failed [0xFFFFFFFF80000048] The operation failed for unspecified reasons

The error code is LINEERR_OPERATIONFAILED

I'm explicitly targeting x86 (32-bit) for hardware reasons. I can initialized TapiManager fine and get my lines. I'm following the examples and passing in the available media modes when opening the line:

        line.Open(line.Capabilities.MediaModes);             

When I follow into the open call, it fails at Line 1157 in TapiLine.cs:

int rc = NativeMethods.lineOpen(_mgr.LineHandle, _deviceId, out hLine, _negotiatedVersion, _negotiatedExtVersion,
                Marshal.GetFunctionPointerForDelegate(_lcb), privilege, (int) mediaMode, ref lcp);

returns

-2147483576

which is obviously a bad pointer. Everything being passed into the native call is valid and not null, so it's failing somewhere during the interop part. It looks like Interop.cs explicitly points to TAPI32.dll:

[DllImport("Tapi32.dll", EntryPoint = "lineOpenW", CharSet = CharSet.Auto)]
internal static extern int lineOpen(HTLINEAPP hLineApp, int dwDeviceID, out uint hLine, int dwAPIVersion, int dwExtVersion, IntPtr dwCallbackInstance, int dwPrivileges, int dwMediaModes, ref LINECALLPARAMS lpCallParams);

I do have the TAPI32 dll in System32. I've tried two different modems, and tried explicitly setting the media mode, but it errors out the same way. It's probably something dumb I'm doing, but I can't figure it out.

TapiCall id error

We use our monitor functionality program in several computers. Sometime we have got next situation with incomming call in OnCallStateChanged -
We have no event with final CallState.
But we have got Call with Id+1(maybe 2 or 3) and CallOrigin =Unknown and CallState = Connected.

Compilation error with Visual Studio 2017

D:\src\atapi.net\src\src\Events.cs(374,20,374,29): error CS0266: Cannot implicitly convert type 'JulMar.Atapi.ITapiLine' to 'JulMar.Atapi.TapiLine'. An explicit conversion exists (are you missing a cast?)
D:\src\atapi.net\src\src\TapiManager.cs(547,39,547,55): error CS1061: 'ITapiLine' does not contain a definition for 'OnDeviceSpecific' and no extension method 'OnDeviceSpecific' accepting a first argument of type 'ITapiLine' could be found (are you missing a using directive or an assembly reference?)

There are different ways to resolve them:

  1. changing the type to ITapiLine and adding OnDeviceSpecific to the interface
  2. explicit cast to TapiLine

I don't know which way is preferred. I will post diffs for both possibilities.

issue-9-extend-itapiline.txt
issue-9-explicit-cast.txt

a question

hi men
i have a panasonic ns500 pbx device .
i searching in internet for a while and now know i need a tapi application to connect to my pbx to manage phone and calls.
but it still confusing for me!
can you please tell me how i can connect to my pbx and programing for it? can i use your library for it?
i just need some clear road map and knowlege.
Thank you a lot!

How to use atapi.net in web API

Hello,

We have got a requirement where we would like to monitor the incoming call and from fin the related user from that phone number and display the user details on the screen. Also want to create a phone link where user can call the that number directly from the link.
WE have got similar functionality in our older version but it uses the Vbscript. We have got TAPi installed. i just need a way to way to monitor this in our new system. (front end is Ember and backend is web API in C#)

Kind Regards

TcMon frozen UI

Start TcMon test in VS2017.
When a new call occurs, UI becomes frozen.
It is not possible to close the running app by a cross.

I've modified private void TapiMonitorForm_Load(object sender, EventArgs e) to monitor only OnNewCall for one given line:

        foreach (TapiLine line in tapiManager.Lines)
        {
            try
            {
                if (line.ToString().Contains("1240171"))
                {
                    line.NewCall += OnNewCall;
                    line.Monitor();
                }
            }

Can you please give me a hint?
I assume this shall work, so a problem must me on my side.
Thanks.

tcmonuifrozen

ArgumentOutOfRangeException in LineCapabilities ctor

An error may occur during initialization of TapiManager on creating a new TapiLine object and gathering the line capabilities.

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parametername: startIndex
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.BitConverter.ToChar(Byte[] value, Int32 startIndex)
at JulMar.Atapi.LineCapabilities..ctor(LINEDEVCAPS ldc, Byte[] buff)
at JulMar.Atapi.TapiLine.GatherDevCaps()
at JulMar.Atapi.TapiLine..ctor(TapiManager mgr, Int32 deviceId)
at JulMar.Atapi.TapiManager.InitializeLineDevices()
at JulMar.Atapi.TapiManager.Initialize()

Next nuget release

Hi again!

Do you have any plan to publish the latest changes made with the PRs via Nuget to allow us to update the library?

Regards!

Trouble getting device configuration

Hello,

I have trouble using the GetDeviceConfig function. From within my app I would like the user to permanently change settings for a specific tapi line without going to the control panel an searching for the tsp provider.

I have a sub with the following:

Public Shared Sub OpenConfigDialog()

        ' Get the current active tapi line
        Dim ActiveTapiLine As TapiLine = GetActiveTapiLine()

        ' Open the config dialog for the line
        ActiveTapiLine.Config(Nothing, "tapi/line")

        ' Get the config as byteArray
        Dim LineConfigByteArray As Byte() = ActiveTapiLine.GetDeviceConfig("tapi/line")

        ' Store updated config as byteArray
        ActiveTapiLine.SetDeviceConfig("tapi/line", LineConfigByteArray)

End Sub

The problem is that the GetDeviceConfig returns {Length=0}. However, I expect that to return an updated config so it can be used again with the SetDeviceConfig function.

Am I doing something wrong? Hope you can help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.