Skip to content

Commit b2322da

Browse files
authored
Merge pull request #19 from electricimp/develop
Fix an issue with DHCP client identifier
2 parents 46eaf04 + e18d925 commit b2322da

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

DHCP/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Wiznet 5500 DHCP #
1+
# Wiznet 5500 DHCP 2.0.1 #
22

33
This library class enables Dynamic Host Configuration Protocol (DHCP) functionality for the [Wiznet W5500 chip](http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v106e_141230.pdf). It depends on the Wiznet W5500 library, so be sure to include the DHCP library after the W5500 library.
44

5-
**To include this library in your project, add the following to the top of your device code**
5+
**To include this library in your project, add the following at the top of your device code:**
66

7-
```
8-
#require "W5500.device.lib.nut:2.1.1"
9-
#require "W5500.DHCP.device.lib.nut:2.0.0"
7+
```squirrel
8+
#require "W5500.device.lib.nut:2.2.0"
9+
#require "W5500.DHCP.device.lib.nut:2.0.1"
1010
```
1111

1212
## Class Usage ##
@@ -80,7 +80,7 @@ This method renews the lease or requests a new lease. When this is complete, the
8080

8181
| Parameter | Data Type | Required? | Description |
8282
| --- | --- | --- | --- |
83-
| *timeout* | Integer | No | The number of seconds to allow for the lease to try before giving up, if set to 0 the timeout will be infinite. Default: 0 |
83+
| *timeout* | Integer | No | The number of seconds to allow for the lease to try to be renewed before giving up. If set to 0, the timeout will be infinite. Default: 0 |
8484

8585
#### Returns ####
8686

DHCP/W5500.DHCP.device.lib.nut

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ enum W5500_DHCP_OPTIONS {
143143

144144
class W5500.DHCP {
145145

146-
static VERSION = "2.0.0";
146+
static VERSION = "2.0.1";
147147

148148
_driver = null;
149149
_wiz = null;
@@ -751,6 +751,7 @@ class W5500.DHCP {
751751
for (local i = 0; i < _mac.len(); i++) {
752752
mac.writen(_mac[i], 'b');
753753
}
754+
mac.seek(0, 'b');
754755

755756
// OPTIONS
756757
// Client identifier
@@ -760,7 +761,7 @@ class W5500.DHCP {
760761
// Type
761762
options.writen(0x01, 'b');
762763
// Writes Mac Address
763-
options.writeblob(mac);
764+
options.writeblob(mac.readblob(6));
764765

765766
// Host Name
766767
options.writen(W5500_DHCP_OPTIONS.hostName, 'b');

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Wiznet W5500 #
1+
# Wiznet W5500 2.2.0 #
22

3-
The W5500 chip is a hardwired TCP/IP embedded Ethernet controller. We have two libraries for use with the [Wiznet W5500 chip](http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v106e_141230.pdf).
3+
The W5500 chip is a hardwired TCP/IP embedded Ethernet controller. We have two libraries for use with the [Wiznet W5500 chip](http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v106e_141230.pdf).
44

5-
The base library allows you to communicate with a TCP/IP network (separate from an imp’s connection to the network). This library supports SPI integration with the W5500. See documentation [below](#w5500-class-usage).
5+
The base library allows you to communicate with a TCP/IP network (separate from an imp’s connection to the network). This library supports SPI integration with the W5500. See documentation [below](#w5500-class-usage).
66

77
In addition we have a W5500.DHCP library that enables Dynamic Host Configuration Protocol (DHCP) functionality for the [Wiznet W5500 chip](http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v106e_141230.pdf). Documentation and source code can be found in the [DHCP directory](./DHCP).
88

@@ -24,7 +24,7 @@ The constructor configures, resets then initializes the Wiznet chip. The reset p
2424
| *resetPin* | imp **pin** object | No | The pin represents a physical pin on the imp and is used for sending a hard reset signal to the W5500 chip |
2525
| *autoRetry* | Boolean | No | Whether the library should automatically retry to open a connection should one fail. Default: `false`. **Note** Not yet implemented |
2626
| *setMac* | Boolean | No | Whether the library should set the MAC address of the chip to the imp’s own MAC (with the locally administered bit flipped). This should be set to `false` when using a Wiznet Wiz550io board, since it has its own MAC address. Default: `true` |
27-
27+
2828
#### Examples ####
2929

3030
```squirrel
@@ -33,7 +33,7 @@ The constructor configures, resets then initializes the Wiznet chip. The reset p
3333
interruptPin <- hardware.pinXC;
3434
resetPin <- hardware.pinXA;
3535
36-
// Initialize SPI
36+
// Initialize SPI
3737
spiSpeed <- 1000;
3838
spi <- hardware.spi0;
3939
spi.configure(CLOCK_IDLE_LOW | MSB_FIRST | USE_CS_L, spiSpeed);
@@ -43,9 +43,9 @@ wiz <- W5500(interruptPin, spi, null, resetPin);
4343
```
4444

4545
```squirrel
46-
// Setup for an impC001
46+
// Setup for an impC001
4747
48-
// Configure pins
48+
// Configure pins
4949
cs <- hardware.pinS;
5050
resetPin <- hardware.pinYC;
5151
// Note: This is not the default interrupt pin for the mikroBus.
@@ -54,7 +54,7 @@ resetPin <- hardware.pinYC;
5454
// interrupt to pin YL.
5555
interruptPin <- hardware.pinYL;
5656
57-
// Initialize SPI
57+
// Initialize SPI
5858
speed <- 1000;
5959
spi <- hardware.spiPQRS;
6060
spi.configure(CLOCK_IDLE_LOW | MSB_FIRST, speed);
@@ -64,14 +64,14 @@ wiz <- W5500(interruptPin, spi, cs, resetPin);
6464
```
6565

6666
```squirrel
67-
// Setup for an imp001
67+
// Setup for an imp001
6868
69-
// Configure pins
69+
// Configure pins
7070
cs <- hardware.pin8;
7171
resetPin <- hardware.pin9;
7272
interruptPin <- hardware.pin1;
7373
74-
// Initialize SPI
74+
// Initialize SPI
7575
speed <- 1000;
7676
spi <- hardware.spi257
7777
spi.configure(CLOCK_IDLE_LOW | MSB_FIRST, speed);
@@ -113,7 +113,7 @@ wiz.configureNetworkSettings([192,168,1,37], [255,255,255,0], [192,168,1,1]);
113113

114114
### onReady(*callback*) ###
115115

116-
This method registers a callback function that will be triggered when the W5500 initialization is completed and the chip is ready for use.
116+
This method registers a callback function that will be triggered when the W5500 initialization is completed and the W5500 is ready for use.
117117

118118
#### Parameters ####
119119

@@ -204,6 +204,8 @@ This method finds a socket that is not in use and sets up a TCP server. Initiali
204204
| *port* | An integer | Yes | The port to listen on for connections |
205205
| *callback* | Function | Yes | A callback function that is passed an error message, or the established remote connection is established. The table below lists its parameters |
206206

207+
&nbsp;
208+
207209
| Callback Parameter | Data&nbsp;Type | Description |
208210
| --- | --- | --- |
209211
| *error* | String | An error message if there was a problem, or `null` if successful |
@@ -346,7 +348,7 @@ The instance (*this*).
346348

347349
### close(*[callback]*) ###
348350

349-
This method closes a connection via the W5500.
351+
This method closes a connection via the W5500.
350352

351353
#### Parameters ####
352354

@@ -404,6 +406,8 @@ This method registers a callback function that will be triggered when data is re
404406
| --- | --- | --- | --- |
405407
| *callback* | Function | No | A function to be called when data is received. Its parameters are listed below |
406408

409+
&nbsp;
410+
407411
| Parameter | Data&nbsp;Type | Description|
408412
| --- | --- | --- |
409413
| *error* | String | An error message if there was a problem, or `null` if it was successful |
@@ -435,6 +439,8 @@ This method registers a callback function that will be triggered when the connec
435439
| --- | --- | --- | --- |
436440
| *callback* | Function | No | A function to be called when the W5500 is disconnects. Its parameters are listed below |
437441

442+
&nbsp;
443+
438444
| Callback&nbsp;Parameter | Data&nbsp;Type | Description|
439445
| --- | --- | --- |
440446
| *error* | String | An error message if there was a problem, or `null` if it was successful |
@@ -485,6 +491,8 @@ This method is called within a connection to transmit the data through the socke
485491
| *data* | Blob or string | Yes | The data to be transmitted |
486492
| *callback* | Function | No | The callback triggered when data was sent successfully or a timeout occurred. Its parameters are listed below |
487493

494+
&nbsp;
495+
488496
| Callback&nbsp;Parameter | Data&nbsp;Type | Description|
489497
| --- | --- | --- |
490498
| *error* | String | An error message if there was a problem, or `null` if it was successful |
@@ -516,6 +524,8 @@ This method is an alternative to [*onReceive()*](#onreceivecallback) and which w
516524
| --- | --- | --- | --- |
517525
| *callback* | Function | No | The callback triggered when data was received. Its parameters are listed below |
518526

527+
&nbsp;
528+
519529
| Callback&nbsp;Parameters | Data&nbsp;Type | Description|
520530
| --- | --- | --- |
521531
| *error* | String | An error message if there was a problem, or `null` if it was successful |

examples/DHCP_Example.device.nut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
// Include Libraries
2929
#require "W5500.device.lib.nut:2.2.0"
30-
#require "W5500.DHCP.device.lib.nut:2.0.0"
30+
#require "W5500.DHCP.device.lib.nut:2.0.1"
3131

3232
// Configure Echo Server Settings
3333
const ECHO_SERVER_IP = "192.168.42.3";

0 commit comments

Comments
 (0)