Jump to content

The MoDaCo Developer Challenge: Win an i-mate JAQ3!


Guest PaulOBrien

Recommended Posts

Guest euan macinnes
Sure will ;)

Question: Will the merged code from Dan then require your solution to only work with Compact Framework 2.0? Meaning, Smartphones (non-touch screen devices) using WM 2003 can NOT load compact framework 2.0 onto them. So, any solution that requires CF2.0 can only work on WM5 and higher smartphones.

doh!, forgot about that...what are the relevant code features in CF 2.0 that don't work back in 1.0/1.5? i.e.as long as RIL and/or serial comms are available, then it should be removal of any version-specific code features, rather than "no hope of working".

Link to comment
Share on other sites

Guest johncody
doh!, forgot about that...what are the relevant code features in CF 2.0 that don't work back in 1.0/1.5? i.e.as long as RIL and/or serial comms are available, then it should be removal of any version-specific code features, rather than "no hope of working".

From what dan mentioned, he needed to use CF2.0 because it supported callbacks, which he said cf1.0 didn't. That's all I know.

But, yes - that would be cool to offer a solution that would support as many methods to supply the cell info as possible for the CF version installed on the device. This way, SP2003 devices could still be useful.

I am anxious to see what you can do!

Link to comment
Share on other sites

Guest euan macinnes
From what dan mentioned, he needed to use CF2.0 because it supported callbacks, which he said cf1.0 didn't. That's all I know.

But, yes - that would be cool to offer a solution that would support as many methods to supply the cell info as possible for the CF version installed on the device. This way, SP2003 devices could still be useful.

I am anxious to see what you can do!

The serial port stuff compiles back to SP2003. The memory reading compiles well enough back to SP2003 as well. Most issues have been trivial things like no partial classes, no generics, no static classes, but RIL works off callbacks and you're right, no hope for that in SP2003.

All is not lost for RIL on SP2003 though, but it's not going to be quite so straightforward. There's a C++ project called TSRil (on xda-developers.com) that does practically the same thing except in C++, targetted for Mobile devices. All we'll need to do is hide the callbacks, by doing some form of calling function that doesn't return a value until the callback is completed. This will mean different DLL's for different CPUs though. Easy enough to compile for multiple target platforms, but adds an additional step on installation.

Link to comment
Share on other sites

Guest euan macinnes

test Ril C++

-----------

It's a very rough start, but as a place to start, here's the Ril C++ DLL and source for it. Beware of the potential to hang the phone, but it'll not do anything more damaging

There are 5 functions currently, just to get things up n running. I've kept things as easy as possible as far as import declarations go:

void InitialiseRil() -- Initialise the RIL connection

void UpdateRil() -- get the latest values

void FinaliseRil() -- shut down the RIL connection

Once you call UpdateRil, then call the other functions to get the values. Currently implemented are:

DWORD GetCellID()

DWORD GetSignalQuality()

The idea is that this will eventualy be populated with lots of other functions to get the LAC, BCCH values, etc.. etc..., so we can avoid having to marshal any datatypes.

There are two versions compiled here, for PocketPC (ARM) and Smartphone (ARM), in the respective debug\ folders. source included for Visual Studio 2005 users.

It's a very mimimal C++ implementation currently, peared right down to just getting celltowerinfo and that's it for now. Let me know if works/not working etc..

In C#, the DLL import will be as follows:

[DllImport("syncril.dll")]

extern static void InitialiseRil();

for DWORD, sub in UInt32

Sorry about the size of it, the actual DLLs are only 4Kb each, there's a lot of waffle added by VS. (hence the RAR format also, the ZIP version ended up at 3Mb).

CZRILDLL.rar

Edited by euan macinnes
Link to comment
Share on other sites

Guest euan macinnes
Isn't inbuilt serial support new in CF 2?

P

the serial routines used are from coredll.dll to open/process the serial port connection, not something built in to CF, so it's friendly to 1.0 as well.

Link to comment
Share on other sites

Guest johncody
It's a very rough start, but as a place to start, here's the Ril C++ DLL and source for it. Beware of the potential to hang the phone, but it'll not do anything more damaging

OK, I will work on a demo VB.NET CF1.0 app to work with the DLL on my MPX-220 (WM2003 smartphone) and show those stats every couple of seconds - I'll post the sample app when I get it working.

Link to comment
Share on other sites

Guest johncody

OK,

I tried to make up a demo vb.net cf1.0 app consisting of one module and a form.

The module contains this:

----------------------------

Module CellInfo

Public Declare Sub InitialiseRil Lib "syncril.dll" ()

Public Declare Sub UpdateRil Lib "syncril.dll" ()

Public Declare Function GetCellID Lib "syncril.dll" () As Integer

Public Declare Function GetSignalQuality Lib "syncril.dll" () As Integer

Public Declare Sub FinaliseRil Lib "syncril.dll" ()

End Module

----------------------------

I copied the SP2003 version of your syncril.dll to my wm2003 phones' "\Storage\Windows" directory (where all native dll's should go).

My form consist of two labels to display the cell tower ID and signal strength, and two menu buttons "Exit" and "Refresh".

The "Refresh" click_event sub is this:

----------------------------

Private Sub Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click

Call InitialiseRil

Call UpdateRil

lblTowerID.Text = GetCellID.ToString

lblSignal.Text = GetSignalQuality.ToString

Call FinaliseRil

End Sub

----------------------------

But, when I click the refresh button, I am getting an error on the first "Call InitialiseRil" line of:

"{System.MissingMethodException}"

I'm not a C++ expert, so the problem could simply be a declare issue that I did.

Any ideas?

(p.s. I tried to do a "Project....Add Reference" to your syncril.dll" and got an error if that helps any.)

Link to comment
Share on other sites

Guest euan macinnes
OK,

I tried to make up a demo vb.net cf1.0 app consisting of one module and a form.

The module contains this:

----------------------------

Module CellInfo

Public Declare Sub InitialiseRil Lib "syncril.dll" ()

Public Declare Sub UpdateRil Lib "syncril.dll" ()

Public Declare Function GetCellID Lib "syncril.dll" () As Integer

Public Declare Function GetSignalQuality Lib "syncril.dll" () As Integer

Public Declare Sub FinaliseRil Lib "syncril.dll" ()

End Module

----------------------------

I copied the SP2003 version of your syncril.dll to my wm2003 phones' "\Storage\Windows" directory (where all native dll's should go).

My form consist of two labels to display the cell tower ID and signal strength, and two menu buttons "Exit" and "Refresh".

The "Refresh" click_event sub is this:

----------------------------

Private Sub Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click

Call InitialiseRil

Call UpdateRil

lblTowerID.Text = GetCellID.ToString

lblSignal.Text = GetSignalQuality.ToString

Call FinaliseRil

End Sub

----------------------------

But, when I click the refresh button, I am getting an error on the first "Call InitialiseRil" line of:

"{System.MissingMethodException}"

I'm not a C++ expert, so the problem could simply be a declare issue that I did.

Any ideas?

(p.s. I tried to do a "Project....Add Reference" to your syncril.dll" and got an error if that helps any.)

The good news is that it found the DLL. The bad news is that it didn't find the function(s) in the DLL. I'll have a play with the Smartphone 2003 emulator once I'm back in the office tomorrow (monday) and see what's gone wrong there.

Link to comment
Share on other sites

Guest johncody

Just a small update...

When I said "(p.s. I tried to do a "Project....Add Reference" to your syncril.dll" and got an error if that helps any.)"...

... it seems this action will only work for COM server DLL's (Dll's with "DllRegisterServer" in them).

Non-COM Dll's with just function/sub calls in them will apparently always cause an error if you try to do a "Add Reference" to them.

Link to comment
Share on other sites

Guest euan macinnes
Just a small update...

When I said "(p.s. I tried to do a "Project....Add Reference" to your syncril.dll" and got an error if that helps any.)"...

... it seems this action will only work for COM server DLL's (Dll's with "DllRegisterServer" in them).

Non-COM Dll's with just function/sub calls in them will apparently always cause an error if you try to do a "Add Reference" to them.

You can just Add it to the project as an existing item, and set it to Copy to Output directory, which will achieve the intended result. This will result in the file being copied over to the phone and stored in the same directory as the app, rather than clogging up windows\

Link to comment
Share on other sites

Guest euan macinnes

it's either mad cow/dyslexia or premature senility on my part:

The function should have been InitaliseRIL() not InitialiseRil(), case sensitive.

the functions came out as:

InitialiseRIL()

UpdateRil()

FinaliseRIL()

GetCellID()

GetSignalQuality()

Denny Crane.

Edited by euan macinnes
Link to comment
Share on other sites

Guest euan macinnes

here's an updated set of DLLs tha polish it off for the most part (except the nearest neighbouring values). All functions are as follows:

void InitialiseRIL();

void UpdateRIL();

void FinaliseRIL();

DWORD GetCellID();

DWORD GetSignalQuality();

DWORD GetLAC();

// Location Area Code

DWORD GetMCC();

// Mobile Country Code

DWORD GetMNC();

// Mobile Network Code

DWORD GetRxLevel();

DWORD GetRxLevelFull();

DWORD GetRxLevelSub();

DWORD GetRxQuality();

DWORD GetRxQualityFull();

DWORD GetRxQualitySub();

DWORD GetTimingAdvance();

DWORD GetBCCH();

// Broadcast Control Channel. Essentially the ARFCN or specific frequency of the cellsite.

DWORD GetBaseStationID();

DWORD GetGPRSBaseStationID();

DWORD GetGPRSCelID();

DWORD GetIdleTimeSlot();

I've separated out the DLLs to represent the different version of it, i.e. the syncril_PPC.dll for the PocketPC, and the syncril_SP2003.dll for the smartphone.

syncril.rar

Link to comment
Share on other sites

Guest johncody
here's an updated set of DLLs tha polish it off for the most part (except the nearest neighbouring values). All functions are as follows:

void InitialiseRIL();

void UpdateRIL();

void FinaliseRIL();

OK, I replaced the DLL with the latest one and changed the declares to:

Public Declare Sub InitialiseRIL Lib "syncril.dll" ()

Public Declare Sub UpdateRIL Lib "syncril.dll" ()

Public Declare Function GetCellID Lib "syncril.dll" () As Integer

Public Declare Function GetSignalQuality Lib "syncril.dll" () As Integer

Public Declare Sub FinaliseRIL Lib "syncril.dll" ()

(I just want to get the cellid and strength working before trying out the other functions)

Now, when I click "Refresh", the app hangs on the "UpdateRIL" call. (no error is generated on the InitilizeRIL or FinaliseRIL lines if I rem out the UpdateRIL ;)

(yes I did rename the new syncril_SP2003.dll to syncril.dll and overwrote the old one)

Edited by johncody
Link to comment
Share on other sites

Guest euan macinnes
OK, I replaced the DLL with the latest one and changed the declares to:

Public Declare Sub InitialiseRIL Lib "syncril.dll" ()

Public Declare Sub UpdateRIL Lib "syncril.dll" ()

Public Declare Function GetCellID Lib "syncril.dll" () As Integer

Public Declare Function GetSignalQuality Lib "syncril.dll" () As Integer

Public Declare Sub FinaliseRIL Lib "syncril.dll" ()

(I just want to get the cellid and strength working before trying out the other functions)

Now, when I click "Refresh", the app hangs on the "UpdateRIL" call. (no error is generated on the InitilizeRIL or FinaliseRIL lines if I rem out the UpdateRIL ;)

(yes I did rename the new syncril_SP2003.dll to syncril.dll and overwrote the old one)

It'll be hanging because it isn't receiving a response from RIL. I'll put in an extra debug function to check that RIL is being initialised properly.

Link to comment
Share on other sites

Guest euan macinnes
OK, I replaced the DLL with the latest one and changed the declares to:

Public Declare Sub InitialiseRIL Lib "syncril.dll" ()

Public Declare Sub UpdateRIL Lib "syncril.dll" ()

Public Declare Function GetCellID Lib "syncril.dll" () As Integer

Public Declare Function GetSignalQuality Lib "syncril.dll" () As Integer

Public Declare Sub FinaliseRIL Lib "syncril.dll" ()

(I just want to get the cellid and strength working before trying out the other functions)

Now, when I click "Refresh", the app hangs on the "UpdateRIL" call. (no error is generated on the InitilizeRIL or FinaliseRIL lines if I rem out the UpdateRIL ;)

(yes I did rename the new syncril_SP2003.dll to syncril.dll and overwrote the old one)

It may be hanging because the main app needs to have a priviledged certificate to access RIL. If you don't have one, you'll need to download the smartphone 2003 SDK from microsoft, and there's a .pdk TEST priviledged cert in there.

Link to comment
Share on other sites

Guest johncody
It may be hanging because the main app needs to have a priviledged certificate to access RIL. If you don't have one, you'll need to download the smartphone 2003 SDK from microsoft, and there's a .pdk TEST priviledged cert in there.

I'm not ruling that out, but the below app runs on my phone and sucessfully displays the celltower ID with whatever certificates are already on my phone:

http://maniac.fschreiner.de/content/view/9/17/

I could try to use the cert, but I haven't really figured out that whole process of applying a cert to a phone (However, I did luck-out and somehow got the "Security Configuration Manager" to unlock a WM5 blackjack so VS2005 could connect to it, but it doesn't seem to work with my wm2003 phone to do any unlocking).

-John

Edited by johncody
Link to comment
Share on other sites

Guest euan macinnes
I'm not ruling that out, but the below app runs on my phone and sucessfully displays the celltower ID with whatever certificates are already on my phone:

http://maniac.fschreiner.de/content/view/9/17/

I could try to use the cert, but I haven't really figured out that whole process of applying a cert to a phone (However, I did luck-out and somehow got the "Security Configuration Manager" to unlock a WM5 blackjack so VS2005 could connect to it, but it doesn't seem to work with my wm2003 phone to do any unlocking).

-John

Ok I'll check it out in the morning. CellProfileSwitcher may just be using serial port AT commands to retrieve the tower ID though, AT+CREG will do that on most phones, which don't need certs. The other possibility is that CPS is using a paid-for run-anywhere cert, so the cert doesn't need to be installed. I'm not sure about SP2003, but WM5.0 apps definitely need a privileged cert to run RIL, or a null handle will be returned. The syncril is basic and just goes into an infinite loop waiting for the RIL callback to happen, and with an invalid handle, that'll never happen hence the hang. I'll update the InitialiseRIL function to return the handle used, and put a timeout on the UpdateRIL(), and have a look for other reasons that will be causing an invalid handle.

Link to comment
Share on other sites

Guest euan macinnes
I'm not ruling that out, but the below app runs on my phone and sucessfully displays the celltower ID with whatever certificates are already on my phone:

http://maniac.fschreiner.de/content/view/9/17/

I could try to use the cert, but I haven't really figured out that whole process of applying a cert to a phone (However, I did luck-out and somehow got the "Security Configuration Manager" to unlock a WM5 blackjack so VS2005 could connect to it, but it doesn't seem to work with my wm2003 phone to do any unlocking).

-John

To add an existing Cert to a project, you'll need to go to the Signing tab in the project properties in VS2005. When developing in VS, whatever cert you sign the code with VS2005 deploys that to the phone automatically, just while running from the IDE though, standalone apps will not have the cert deployed to the phone. there's also a tool in the Smartphone SDK for deploying certs to phones. The main thing will be whether that cert allows priviledged access, or is just for code signing etc..

I found this on the MS site also:

Note The required trust level for RIL APIs can be modified by changing the value of the following registry key from 2 to 1:

[HKEY_LOCAL_MACHINE\Security\Policy\APIs\RILGSM] @="2"

this is found right at the bottom of this page:

http://msdn2.microsoft.com/en-us/library/m...security_topic6

You should be able to use Total Commander to edit the registry.

Edited by euan macinnes
Link to comment
Share on other sites

Guest johncody
Ok I'll check it out in the morning. CellProfileSwitcher may just be using serial port AT commands to retrieve the tower ID though, AT+CREG will do that on most phones, which don't need certs. The other possibility is that CPS is using a paid-for run-anywhere cert, so the cert doesn't need to be installed. I'm not sure about SP2003, but WM5.0 apps definitely need a privileged cert to run RIL, or a null handle will be returned. The syncril is basic and just goes into an infinite loop waiting for the RIL callback to happen, and with an invalid handle, that'll never happen hence the hang. I'll update the InitialiseRIL function to return the handle used, and put a timeout on the UpdateRIL(), and have a look for other reasons that will be causing an invalid handle.

If it helps any, the "System Requirements of CellProfileSwitcher":

http://maniac.fschreiner.de/content/view/12/22/

Says "Motorola MPX220 (limited support)"

So, it would be really cool if you could somehow design your DLL to be able to scale-down it's functionality depending on if a privileged cert is installed on the device or not. So, for devices which don't have a privileged cert, then your DLL would use serial port calls to retrieve as much info as possible. Or, maybe just have one set of API calls that require privileged cert, and a sub-set that doesn't.

Does this sound doable?

Link to comment
Share on other sites

Guest johncody
To add an existing Cert to a project, you'll need to go to the Signing tab in the project properties in VS2005. When developing in VS, whatever cert you sign the code with VS2005 deploys that to the phone automatically, just while running from the IDE though, standalone apps will not have the cert deployed to the phone. there's also a tool in the Smartphone SDK for deploying certs to phones. The main thing will be whether that cert allows priviledged access, or is just for code signing etc..

I found this on the MS site also:

this is found right at the bottom of this page:

http://msdn2.microsoft.com/en-us/library/m...security_topic6

You should be able to use Total Commander to edit the registry.

OK, I setup the "signing" tab of my test app to use the test priv cert at this location:

F:\NET\SmartDevices\SDK\SDKTools\TestCertificates\TestCert_Privileged.pfx

And it still hangs.

I then installed Total Commander and tried to use it to modify that reg value and it wouldnt change the value. I even tried to use PHM registry editor and the remote registry editor tool of VS, but it gives an error as if they don't have high enough security to modify that value ;)

Edited by johncody
Link to comment
Share on other sites

Guest euan macinnes
If it helps any, the "System Requirements of CellProfileSwitcher":

http://maniac.fschreiner.de/content/view/12/22/

Says "Motorola MPX220 (limited support)"

So, it would be really cool if you could somehow design your DLL to be able to scale-down it's functionality depending on if a privileged cert is installed on the device or not. So, for devices which don't have a privileged cert, then your DLL would use serial port calls to retrieve as much info as possible. Or, maybe just have one set of API calls that require privileged cert, and a sub-set that doesn't.

Does this sound doable?

The serial port routines will be available directly in .NET, I'm putting it in as a User Control component, along with the memory hack and access to this DLL, so the App can choose what to do and what to prioritise. It's best to keep the C++ as minimal as possible.

Link to comment
Share on other sites

Guest euan macinnes

I'm having a lot of trouble getting all this going on the Smartphone Emulator here, so I'm developing this a little blind here, as far as the "SP2003 edition" is concerned. I've updated the Smartphone RIL DLL to return the result handle (which should be 0 for successful), so the declarations have been changed to:

long InitialiseRIL();

long UpdateRIL();

updateRIL will return 0 for a successful result, otherwise it will return >0 if it times out after 100 ms. I had some device specific RIL commands in the UpdateRIL also to get the registered signal strength value, I've temporarily disabled that to reduce the possible sources of error.

I've also compiled it with the TEST cert, as DLLs also need certified. Hopefully there's a bit more luck with this one...

syncril.rar

Edited by euan macinnes
Link to comment
Share on other sites

Guest johncody
I'm having a lot of trouble getting all this going on the Smartphone Emulator here, so I'm developing this a little blind here, as far as the "SP2003 edition" is concerned. I've updated the Smartphone RIL DLL to return the result handle (which should be 0 for successful), so the declarations have been changed to:

long InitialiseRIL();

long UpdateRIL();

updateRIL will return 0 for a successful result, otherwise it will return >0 if it times out after 100 ms. I had some device specific RIL commands in the UpdateRIL also to get the registered signal strength value, I've temporarily disabled that to reduce the possible sources of error.

I've also compiled it with the TEST cert, as DLLs also need certified. Hopefully there's a bit more luck with this one...

Ok, heres what I got so far:

==========================================================

Module CellInfo

Public Declare Function InitialiseRIL Lib "syncril.dll" () As Integer

Public Declare Function UpdateRIL Lib "syncril.dll" () As Integer

Public Declare Function GetCellID Lib "syncril.dll" () As Integer

Public Declare Function GetSignalQuality Lib "syncril.dll" () As Integer

Public Declare Sub FinaliseRIL Lib "syncril.dll" ()

End Module

Private Sub Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click

Dim R As Integer

R = InitialiseRIL()

If R <> 0 Then

MsgBox("InitialiseRIL <> 0: " & CStr®)

Exit Sub

End If

R = UpdateRIL()

If R <> 0 Then

MsgBox("UpdateRIL <> 0: " & CStr®)

Exit Sub

End If

'lblTowerID.Text = GetCellID.ToString

'lblSignal.Text = GetSignalQuality.ToString

Call FinaliseRIL()

MsgBox("Done!")

End Sub

==========================================================

I get a InitializeRIL <> 0: 2147467259 error ;)

Edited by johncody
Link to comment
Share on other sites


×
×
  • Create New...

Important Information

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