diff --git a/README.md b/README.md
index e1ba78d..b9b374b 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ On the server device, the server instance can retrieve the data from acceleromet
(new class extends ZapServer {
// Define the method that is called whenever accelerometer sensor data is
// received from client devices.
- onAccelerometerChanged(info: MetaInfo, data: ZapAccelerometer) {
+ onAccelerometerReceived(info: MetaInfo, data: ZapAccelerometer) {
console.log(`Data received from ${info.dgram.address}: (${data.x}, ${data.y}, ${data.z})`);
}
}).listen();
diff --git a/src/architectures/zap-protocol.md b/src/architectures/zap-protocol.md
index 0c7bfec..944d5fd 100644
--- a/src/architectures/zap-protocol.md
+++ b/src/architectures/zap-protocol.md
@@ -10,4 +10,4 @@ The header consists of a timestamp and a resource field. The first 64 bits of th
Following the timestamp, the next 8 bits constitute the resource field. The resource field informs which resource the payload represents and simultaneously implies how the payload is encoded. This field can be interpreted as an unsigned integer.
-After the 72-bit header, there is the payload part. The format of the payload varies depending on the resource. It can be a simple primitive type, text with delimiters, or JSON. The maximum length of the payload is theoretically up to 65,518 bytes, although it may vary depending on the implementation of Zap server.
+After the 72-bit header, there is the payload part. The format of the payload varies depending on the resource. It can be a simple primitive type, text with delimiters, or JSON. Refer to the [Resources](../specifications/resources.md) page for information on the payload format each resource takes. The maximum length of the payload is theoretically up to 65,518 bytes, although it may vary depending on the implementation of Zap server.
diff --git a/src/getting-started.md b/src/getting-started.md
index c84d94a..3b66699 100644
--- a/src/getting-started.md
+++ b/src/getting-started.md
@@ -19,7 +19,7 @@ Now, simply create an index.js file and write the Zap server. This server will r
import { ZapServer } from 'zap-lib-js';
(new class extends ZapServer {
- onAccelerometerChanged(info, data) {
+ onAccelerometerReceived(info, data) {
console.log(`Data received from ${info.dgram.address}: (${data.x}, ${data.y}, ${data.z})`);
}
}).listen();
diff --git a/src/introduction.md b/src/introduction.md
index a3bd3f7..6793a7e 100644
--- a/src/introduction.md
+++ b/src/introduction.md
@@ -46,7 +46,7 @@ On the server device, the server instance can retrieve the data from acceleromet
(new class extends ZapServer {
// Define the method that is called whenever accelerometer sensor data is
// received from client devices.
- onAccelerometerChanged(info: MetaInfo, data: ZapAccelerometer) {
+ onAccelerometerReceived(info: MetaInfo, data: ZapAccelerometer) {
console.log(`Data received from ${info.dgram.address}:
(${data.x}, ${data.y}, ${data.z})`);
}
diff --git a/src/specifications/client-and-server.md b/src/specifications/client-and-server.md
index 958c273..ef9552f 100644
--- a/src/specifications/client-and-server.md
+++ b/src/specifications/client-and-server.md
@@ -18,9 +18,14 @@ A server receives data from client. The 'open function' refers to a callback fun
|------|-----------|-------------|
| function | `listen(port: int): void` | Start listening the transmitted data from clients on the given port.
`port`: A port number for receiving data (default: `65500`). |
| function | `stop(): void` | Stop listening to clients. |
-| open function | `onAccelerometerChanged(info: MetaInfo, data: ZapAccelerometer): void` | A callback function called whenever accelerometer sensor data is received. |
+| open function | `onAccelerometerReceived(info: MetaInfo, data: ZapAccelerometer): void` | A callback function called whenever accelerometer sensor data is received. |
+| open function | `onGeoPointReceived(info: MetaInfo, data: ZapGeoPoint): void` | A callback function called whenever geological point is received. |
+| open function | `onGravityReceived(info: MetaInfo, data: ZapGravity): void` | A callback function called whenever gravity data is received. |
+| open function | `onGyroscopeReceived(info: MetaInfo, data: ZapGyroscope): void` | A callback function called whenever gyroscope data is received. |
+| open function | `onIlluminanceReceived(info: MetaInfo, data: ZapIlluminance): void` | A callback function called whenever illuminance data is received. |
+| open function | `onMagneticFieldReceived(info: MetaInfo, data: ZapMagneticField): void` | A callback function called whenever magnetic field data is received. |
| open function | `onUIEventReceived(info: MetaInfo, data: ZapUiEvent): void` | A callback function called whenever UI event data is received. |
-| open function | `onTextReceived(info: MetaInfo, data: ZapText): void` | A callback function called whenever text data is received.|
+| open function | `onTextReceived(info: MetaInfo, data: ZapText): void` | A callback function called whenever text data is received. |
The server implementation, upon receiving a datagram, MUST reference the `ZappHeader` to identify the resource and then invoke the corresponding callback function for that resource. For detailed specifications on supported resources, please refer to [Resources](./resources.md) section.
diff --git a/src/specifications/resources.md b/src/specifications/resources.md
index 2488958..e280e42 100644
--- a/src/specifications/resources.md
+++ b/src/specifications/resources.md
@@ -4,30 +4,94 @@
A registry of resources supported by Zap and their identification keys.
-| property | key
(8-bit uint) | description |
+| property | key
(8-bit uint) | type |
|------|-----------|-------------|
-| `ACCELEROMETER` | 10 | A data measured by an accelerometer sensor. |
-| `UI_EVENT` | 20 | A data related to event raised by the user interface. |
-| `TEXT` | 30 | A simple text data. |
+| `ACCELEROMETER` | 10 | `ZapAccelerometer` |
+| `GRAVITY` | 11 | `ZapGravity` |
+| `GYROSCOPE` | 12 | `ZapGyroscope` |
+| `ILLUMINANCE` | 13 | `ZapIlluminance` |
+| `MAGNETIC_FIELD` | 14 | `ZapMagneticField` |
+| `UI_EVENT` | 20 | `ZapUiEvent` |
+| `TEXT` | 30 | `ZapText` |
+| `GEO_POINT` | 31 | `ZapGeoPoint` |
-## `ZapText`
+## `ZapAccelerometer`
-Represent simple text.
+Represent values measured by accelerometer sensor
+
+```text
++-------------+-------------+-------------+
+| x (32 bits) | y (32 bits) | z (32 bits) |
++-------------+-------------+-------------+
+```
| type | signature | description |
|------|-----------|-------------|
-| property | `str: string` | Just string. |
-| property | `charset` | A character set of `str`. (default: UTF-8) |
+| property | `x: float` | Acceleration force along the x axis. (m/s²) |
+| property | `y: float` | Acceleration force along the y axis. (m/s²) |
+| property | `z: float` | Acceleration force along the z axis. (m/s²) |
-## `ZapAccelerometer`
+## `ZapGravity`
+
+Represent the force of gravity that is applied to a device.
-Represent values measured by accelerometer sensor.
+```text
++-------------+-------------+-------------+
+| x (32 bits) | y (32 bits) | z (32 bits) |
++-------------+-------------+-------------+
+```
| type | signature | description |
|------|-----------|-------------|
-| property | `x: float` | Acceleration force along the x axis. (m/s²) |
-| property | `y: float` | Acceleration force along the y axis. (m/s²) |
-| property | `z: float` | Acceleration force along the z axis. (m/s²) |
+| property | `x: float` | Force of gravity along the x axis. (m/s²) |
+| property | `y: float` | Force of gravity along the y axis. (m/s²) |
+| property | `z: float` | Force of gravity along the z axis. (m/s²) |
+
+## `ZapGyroscope`
+
+Represent a device's rate of rotation.
+
+```text
++-------------+-------------+-------------+
+| x (32 bits) | y (32 bits) | z (32 bits) |
++-------------+-------------+-------------+
+```
+
+| type | signature | description |
+|------|-----------|-------------|
+| property | `x: float` | Rate of rotation around the x axis. (rad/s) |
+| property | `y: float` | Rate of rotation around the y axis. (rad/s) |
+| property | `z: float` | Rate of rotation around the z axis. (rad/s) |
+
+## `ZapIlluminance`
+
+Represent the ambient light level.
+
+```text
++--------------+
+| lx (32 bits) |
++--------------+
+```
+
+| type | signature | description |
+|------|-----------|-------------|
+| property | `lx: float` | Ambient light level. (lx) |
+
+## `ZapMagneticField`
+
+Represent a ambient geomagnetic field.
+
+```text
++-------------+-------------+-------------+
+| x (32 bits) | y (32 bits) | z (32 bits) |
++-------------+-------------+-------------+
+```
+
+| type | signature | description |
+|------|-----------|-------------|
+| property | `x: float` | Geomagnetic field strength along the x axis. (μT) |
+| property | `y: float` | Geomagnetic field strength along the y axis. (μT) |
+| property | `z: float` | Geomagnetic field strength along the z axis. (μT) |
## `ZapUiEvent`
@@ -45,3 +109,27 @@ Represent data related to event raised by the user interface.
|------|-----------|-------------|
| `CLICK_DOWN` | `CLICK_DOWN` | An event triggered when a click (or touch) is initiated on the UI. |
| `CLICK_UP` | `CLICK_UP` | An event triggered when a click (or touch) on the UI has ended. |
+
+## `ZapText`
+
+Represent simple text.
+
+| type | signature | description |
+|------|-----------|-------------|
+| property | `str: string` | Just string. |
+| property | `charset` | A character set of `str`. (default: UTF-8) |
+
+## `ZapGeoPoint`
+
+Represent a point on earth in geological coordinates.
+
+```text
++--------------------+---------------------+
+| latitude (64 bits) | longitude (64 bits) |
++--------------------+---------------------+
+```
+
+| type | signature | description |
+|------|-----------|-------------|
+| property | `latitude: double` | A latitude of the point. |
+| property | `longitude: double` | A longitude of the point. |