Python

Moderators: None (Apply to moderate this forum)
Number of threads: 400
Number of posts: 1055

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How can I dial GPRS/EDGE in Win CE Posted by Brontesinho on 10 Jun 2010 at 2:13 PM
Hello all.

I am developing application in python on Windows CE which needs connection to the internet (via GPRS/EDGE). When I turn on the device, the internet connection is not active. It becomes active if I open internet explorer.

I would like to activate connection in my application. I'm trying to do this with RasDial function over ctypes library, but I can't get it to work. Is this the right way or I should do something else?

Below is my current code. The ResDial function keeps returning error 87 – Invalid parameter. I don't know anymore what is wrong with it.

I would really appreciate any kind of help. Thanks in advance.

#encoding: utf-8

import ppygui as gui
from ctypes import *
import os

class MainFrame(gui.CeFrame):
def __init__(self, parent = None):
gui.CeFrame.__init__(self, title=u"Zgodovina dokumentov", menu="Menu")

DWORD = c_ulong
TCHAR = c_wchar
ULONG_PTR = c_ulong

class RASDIALPARAMS(Structure):
_fields_ = [("dwSize", DWORD),
("szEntryName", TCHAR*21),
("szPhoneNumber", TCHAR*129),
("szCallbackNumber", TCHAR*49),
("szUserName", TCHAR*257),
("szPassword", TCHAR*257),
("szDomain", TCHAR*16),
]

try:
param = RASDIALPARAMS()
param.dwSize = 1462 # also tried 1464 and sizeof(RASDIALPARAMS()). Makes no difference.
param.szEntryName = u"My Connection"
param.szPhoneNumber = u"0"
param.szCallbackNumber = u"0"
param.szUserName = u"0"
param.szPassword = u"0"
param.szDomain = u"0"

iNasConn = c_ulong(0)
ras = windll.coredll.RasDial(None, None, param, c_ulong(0xFFFFFFFF), c_voidp(self._w32_hWnd), byref(iNasConn))
print ras, repr(iNasConn) #this prints 87 c_ulong(0L)
except Exception, e:
print "Error"
print e

if __name__ == '__main__':
app = gui.Application(MainFrame(None))
# create an application bound to our main frame instance
app.run()
#launch the app !




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.