Radiodocsupdate (#1430)
* a few updates * more updates * reorder radio blocks * more shuffling of new radio apis * fixing hot or ocold * more doc fixes * more updates * fixing docs issues * more doc fixes * restore docs errors * missing packate * renamed argument of callback * mssing radio * more odcs fixes * lock turtle * ignore docs for now
This commit is contained in:
@ -8,8 +8,6 @@
|
||||
"radio.Packet.time": "The system time of the sender of the packet at the time the packet was sent.",
|
||||
"radio._packetProperty": "Gets a packet property.",
|
||||
"radio._packetProperty|param|type": "the packet property type, eg: PacketProperty.time",
|
||||
"radio.getReceivedPacketProperty": "Returns properties of the last radio packet received.",
|
||||
"radio.getReceivedPacketProperty|param|type": "the type of property to retrieve from the last packet",
|
||||
"radio.onDataPacketReceived": "Registers code to run when the radio receives a packet. Also takes the\nreceived packet from the radio queue.",
|
||||
"radio.onDataReceived": "Registers code to run when a packet is received over radio.",
|
||||
"radio.onReceivedBuffer": "Registers code to run when the radio receives a buffer.",
|
||||
@ -21,6 +19,8 @@
|
||||
"radio.receiveString": "Reads the next packet from the radio queue and returns the packet's string\npayload or the empty string if the packet did not contain a string.",
|
||||
"radio.receivedBuffer": "Returns the buffer payload from the last packet taken from the radio queue\n(via ``receiveNumber``, ``receiveString``, etc) or the empty string if that\npacket did not contain a string.",
|
||||
"radio.receivedNumber": "Returns the number payload from the last packet taken from the radio queue\n(via ``receiveNumber``, ``receiveString``, etc) or 0 if that packet did not\ncontain a number.",
|
||||
"radio.receivedPacket": "Returns properties of the last radio packet received.",
|
||||
"radio.receivedPacket|param|type": "the type of property to retrieve from the last packet",
|
||||
"radio.receivedSerial": "Returns the serial number of the sender micro:bit from the last packet taken\nfrom the radio queue (via ``receiveNumber``, ``receiveString``, etc) or 0 if\nthat packet did not send a serial number.",
|
||||
"radio.receivedSignalStrength": "Gets the received signal strength indicator (RSSI) from the last packet taken\nfrom the radio queue (via ``receiveNumber``, ``receiveString``, etc). Not supported in simulator.\nnamespace=radio",
|
||||
"radio.receivedString": "Returns the string payload from the last packet taken from the radio queue\n(via ``receiveNumber``, ``receiveString``, etc) or the empty string if that\npacket did not contain a string.",
|
||||
|
@ -1,9 +1,8 @@
|
||||
{
|
||||
"radio.PacketProperty.SerialNumber|block": "serial number",
|
||||
"radio.PacketProperty.SignalStrength|block": "signal strength",
|
||||
"radio.PacketProperty.Time|block": "time",
|
||||
"RadioPacketProperty.SerialNumber|block": "serial number",
|
||||
"RadioPacketProperty.SignalStrength|block": "signal strength",
|
||||
"RadioPacketProperty.Time|block": "time",
|
||||
"radio._packetProperty|block": "%note",
|
||||
"radio.getReceivedPacketProperty|block": "received packet %type=radio_packet_property",
|
||||
"radio.onDataPacketReceived|block": "on radio received",
|
||||
"radio.onDataReceived|block": "radio on data received",
|
||||
"radio.onReceivedBuffer|block": "on radio received",
|
||||
@ -13,6 +12,7 @@
|
||||
"radio.raiseEvent|block": "radio raise event|from source %src=control_event_source_id|with value %value=control_event_value_id",
|
||||
"radio.receiveNumber|block": "radio receive number",
|
||||
"radio.receiveString|block": "radio receive string",
|
||||
"radio.receivedPacket|block": "received packet %type=radio_packet_property",
|
||||
"radio.receivedSignalStrength|block": "radio received signal strength",
|
||||
"radio.sendNumber|block": "radio send number %value",
|
||||
"radio.sendString|block": "radio send string %msg",
|
||||
|
@ -1,3 +1,16 @@
|
||||
|
||||
enum RadioPacketProperty {
|
||||
//% blockIdentity=radio._packetProperty
|
||||
//% block="signal strength"
|
||||
SignalStrength = 2,
|
||||
//% blockIdentity=radio._packetProperty
|
||||
//% block="time"
|
||||
Time = 0,
|
||||
//% block="serial number"
|
||||
//% blockIdentity=radio._packetProperty
|
||||
SerialNumber = 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Communicate data using radio packets
|
||||
*/
|
||||
@ -33,18 +46,6 @@ namespace radio {
|
||||
public signal: number;
|
||||
}
|
||||
|
||||
export enum PacketProperty {
|
||||
//% blockIdentity=radio._packetProperty
|
||||
//% block="time"
|
||||
Time,
|
||||
//% block="serial number"
|
||||
//% blockIdentity=radio._packetProperty
|
||||
SerialNumber,
|
||||
//% blockIdentity=radio._packetProperty
|
||||
//% block="signal strength"
|
||||
SignalStrength
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers code to run when the radio receives a packet. Also takes the
|
||||
* received packet from the radio queue.
|
||||
@ -133,7 +134,7 @@ namespace radio {
|
||||
//% help=radio/on-received-buffer blockHandlerKey="radioreceived" blockHidden=1
|
||||
//% blockId=radio_on_buffer block="on radio received" blockGap=16
|
||||
//% useLoc="radio.onDataPacketReceived"
|
||||
export function onReceivedBuffer(cb: (buffer: Buffer) => void) {
|
||||
export function onReceivedBuffer(cb: (receivedBuffer: Buffer) => void) {
|
||||
onDataReceived(() => {
|
||||
receiveNumber();
|
||||
const packet = new Packet();
|
||||
@ -151,14 +152,15 @@ namespace radio {
|
||||
* Returns properties of the last radio packet received.
|
||||
* @param type the type of property to retrieve from the last packet
|
||||
*/
|
||||
//% help=radio/get-received-packet-property advanced=true
|
||||
//% blockId=radio_received_packet_property block="received packet %type=radio_packet_property" blockGap=16
|
||||
export function getReceivedPacketProperty(type: number) {
|
||||
//% help=radio/received-packet
|
||||
//% weight=11 blockGap=8
|
||||
//% blockId=radio_received_packet block="received packet %type=radio_packet_property" blockGap=16
|
||||
export function receivedPacket(type: number) {
|
||||
if (lastPacket) {
|
||||
switch(type) {
|
||||
case PacketProperty.Time: return lastPacket.time;
|
||||
case PacketProperty.SerialNumber: return lastPacket.serial;
|
||||
case PacketProperty.SignalStrength: return lastPacket.signal;
|
||||
case RadioPacketProperty.Time: return lastPacket.time;
|
||||
case RadioPacketProperty.SerialNumber: return lastPacket.serial;
|
||||
case RadioPacketProperty.SignalStrength: return lastPacket.signal;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -170,7 +172,7 @@ namespace radio {
|
||||
*/
|
||||
//% blockId=radio_packet_property block="%note"
|
||||
//% shim=TD_ID blockHidden=1
|
||||
export function _packetProperty(type: PacketProperty): number {
|
||||
export function _packetProperty(type: RadioPacketProperty): number {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user