Remote data topic for the analyze docs (#720)

* Remote data topic for the analyze docs

* Add 'see also'

* Spelling typo

* Add more info about serial number usage

* Expand the example
This commit is contained in:
Galen Nickel
2018-03-27 18:26:35 -07:00
committed by Peli de Halleux
parent 0ec922c7f4
commit 5d6f3cd598
6 changed files with 182 additions and 8 deletions

View File

@ -8,7 +8,7 @@ radio.setTransmitSerialNumber(true);
## Parameters
* ``transmit`` is a [boolean](/types/boolean) that represents whether the serial number needs to be transmitted.
* ``transmit`` is a [boolean](/types/boolean) that, when ``true``, means that the board serial number is included in each transmitted packet. If ``false``, the serial number value is set to `0`.
## Example

View File

@ -10,21 +10,31 @@ radio.writeReceivedPacketToSerial();
## Data received format
The format for received data printed to serial is as follows:
The format for received data when these send functions are used:
- [send number](/reference/radio/send-number): ```{v:ValueSent,t:MicrobitTimeAlive,s:SerialNumber}```
- [send value](/reference/radio/send-value): ```{v:ValueSent,t:MicrobitTimeAlive,s:SerialNumber,n:"Name"}```
- [send string](/reference/radio/send-string): ```{t:MicrobitTimeAlive,s:SerialNumber,n:"Text"}```
## Examples
### ~hint
The serial number value sent in the packet is set to `0` unless transmission of the serial number is enabled with ``||radio:radio set transmit serial number||``.
### ~
## Example
When ```radio``` data is received (after pressing the ``A`` button on
the second @boardname@), this program sends temperature data to
serial.
the second @boardname@), this program sends temperature data to the
serial port.
```blocks
input.onButtonPressed(Button.A, () => {
radio.sendNumber(input.temperature());
radio.sendValue("temperature", input.temperature());
radio.sendString("It's warm now");
});
radio.onDataPacketReceived(() => {
radio.writeReceivedPacketToSerial();
@ -32,8 +42,10 @@ radio.onDataPacketReceived(() => {
```
Sample output to serial when ``A`` button pressed:
```Text
{v:27,t:323,s:0}
```json
{"t":323,"s":0,"v":27}
{"t":325,"s":0,"n":"temperature","v":27}
{"t":326,"s":0,"n":"It's warm now"}
```
## See also
@ -41,7 +53,8 @@ Sample output to serial when ``A`` button pressed:
[send number](/reference/radio/send-number),
[send value](/reference/radio/send-value),
[send string](/reference/radio/send-string),
[on data packet received](/reference/radio/on-data-packet-received)
[on data packet received](/reference/radio/on-data-packet-received),
[set transmit serial number](/reference/radio/set-transmit-serial-number)
```package
radio