aboutsummaryrefslogtreecommitdiff
path: root/docs/buffer.md
diff options
context:
space:
mode:
authorGeoff Gustafson <geoff@linux.intel.com>2016-08-23 17:40:40 -0700
committerGeoff Gustafson <geoff@linux.intel.com>2016-08-23 17:40:40 -0700
commitc95cfe89a1e920afd735f79c33f344e10ec09828 (patch)
treed684ecfc120816275b5c101c202c7ad35ba8d37b /docs/buffer.md
parent3e4c7e0abd862645a6fc7bfbb4e96c482464ea06 (diff)
[Docs] Add K64F pins and Buffer documentation
Signed-off-by: Geoff Gustafson <geoff@linux.intel.com>
Diffstat (limited to 'docs/buffer.md')
-rw-r--r--docs/buffer.md68
1 files changed, 68 insertions, 0 deletions
diff --git a/docs/buffer.md b/docs/buffer.md
new file mode 100644
index 0000000..88031b6
--- /dev/null
+++ b/docs/buffer.md
@@ -0,0 +1,68 @@
+Zephyr.js API for Buffer
+========================
+
+* [Introduction](#introduction)
+* [Web IDL](#web-idl)
+* [API Documentation](#api-documentation)
+* [Sample Apps](#sample-apps)
+
+Introduction
+------------
+Buffer is a [node.js API]
+(https://nodejs.org/dist/latest-v6.x/docs/api/buffer.html)
+to read and write binary data accurately from JavaScript. Zephyr.js supports a
+minimal subset of this API that will be expanded as the need arises.
+
+Web IDL
+-------
+This IDL provides an overview of the interface; see below for documentation of
+specific API functions.
+
+```javascript
+// Buffer is a global object constructor that is always available
+
+[Constructor(unsigned long length)]
+interface Buffer {
+ unsigned char readUInt8(unsigned long offset);
+ void writeUInt8(unsigned char value, unsigned long offset);
+ string toString(string encoding);
+ readonly attribute unsigned long length;
+};
+```
+
+API Documentation
+-----------------
+### Buffer constructor
+
+`Buffer(unsigned long length);`
+
+The `length` argument specifies the length in bytes of the Buffer object.
+
+### Buffer.readUInt8
+
+`unsigned char readUInt8(unsigned long offset);`
+
+The `offset` should be provided but will be treated as 0 if not given. Returns
+the value of the byte located at the given offset. If the offset is outside the
+bounds of the Buffer, returns an error.
+
+### Buffer.writeUInt8
+
+`void writeUInt8(unsigned char value, unsigned long offset);`
+
+The `offset` should be provided but will be treated as 0 if not given. Writes
+`value` to the byte located at the given offset. If the offset is outside the
+bounds of the Buffer, returns an error.
+
+### Buffer.toString
+
+`string toString(string encoding);`
+
+Currently, the only supported `encoding` is 'hex'. If 'hex' is given, returns
+the contents of the Buffer encoded in hexadecimal digits. Otherwises, returns an
+error.
+
+Sample Apps
+-----------
+* [Buffer sample](../samples/Buffer.js)
+* [WebBluetooth Demo](../samples/WebBluetoothDemo.js)