Functions | |
int | Network_SetActive (int state) |
Sets whether the Network subsystem is active. | |
int | Network_GetActive (void) |
Returns the active state of the Network subsystem. | |
int | Network_SetAddress (int a0, int a1, int a2, int a3) |
Set the IP address of the Make Controller. | |
int | Network_SetMask (int a0, int a1, int a2, int a3) |
Set the network mask of the Make Controller on your local network. | |
int | Network_SetGateway (int a0, int a1, int a2, int a3) |
Set the gateway address for the local network the Make Controller is on. | |
int | Network_GetAddress (int *a0, int *a1, int *a2, int *a3) |
Read the board's current IP address. | |
int | Network_GetMask (int *a0, int *a1, int *a2, int *a3) |
Read the board's current network mask. | |
int | Network_GetGateway (int *a0, int *a1, int *a2, int *a3) |
Read the board's current gateway address. | |
void | Network_SetDhcpEnabled (int enabled) |
Set whether DHCP is enabled. | |
int | Network_GetDhcpEnabled () |
Read whether DHCP is currently enabled. | |
int | Network_DnsGetHostByName (const char *name) |
Resolve the IP address for a given host name. |
Like any other network enabled device, the Make Controller has an IP address, net mask and gateway.
You can set any of these values manually, or use DHCP to get them automatically.
int Network_DnsGetHostByName | ( | const char * | name | ) |
Resolve the IP address for a given host name.
Up to 4 DNS entries are cached, so if you make successive calls to this function, you won't incur a whole lookup roundtrip - you'll just get the cached value. The cached values are maintained internally, so if one of them becomes invalid, a new lookup will be fired off the next time it's asked for.
name | A string specifying the name of the host to look up. |
// try to open a socket connection to makingthings.com int addr = Network_DnsGetHostByName("makingthings.com"); struct netconn* socket = Socket(addr, 80); // open up a new connection to that address
int Network_GetActive | ( | void | ) |
int Network_GetAddress | ( | int * | a0, | |
int * | a1, | |||
int * | a2, | |||
int * | a3 | |||
) |
Read the board's current IP address.
Pass in pointers to integers where the address should be stored.
a0 | A pointer to an integer where the first of 4 numbers of the address is to be stored. | |
a1 | A pointer to an integer where the second of 4 numbers of the address is to be stored. | |
a2 | A pointer to an integer where the third of 4 numbers of the address is to be stored. | |
a3 | A pointer to an integer where the fourth of 4 numbers of the address is to be stored. |
int a0, a1, a2, a3; Network_GetAddress( &a0, &a1, &a2, &a3 ); // now our variables are filled with the current address values
int Network_GetDhcpEnabled | ( | void | ) |
int Network_GetGateway | ( | int * | a0, | |
int * | a1, | |||
int * | a2, | |||
int * | a3 | |||
) |
Read the board's current gateway address.
Pass in pointers to integers where the gateway address should be stored.
a0 | A pointer to an integer where the first of 4 numbers of the gateway address is to be stored. | |
a1 | A pointer to an integer where the second of 4 numbers of the gateway address is to be stored. | |
a2 | A pointer to an integer where the third of 4 numbers of the gateway address is to be stored. | |
a3 | A pointer to an integer where the fourth of 4 numbers of the gateway address is to be stored. |
int a0, a1, a2, a3; Network_GetGateway( &a0, &a1, &a2, &a3 ); // now our variables are filled with the current gateway values
int Network_GetMask | ( | int * | a0, | |
int * | a1, | |||
int * | a2, | |||
int * | a3 | |||
) |
Read the board's current network mask.
Pass in pointers to integers where the mask should be stored.
a0 | A pointer to an integer where the first of 4 numbers of the mask is to be stored. | |
a1 | A pointer to an integer where the second of 4 numbers of the mask is to be stored. | |
a2 | A pointer to an integer where the third of 4 numbers of the mask is to be stored. | |
a3 | A pointer to an integer where the fourth of 4 numbers of the mask is to be stored. |
int a0, a1, a2, a3; Network_GetMask( &a0, &a1, &a2, &a3 ); // now our variables are filled with the current mask values
int Network_SetActive | ( | int | state | ) |
Sets whether the Network subsystem is active.
This fires up the networking system on the Make Controller, and will not return until a network is found, ie. a network cable is plugged in.
state | An integer specifying the active state - 1 (active) or 0 (inactive). |
int Network_SetAddress | ( | int | a0, | |
int | a1, | |||
int | a2, | |||
int | a3 | |||
) |
Set the IP address of the Make Controller.
The IP address of the Make Controller, in dotted decimal form (xxx.xxx.xxx.xxx), can be set by passing in each of the numbers as a separate parameter. The default IP address of each Make Controller as it ships from the factory is 192.168.0.200.
This value is stored in EEPROM, so it persists even after the board is powered down.
a0 | An integer corresponding to the first of 4 numbers in the address. | |
a1 | An integer corresponding to the second of 4 numbers in the address. | |
a2 | An integer corresponding to the third of 4 numbers in the address. | |
a3 | An integer corresponding to the fourth of 4 numbers in the address. |
// set the address to 192.168.0.23 Network_SetAddress( 192, 168, 0, 23 );
void Network_SetDhcpEnabled | ( | int | enabled | ) |
Set whether DHCP is enabled.
The Make Controller can use DHCP (Dynamic Host Configuration Protocol) to automatically retrieve an IP address from a router. If you're using your Make Controller on a network with a router, it is generally preferred (and more convenient) to use DHCP. Otherwise, turn DHCP off and set the IP address, mask, and gateway manually.
Wikipedia has a good article about DHCP at http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
This value is stored persistently, so it will remain constant across system reboots.
enabled | An integer specifying whether to enable DHCP - 1 (enable) or 0 (disable). |
int Network_SetGateway | ( | int | a0, | |
int | a1, | |||
int | a2, | |||
int | a3 | |||
) |
Set the gateway address for the local network the Make Controller is on.
The gateway address is commonly 192.168.0.1 for many home networks. Set the gateway address in dotted decimal form (xxx.xxx.xxx.xxx), passing in each number as a separate parameter.
This value is stored in EEPROM, so it persists even after the board is powered down.
a0 | An integer corresponding to the first of 4 numbers in the gateway address. | |
a1 | An integer corresponding to the second of 4 numbers in the gateway address. | |
a2 | An integer corresponding to the third of 4 numbers in the gateway address. | |
a3 | An integer corresponding to the fourth of 4 numbers in the gateway address. |
// set the gateway to 192.168.5.1 if( 0 != Network_SetGateway( 192, 168, 5, 1 ) ) // then there was a problem.
int Network_SetMask | ( | int | a0, | |
int | a1, | |||
int | a2, | |||
int | a3 | |||
) |
Set the network mask of the Make Controller on your local network.
When on a subnet or local network, the network mask must be set in order for the gateway to route information to the board's IP address properly. The mask is commonly 255.255.255.0 for many home networks. Set the mask in dotted decimal form (xxx.xxx.xxx.xxx), passing in each number as a separate parameter.
This value is stored in EEPROM, so it persists even after the board is powered down.
a0 | An integer corresponding to the first of 4 numbers in the mask. | |
a1 | An integer corresponding to the second of 4 numbers in the mask. | |
a2 | An integer corresponding to the third of 4 numbers in the mask. | |
a3 | An integer corresponding to the fourth of 4 numbers in the mask. |
// set the mask to 255.255.255.254 if( 0 != Network_SetMask( 255, 255, 255, 254 ) ) // then there was a problem.