Skip to content

Latest commit

 

History

History
179 lines (120 loc) · 4.98 KB

corrigendum.md

File metadata and controls

179 lines (120 loc) · 4.98 KB

Corrigendum

This document lists errors discovered after the publication of the book. If you find an error that is not listed here, please open an issue in this repository.


Page 152

Listing 3-15 does not match the https-get example. The listing leaves out the port property in the dictionary passed to the Request constructor; it should be as follows:

let request = new Request({
	host: "www.example.com",
	path: "/",
	response: String,
	Socket: SecureSocket,
	port: 443
});

Page 159

Listing 3-21 returns String for the Server.status message instead of the Server.headersComplete message. The full corrected listing is as follows:

let server = new Server;

server.callback = function(msg, value, etc) {
	switch (msg) {
		case Server.status:
			if ("PUT" !== etc)
				this.close();
			return;

		case Server.headersComplete:
			return String;

		case Server.requestComplete:
			this.json = {
				error: "none",
				when: (new Date).toString(),
				request: JSON.parse(value)
			};
			break;

		case Server.prepareResponse:
			return {
				headers: ["Content-Type", "application/json"],
				body: JSON.stringify(this.json)
			};
	}
}

Page 160-161

To ask the HTTP Server class to deliver the request body in fragments, the callback returns true to the prepareRequest message.

This sentence is incorrect. The callback returns true to the headersComplete message, not the prepareRequest message.

In addition, Listing 3-22 does not match the https-server-streaming-put example. The listing uses quotation marks instead of backticks in the first trace statement and the prepareRequest message instead of the headersComplete message; it should be as follows:

let server = new Server;

server.callback = function(msg, value) {
	switch (msg) {
		case Server.status:
			trace(`\n ** begin upload to ${value} **\n`);
			break;

		case Server.headersComplete:		// prepare for request body
			return true;					// provide request body in fragments

		case Server.requestFragment:
			trace(this.read(String));
			break;

		case Server.requestComplete:
			trace("\n ** end of file **\n");
			break;
	}
}

Page 169

The websocket-client example originally connected to the server at echo.websocket.org. This service is no longer available, so the example now connects to websockets.chilkat.io.

This code snippet on page 169 no longer matches the websocket-client example:

let ws = new Client({
    host: "echo.websocket.org"
});

It should be as follows:

let ws = new Client({
	host: "websockets.chilkat.io", 
	path: "/wsChilkatEcho.ashx"
});

In addition, the following sentence is no longer accurate:

This process repeats indefinitely, with count increasing each time.

The server at websockets.chilkat.io limits each connection to a maximum of 16 echoed messages. After the 16th message, it disconnects from the client.


Page 193-200

The Creating Two-Way Communication section explains how to use the Bluefruit mobile app to create a peripheral. However, the Bluefruit mobile app no longer has the Peripheral Mode feature described in the text, so the instructions in this section are no longer valid.

The text-server example may be used as a replacement if you have a second ESP32 device. To use this example, follow these steps:

  • Connect one of your ESP32 devices to your computer with a USB cable.

  • Install the text-server example on the ESP32 using mcconfig.

     cd $EXAMPLES/ch4-ble/text-server
     mcconfig -m -p esp32
    
  • Disconnect the first ESP32 and connect the other ESP32.

  • Install the text-client example as described in the book.

  • Connect the first ESP32 to a power source.

The devices will automatically pair, and the text-client will subscribe to notifications from the text-server as described. However, instead of typing in messages and manually sending them from your phone, the text-server app will automatically sends a message every second.


Page 243

In this example, the second parameter to slice is incorrect.

let r1 = new Resource("myData.dat");
let values = new Uint16Array(r1.slice(32, 10, false));

The second parameter is the end position of the slice, not the byte length of the slice. The correct code is:

let r1 = new Resource("myData.dat");
let values = new Uint16Array(r1.slice(32, 32 + 10, false));

Page 266

The Monitoring for Changes section does not provide the import statement for the Monitor class used in Listing 6-5.

import Monitor from "pins/digital/monitor";

Page 338

Figure 8-8 shows the same circle mask drawn in blue (which appears gray in printed versions of this book).

The comment in parentheses is incorrect. The book is published in color, though it was planned to be published in grayscale.