×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    11

    Getting and setting MAC address, Subnet Mask Address

    Hey I'm new to this forum, so sorry if I'm not use to the customs.

    I am writing a program on an N80 in pys60.

    I have come across the need to get the MAC address, and get and set the Subnet mask address programmatically through python.

    I've been looking all over the web and I have not found a way to do it.

    I was wondering if someone could help me with this.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Getting and setting MAC address, Subnet Mask Address

    HI Blackhawk225
    first of all welcome to the python discussion board
    as far as i know you can get the IP address of your phone using pys60 if you know bit networking concepts then you can easily get other things.
    i hope this works for you.

  3. #3
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Getting and setting MAC address, Subnet Mask Address

    Quote Originally Posted by Blackhawk255 View Post
    I have come across the need to get the MAC address, and get and set the Subnet mask address programmatically through python.
    This is not possible as far as I can tell. It would require an extension written in C++ and there aren't any yet.

    Also note, that these low level networking parameters require the CommDD and NetworkControl capabilities to access.

  4. #4
    Regular Contributor
    Join Date
    Aug 2004
    Posts
    156

    Re: Getting and setting MAC address, Subnet Mask Address

    Hi, Its not possible to get the physical address but surely you can get the logical address of the device. Because it falls under the device capabilities. If you can play with the root level of symbian OS and hardware you can get it but as you know S60 is layer above symbian OS so you have to penetrate the OS first !
    ||Kiran ||
    Nokia E-65
    Nokia 7610
    Nokia N95 8GB
    Nokia E90
    Nokia 5110 !!
    Nokia 6110i !!

  5. #5
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Getting and setting MAC address, Subnet Mask Address

    Hi Blackhawk,

    Looks like you would need to hard code your MAC address, which would make your app : non portable.
    (Which is the only possible solution, I can see using Pys60)

    You can get the MAC Address by using code *#62209526# on the device

    Br,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Getting and setting MAC address, Subnet Mask Address

    hi Blackhawk255
    yes once you get the mac address i think certainly get the other things with a little bit of manipulations on it.

    @kiran sir great to see you again in the discussion boards.

  7. #7
    Registered User
    Join Date
    Apr 2008
    Location
    PL
    Posts
    10

    Re: Getting and setting MAC address, Subnet Mask Address

    How to check with Pyton which IP I received from DHCP while connecting to AP?
    I've found such script:
    Code:
       import socket
       ap_id = socket.select_access_point()
       apo = socket.access_point(ap_id)
       apo.start()
       print "PHONE IP IS", apo.ip()
    But for me it works only in case I select connection different than WLAN (e.g. GPRS); while selecting WLAN IP address is always 196.254.13.225

    Nokia E51
    Last edited by reaper7; 2008-07-31 at 10:23.

  8. #8
    Registered User
    Join Date
    Mar 2008
    Location
    Frankfurt, Germany
    Posts
    35

    Re: Getting and setting MAC address, Subnet Mask Address

    @reaper7

    That code works for me... I've manually set my IP for my AP at home to 192.168.2.95, an that's exactly what the code returns in my case.
    Python-Stuff I work on @
    http://www.daniel-perna.de/Python.htm

  9. #9
    Registered User
    Join Date
    Apr 2008
    Location
    PL
    Posts
    10

    Re: Getting and setting MAC address, Subnet Mask Address

    @szallah: Of course you're right - if IP is set up manualny the script will show it correctly.
    But if I set it up manually of course I know it well and so don't have to check it

    I've set DHCP, connect to different APs and want to know which IP was assigned for me and this doesn't work correctly.
    E51

  10. #10
    Registered User
    Join Date
    Apr 2008
    Location
    PL
    Posts
    10

    Re: Getting and setting MAC address, Subnet Mask Address

    another way to get the real address:
    Code:
        
    msg = "Ok"
    intip = "0.0.0.0"
    port = 8511
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    
    apid = None
    apid = socket.select_access_point()
    if not apid:
        sys.exit()
    apo = socket.access_point(apid)
    socket.set_default_access_point(apo)
    apo.start()
    
    s.bind(("0.0.0.0", port))
    
    s.sendto(msg, ("255.255.255.255", port))
    
    while 1:
        data, addr = s.recvfrom(1024)
        intip = addr[0]
        if intip <> "":
            print intip
            break
    apo.stop()
    Sorry for dirty code but working for me
    E51

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Getting and setting MAC address, Subnet Mask Address

    Hi reaper7 good that you got another way if its working correct then i advice you to have article on this at the wiki.
    So that the newbies dont face a problem.

    Hope you take the advice
    Enjoy Pythoning.
    Gaba88

  12. #12
    Registered User
    Join Date
    Apr 2008
    Location
    PL
    Posts
    10

    Re: Getting and setting MAC address, Subnet Mask Address

    This script doesn't seem to be the best one;
    reading its code it looks like IP is not checked locally but only UDP broadcast packed is send so hardware needs to "run it and send back".
    In case of adhoc connection if there's no other WLAN point the script will not work.
    I'd prefer that base script (apo.ip()) would work fine.

    I think that there's some kind of bug:
    1. IP information is retrieved too fast - before IP is assigned by DHCP,
    2. or in case of WLAN IP refresh doesn't work and so apo.ip() returns default IP.
    E51

  13. #13
    Registered User
    Join Date
    Jul 2008
    Posts
    11

    Re: Getting and setting MAC address, Subnet Mask Address

    Quote Originally Posted by croozeus View Post
    Hi Blackhawk,

    Looks like you would need to hard code your MAC address, which would make your app : non portable.
    (Which is the only possible solution, I can see using Pys60)

    You can get the MAC Address by using code *#62209526# on the device

    Br,
    Croozeus
    I was wondering what you mean by code *#62209526# on the device. What do you mean by code? Code where?

  14. #14
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Getting and setting MAC address, Subnet Mask Address

    Quote Originally Posted by Blackhawk255 View Post
    I was wondering what you mean by code *#62209526# on the device. What do you mean by code? Code where?
    hi Blackhawk225
    just enter that code given by croozeus as you dial a number then you will get your MAC address whats you are not getting in that.


    Enjoy Pythoning
    Gaba88

  15. #15
    Nokia Developer Champion
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,545

    Re: Getting and setting MAC address, Subnet Mask Address

    And the code is easier to remember, if you think of it as *#MAC WLAN# ('M' on the regular mobile phone (ITU-T) keypad is on the key '6', 'A' is on the key '2', 'C' is also on '2', etc.).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •