Main Parameters

Top  Previous  Next

To enable Ethernet communications, you need to set the net.ip, net.gatewayip, and the net.netmask properties. Actually, net.gatewayip and net.netmask are only needed when your device will be establishing outgoing connections to other hosts on the network (perform active opens). If your device will only be accepting incoming connections then you do not have to set the net.gatewayip and the net.netmask.

 

note_tip-wt

Strangely, a lot of people hold a passionate belief that default gateway IP and the netmask are necessary always, even for incoming connections. This is not true!

 

The net object is usually initialized once on startup, like this:

 

 

sub on_sys_init

 ... some other stuff        

 

 net.ip = "192.168.1.95" 'just an example! May not work on your network!

 net.gatewayip = "192.168.1.1" 'just an example! May not work on your network!

 net.netmask= "255.255.255.0" 'just an example! May not work on your network!

 

 ...some other stuff

end sub

 

 

note_tip-wt

On a lot of networks the IP, gateway IP, and the netmask parameters of the hosts are configured automatically, through the use of a special protocol called "DHCP". The net object does not support dhcp directly by we provide a BASIC library that implements DHCP functionality.

 

One additional read-only property- the net.mac- can be used to extract the MAC address of your device. Your program cannot change the MAC address directly. The MAC is stored in the special configuration area of the EEPROM. Access to the EEPROM is provided by the stor object. To change the MAC address you need to rewrite the data in the EEPROM. For more details, see the Stor Object and Stor.Base Property topics.