support for buffer packet type (#608)

* support for buffer packet type

* updated description

* updated signature

* added note on json encoding

* adding sendNumbers

* cleanup

* removing 'sendnumbers'
This commit is contained in:
Peli de Halleux
2018-01-30 10:11:12 -08:00
committed by GitHub
parent 79018d4f00
commit 07a578831c
7 changed files with 201 additions and 19 deletions

17
libs/radio/shims.d.ts vendored
View File

@ -33,6 +33,15 @@ declare namespace radio {
//% blockId=radio_datagram_send_string block="radio send string %msg" shim=radio::sendString
function sendString(msg: string): void;
/**
* Broadcasts a buffer (up to 19 bytes long) along with the device serial number
* and running time to any connected micro:bit in the group.
*/
//% help=radio/send-buffer
//% weight=57
//% advanced=true shim=radio::sendBuffer
function sendBuffer(msg: Buffer): void;
/**
* Reads the next packet from the radio queue and and writes it to serial
* as JSON.
@ -148,6 +157,14 @@ declare namespace radio {
//% help=radio/received-string shim=radio::receivedString
function receivedString(): string;
/**
* Returns the buffer payload from the last packet taken from the radio queue
* (via ``receiveNumber``, ``receiveString``, etc) or the empty string if that
* packet did not contain a string.
*/
//% help=radio/received-buffer shim=radio::receivedBuffer
function receivedBuffer(): Buffer;
/**
* Returns the system time of the sender micro:bit at the moment when it sent the
* last packet taken from the radio queue (via ``receiveNumber``,