From 418d08bc7a7fbf08c65ab9623874ed1e6b19092c Mon Sep 17 00:00:00 2001 From: Hideaki Tai Date: Wed, 25 Nov 2020 19:56:16 +0900 Subject: [PATCH] =?UTF-8?q?fix=20callback=20argument=E2=80=99s=20const=20o?= =?UTF-8?q?f=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aa4792e..d168c7a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Please use them depending on the situation. - Artnet (Integrated Sender/Receiver) -#### Warning +### Warning **From v0.1.11, arguments of callbacks must be `const` for safety. Previous sketches can not be compiled as is, so please add `const` to the arguments of callbacks.** @@ -57,7 +57,7 @@ void loop() ArtnetReceiver artnet; -void callback(uint8_t* data, uint16_t size) +void callback(const uint8_t* data, const uint16_t size) { // you can also use pre-defined callbacks } @@ -69,7 +69,7 @@ void setup() artnet.begin(); // waiting for Art-Net in default port // if Artnet packet comes to this universe, this function is called - artnet.subscribe(universe1, [](uint8_t* data, uint16_t size) + artnet.subscribe(universe1, [](const uint8_t* data, const uint16_t size) { // use received data[], and size }); @@ -101,13 +101,13 @@ void setup() artnet.begin("127.0.0.1"); // send to localhost and listen to default port // if Artnet packet comes to this universe, this function is called - artnet.subscribe(universe, [&](uint8_t* data, uint16_t size) + artnet.subscribe(universe, [&](const uint8_t* data, const uint16_t size) { // do something with data coming to universe }); // if Artnet packet comes, this function is called to every universe - artnet.subscribe([&](uint32_t univ, uint8_t* data, uint16_t size) + artnet.subscribe([&](const uint32_t univ, const uint8_t* data, const uint16_t size) { // do something with data coming to all universe });