From 3761d1282a82eb1315327f623df7f28039e371d2 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 5 Apr 2019 10:45:06 -0700 Subject: [PATCH] Update the max length of a name in a sendValue packet (#1965) --- docs/reference/radio/send-value.md | 2 +- libs/radio/radio.cpp | 9 +++++---- sim/state/radio.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/reference/radio/send-value.md b/docs/reference/radio/send-value.md index 8bff6537..b3737c1b 100644 --- a/docs/reference/radio/send-value.md +++ b/docs/reference/radio/send-value.md @@ -1,7 +1,7 @@ # send Value Send a [string]() and [number]() together by ``radio`` to other @boardname@s. -The maximum [string]() length is 12 characters. +The maximum [string]() length is 8 characters. ```sig radio.sendValue("name", 0); diff --git a/libs/radio/radio.cpp b/libs/radio/radio.cpp index c8baef1b..739dcede 100644 --- a/libs/radio/radio.cpp +++ b/libs/radio/radio.cpp @@ -71,7 +71,7 @@ namespace radio { /** * 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" + //% 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 @@ -259,8 +259,9 @@ namespace radio { /** * Broadcasts a name / value pair along with the device serial number - * and running time to any connected micro:bit in the group. - * @param name the field name (max 12 characters), eg: "name" + * and running time to any connected micro:bit in the group. The name can + * include no more than 8 characters. + * @param name the field name (max 8 characters), eg: "name" * @param value the numeric value */ //% help=radio/send-value @@ -360,7 +361,7 @@ namespace radio { return fromInt(ivalue); else if (type == PACKET_TYPE_DOUBLE || type == PACKET_TYPE_DOUBLE_VALUE) return fromDouble(dvalue); - else + else return fromInt(0); } diff --git a/sim/state/radio.ts b/sim/state/radio.ts index 58d3344e..de13172c 100644 --- a/sim/state/radio.ts +++ b/sim/state/radio.ts @@ -160,7 +160,7 @@ namespace pxsim.radio { } export function sendValue(name: string, value: number) { - name = name.substr(0, 12); + name = name.substr(0, 8); const msg: number[] = []; msg.push() board().radioState.datagram.send({