Jump to content

Cell ID (LAC) using TAPI?


Recommended Posts

Guest sharpstuff
Posted

I'm trying to write an application in .NetCF that's like "CellTrack" (available for Series 60 phones). I want to be able to get the current CellID, and switch my phone to silent if I'm at work etc. etc.

I've read a few articles that mention the use of TAPI for this purpose, but have not managed to find any specific information. Also, I'm not sure if this is the right way to go.

Does anyone know where I could find example code in either C# or VB.Net?

Cheers

Guest chucky.egg
Posted

That's odd

"spv - developers.com" got converted to "censored"

Why was that, is there anything dodgy going on that I might not want to get caught up in?

Anyway, see my sig for their web address

Guest sharpstuff
Posted (edited)

Thanks for replying, I had a look at that site and managed to download the source, once I'd installed tortoise cvs (?!?!?!).

Source is in C++ and indeed uses TAPI. I'm determined to crack this in C# so looks like I have to bite the bullet and call windows libraries direct from C#. :-(

Cheers!

Edited by sharpstuff
Guest sharpstuff
Posted

Thanks for the tips... I think zamo_x is right in saying that a wrapper is the way forward...

I wrote these DLL imports...

[DllImport("coredll.dll")]

  private static extern IntPtr GetModuleHandle( IntPtr name );



  [DllImport("cellcore.dll")]

  private static extern IntPtr LineInitialize(

 	 out int lphLineApp, 

 	 IntPtr  hInstance, 

 	 LineCallback lpfnCallBack, 

 	 IntPtr lpszAppName , 

 	 out int lpdwNumDevs );
..followed by these calls...
 int lineApp = 0;

 	 int numDevs = 0;

 	 

 	 IntPtr handle = GetModuleHandle( IntPtr.Zero );


 	 LineInitialize( out lineApp, handle, new LineCallback( lineCall ), IntPtr.Zero, out numDevs );

Am no expert on this stuff, so might have messed it up... But consistently got "Not supported" exceptions.. :-(

Guest zamo_x
Posted

i found lineInitializeEx in "coredll".

[StructLayout(LayoutKind.Sequential)]

  public struct lineinitializeexparams

  {

 	 public uint  dwTotalSize;

 	 public uint  dwNeededSize;

 	 public uint  dwUsedSize;

 	 public uint  dwOptions;

 	 public System.IntPtr hEvent;

 	 public uint  dwCompletionKey;

  }


[DllImport("coredll")]

  public static extern uint lineInitializeEx(

    out IntPtr lphLineApp, 

    IntPtr hInstance, 

    IntPtr lCalllBack,

    string lpszFriendlyAppName, 

    out System.UInt32 lpdwNumDevs, 

    ref System.UInt32 lpdwAPIVersion,

    ref lineinitializeexparams lpLineInitializeExParams);

Guest Zone-MR
Posted

I think you understood the source wrong. The relevant file is cellget.cpp

http://cvs.sourceforge.net/viewcvs.py/nbft...1.4&view=markup

The CellID info is retrieved directly from the GSM memory. CCellGet::GetCellInfo(CELL_NEAREST, CELL_ID) will retrieve the nearest cell's ID.

I don't think there's any easy was of accessing memory directly in .NET. You'd either have to call the CopyMemory API, or write a eVC++ DLL for getting the Cell info.

Guest sharpstuff
Posted

Ah! Thanks for your help, I'll have a look into that

J

Guest sharpstuff
Posted

I bit the bullet and wrote a C++ DLL that does the same as the GetCellInfo method of CellTrack, and called this from C#. Unfortunately, it threw an exception. I'm assuming this is because the GSM Memory is mapped out differently on my phone.

Cheers for your help guys

Posted

sharpstuff, can you tell me how to call a DLL in C#? I built a c++ DLL, but by using in C# an error says:

This is not a .NET assembly.

Thanks

Guest sharpstuff
Posted

I use DLLImport in my class to create a .NET declaration for each of the methods in my C++ DLL. Like this: -

  

[DllImport("mydll.dll")]

 public static extern int DoStuff(string myParam1,long myParam2, int myParam3 );

Then, just call your DoStuff method from your C#.

Here's an article that explains it quite well

http://csharpcomputing.com/Tutorials/Lesson21.htm

You could also take a look at the source for the smart device framework at www.opennetcf.org, there are some good examples here

Hope this helps

Guest pai
Posted
I use DLLImport in my class to create a .NET declaration for each of the methods in my C++ DLL.  Like this: -

  

[DllImport("mydll.dll")]

 public static extern int DoStuff(string myParam1,long myParam2, int myParam3 );

Then, just call your DoStuff method from your C#.

Here's an article that explains it quite well

http://csharpcomputing.com/Tutorials/Lesson21.htm

You could also take a look at the source for the smart device framework at www.opennetcf.org, there are some good examples here

Hope this helps

<{POST_SNAPBACK}>

Thanks, i got it working now.

  • 3 weeks later...
Guest damylen
Posted
Thanks, i got it working now.

<{POST_SNAPBACK}>

Pai, could you explain us a little bit more how you got things working? Can you access the cellid information from within the compact framework using the dll? I would be interested in knowing how to get this working.

Greetings

  • 2 months later...
Posted
Pai, could you explain us a little bit more how you got things working? Can you access the cellid information from within the compact framework using the dll? I would be interested in knowing how to get this working.

Greetings

<{POST_SNAPBACK}>

First I wrote a c++ DLL, then write a .NET DLL by using the first DLL.

At the end i use the .NET DLL in my .NET application.

sorry for so late response.

  • 1 month later...
Guest NoneUser
Posted

Is it possible to use the cellid information your getting to automatically update the time zone? I can't believe they don't have this built in already.

Pai, could you explain us a little bit more how you got things working? Can you access the cellid information from within the compact framework using the dll? I would be interested in knowing how to get this working.

Greetings

<{POST_SNAPBACK}>

  • 4 weeks later...
Guest bobgeorge
Posted

Hello, I am trying to do the same with java, to make a library that I can use in a java midlet. Does anyone know if this is possible and where I might find some information?

  • 2 months later...
  • 1 month later...
Posted
First I wrote a c++ DLL, then write a .NET DLL by using the first DLL.

At the end i use the .NET DLL in my .NET application.

sorry for so late response.

<{POST_SNAPBACK}>

Man, i was searching this for a real looong time.. Great you guys made it.. I need this too but the thing is I know VB.net only. So is there a way to call the dll made by you to my application using VB.net.. If so, can i get your dll file pleassseee..

Thanx a million in advance..

Regards

Carty..

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.