2016-04-03 02:34:06 +02:00
|
|
|
// Auto-generated. Do not edit.
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-02 18:32:08 +02:00
|
|
|
//% color=#E3008C weight=96 icon="\uf012"
|
2016-04-03 02:34:06 +02:00
|
|
|
declare namespace radio {
|
|
|
|
|
2018-10-08 18:46:23 +02:00
|
|
|
/**
|
|
|
|
* Sends an event over radio to neigboring devices
|
|
|
|
*/
|
|
|
|
//% blockId=radioRaiseEvent block="radio raise event|from source %src=control_event_source_id|with value %value=control_event_value_id"
|
|
|
|
//% blockExternalInputs=1
|
|
|
|
//% advanced=true
|
|
|
|
//% weight=1
|
|
|
|
//% help=radio/raise-event shim=radio::raiseEvent
|
|
|
|
function raiseEvent(src: int32, value: int32): void;
|
|
|
|
|
2016-04-03 02:34:06 +02:00
|
|
|
/**
|
2016-05-11 06:13:16 +02:00
|
|
|
* Broadcasts a number over radio to any connected micro:bit in the group.
|
2016-04-03 02:34:06 +02:00
|
|
|
*/
|
2016-05-11 06:13:16 +02:00
|
|
|
//% help=radio/send-number
|
|
|
|
//% weight=60
|
2016-08-02 01:02:06 +02:00
|
|
|
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8 shim=radio::sendNumber
|
2018-04-21 19:25:43 +02:00
|
|
|
function sendNumber(value: int32): void;
|
2016-04-03 02:34:06 +02:00
|
|
|
|
2016-05-10 07:55:37 +02:00
|
|
|
/**
|
|
|
|
* Broadcasts a name / value pair along with the device serial number
|
2016-08-02 01:02:06 +02:00
|
|
|
* and running time to any connected micro:bit in the group.
|
2016-10-27 23:48:22 +02:00
|
|
|
* @param name the field name (max 12 characters), eg: "name"
|
2016-05-11 06:13:16 +02:00
|
|
|
* @param value the numberic value
|
2016-05-10 07:55:37 +02:00
|
|
|
*/
|
2016-05-11 01:42:18 +02:00
|
|
|
//% help=radio/send-value
|
2016-05-11 06:13:16 +02:00
|
|
|
//% weight=59
|
2016-08-02 01:02:06 +02:00
|
|
|
//% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8 shim=radio::sendValue
|
2018-04-21 19:25:43 +02:00
|
|
|
function sendValue(name: string, value: int32): void;
|
2016-05-10 07:55:37 +02:00
|
|
|
|
2016-05-12 21:35:40 +02:00
|
|
|
/**
|
2016-10-24 21:55:44 +02:00
|
|
|
* Broadcasts a string along with the device serial number
|
|
|
|
* and running time to any connected micro:bit in the group.
|
2016-05-12 21:35:40 +02:00
|
|
|
*/
|
|
|
|
//% help=radio/send-string
|
|
|
|
//% weight=58
|
2018-08-02 22:30:02 +02:00
|
|
|
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
|
|
|
//% msg.shadowOptions.toString=true shim=radio::sendString
|
2016-05-12 21:35:40 +02:00
|
|
|
function sendString(msg: string): void;
|
|
|
|
|
2018-01-30 19:11:12 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2016-05-10 07:55:37 +02:00
|
|
|
/**
|
2016-10-24 21:55:44 +02:00
|
|
|
* Reads the next packet from the radio queue and and writes it to serial
|
|
|
|
* as JSON.
|
2016-05-10 07:55:37 +02:00
|
|
|
*/
|
2016-05-11 06:13:16 +02:00
|
|
|
//% help=radio/write-value-to-serial
|
|
|
|
//% weight=3
|
2016-10-11 22:48:25 +02:00
|
|
|
//% blockId=radio_write_value_serial block="radio write value to serial"
|
2016-10-26 01:38:01 +02:00
|
|
|
//% deprecated=true shim=radio::writeValueToSerial
|
2016-05-11 06:13:16 +02:00
|
|
|
function writeValueToSerial(): void;
|
2016-05-10 07:55:37 +02:00
|
|
|
|
2016-10-26 01:38:01 +02:00
|
|
|
/**
|
|
|
|
* Writes the last received packet to serial as JSON. This should be called
|
|
|
|
* within an ``onDataPacketReceived`` callback.
|
|
|
|
*/
|
|
|
|
//% help=radio/write-received-packet-to-serial
|
|
|
|
//% weight=3
|
|
|
|
//% blockId=radio_write_packet_serial block="radio write received packet to serial"
|
|
|
|
//% advanced=true shim=radio::writeReceivedPacketToSerial
|
|
|
|
function writeReceivedPacketToSerial(): void;
|
|
|
|
|
2016-04-03 02:34:06 +02:00
|
|
|
/**
|
2016-10-24 21:55:44 +02:00
|
|
|
* Reads the next packet from the radio queue and returns the packet's number
|
|
|
|
* payload or 0 if the packet did not contain a number.
|
2016-04-03 02:34:06 +02:00
|
|
|
*/
|
|
|
|
//% help=radio/receive-number
|
|
|
|
//% weight=46
|
2016-10-24 21:55:44 +02:00
|
|
|
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8
|
2016-10-25 01:30:21 +02:00
|
|
|
//% deprecated=true shim=radio::receiveNumber
|
2018-04-21 19:25:43 +02:00
|
|
|
function receiveNumber(): int32;
|
2016-04-03 02:34:06 +02:00
|
|
|
|
2016-08-09 01:54:43 +02:00
|
|
|
/**
|
|
|
|
* Registers code to run when a packet is received over radio.
|
|
|
|
*/
|
|
|
|
//% help=radio/on-data-received
|
|
|
|
//% weight=50
|
2016-10-24 21:55:44 +02:00
|
|
|
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
|
2016-10-25 01:30:21 +02:00
|
|
|
//% deprecated=true shim=radio::onDataReceived
|
2016-08-09 01:54:43 +02:00
|
|
|
function onDataReceived(body: () => void): void;
|
|
|
|
|
2016-05-12 21:35:40 +02:00
|
|
|
/**
|
2016-10-24 21:55:44 +02:00
|
|
|
* Reads the next packet from the radio queue and returns the packet's string
|
|
|
|
* payload or the empty string if the packet did not contain a string.
|
2016-05-12 21:35:40 +02:00
|
|
|
*/
|
2016-08-02 01:02:06 +02:00
|
|
|
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
|
2016-05-12 21:35:40 +02:00
|
|
|
//% weight=44
|
2016-10-24 21:55:44 +02:00
|
|
|
//% help=radio/receive-string
|
2016-10-25 01:30:21 +02:00
|
|
|
//% deprecated=true shim=radio::receiveString
|
2016-05-12 21:35:40 +02:00
|
|
|
function receiveString(): string;
|
|
|
|
|
2016-04-03 02:34:06 +02:00
|
|
|
/**
|
2016-10-24 21:55:44 +02:00
|
|
|
* Gets the received signal strength indicator (RSSI) from the last packet taken
|
|
|
|
* from the radio queue (via ``receiveNumber``, ``receiveString``, etc). Not supported in simulator.
|
2016-04-03 02:34:06 +02:00
|
|
|
* namespace=radio
|
|
|
|
*/
|
|
|
|
//% help=radio/received-signal-strength
|
|
|
|
//% weight=40
|
2016-10-11 22:48:25 +02:00
|
|
|
//% blockId=radio_datagram_rssi block="radio received signal strength"
|
2016-10-25 01:30:21 +02:00
|
|
|
//% deprecated=true shim=radio::receivedSignalStrength
|
2018-04-21 19:25:43 +02:00
|
|
|
function receivedSignalStrength(): int32;
|
2016-04-03 02:34:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time.
|
2017-03-04 08:39:42 +01:00
|
|
|
* @param id the group id between ``0`` and ``255``, eg: 1
|
2016-04-03 02:34:06 +02:00
|
|
|
*/
|
|
|
|
//% help=radio/set-group
|
2017-03-01 23:57:47 +01:00
|
|
|
//% weight=10 blockGap=8
|
2017-03-04 08:39:42 +01:00
|
|
|
//% blockId=radio_set_group block="radio set group %ID"
|
|
|
|
//% id.min=0 id.max=255 shim=radio::setGroup
|
2018-04-21 19:25:43 +02:00
|
|
|
function setGroup(id: int32): void;
|
2016-04-03 02:34:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the output power level of the transmitter to the given value.
|
2016-06-19 14:15:13 +02:00
|
|
|
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
|
2016-04-03 02:34:06 +02:00
|
|
|
*/
|
|
|
|
//% help=radio/set-transmit-power
|
2016-08-02 01:02:06 +02:00
|
|
|
//% weight=9 blockGap=8
|
2016-10-11 22:48:25 +02:00
|
|
|
//% blockId=radio_set_transmit_power block="radio set transmit power %power"
|
2017-03-04 08:39:42 +01:00
|
|
|
//% power.min=0 power.max=7
|
2016-10-11 22:48:25 +02:00
|
|
|
//% advanced=true shim=radio::setTransmitPower
|
2018-04-21 19:25:43 +02:00
|
|
|
function setTransmitPower(power: int32): void;
|
2016-05-11 06:13:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the radio to transmit the serial number in each message.
|
2016-10-12 04:36:00 +02:00
|
|
|
* @param transmit value indicating if the serial number is transmitted, eg: true
|
2016-05-11 06:13:16 +02:00
|
|
|
*/
|
|
|
|
//% help=radio/set-transmit-serial-number
|
2016-08-02 01:02:06 +02:00
|
|
|
//% weight=8 blockGap=8
|
2016-10-11 22:48:25 +02:00
|
|
|
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit"
|
|
|
|
//% advanced=true shim=radio::setTransmitSerialNumber
|
2016-05-11 06:13:16 +02:00
|
|
|
function setTransmitSerialNumber(transmit: boolean): void;
|
2016-10-24 21:55:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number payload from the last packet taken from the radio queue
|
|
|
|
* (via ``receiveNumber``, ``receiveString``, etc) or 0 if that packet did not
|
|
|
|
* contain a number.
|
|
|
|
*/
|
|
|
|
//% help=radio/received-number shim=radio::receivedNumber
|
2018-04-21 19:25:43 +02:00
|
|
|
function receivedNumber(): int32;
|
2016-10-24 21:55:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the serial number of the sender micro:bit from the last packet taken
|
|
|
|
* from the radio queue (via ``receiveNumber``, ``receiveString``, etc) or 0 if
|
|
|
|
* that packet did not send a serial number.
|
|
|
|
*/
|
|
|
|
//% help=radio/received-serial shim=radio::receivedSerial
|
2018-04-21 19:25:43 +02:00
|
|
|
function receivedSerial(): uint32;
|
2016-10-24 21:55:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the string 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-string shim=radio::receivedString
|
|
|
|
function receivedString(): string;
|
|
|
|
|
2018-01-30 19:11:12 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2016-10-24 21:55:44 +02:00
|
|
|
/**
|
|
|
|
* 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``,
|
|
|
|
* ``receiveString``, etc).
|
|
|
|
*/
|
|
|
|
//% help=radio/received-time shim=radio::receivedTime
|
2018-04-21 19:25:43 +02:00
|
|
|
function receivedTime(): uint32;
|
2016-04-03 02:34:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Auto-generated. Do not edit. Really.
|