The micro:bit and other boards with Nordic chips support an easy-to-use, peer-to-peer radio messaging system.
To make WIFI messaging as easy, we have implemented a similar RADIO messaging over WIFI.
A WIFI radio messages consist of a short text string, a number, or both (a pair).
Using different group codes (0-255) allows multiple WIFI radio projects to operate simultaously in classroom settings. A group is an independent communications channel. Each microcontroller sends and receives messages to others in its own group. Any messages being exchanged by other groups are ignored. If you wish to use the group code concept, set your group numbers for all microcontrollers involved, before you start sending and receiving messages.
The group is set to zero by default. You don't need change to another group unless people nearby are already using group zero.
WIFI version of the Radio Messaging uses the WIFI UDP protocol in a BROADCAST mode. Each message sent is broadcast over the local IP subnetwork. Therefore, a connection to a WIFI network has to be established first, before making use of this feature.
This WIFI network can either be your own local Internet router based network OR it can be a network setup by the HOTSPOT feature of the WIFI Library. One of the following blocks from the WIFI Library should be used to establish connectivity or create a hotspot, respectively.
The device sending the messages will not be able to receive them.
Send a message containing a number.
On the receiving end, the number is read with the wifi last number block.
Send a text string (up to approx. 800 bytes). You can send longer messages by breaking them into lesser number of byte chunks.
On the receiving end, the string is read with the wifi last string block.
Send a message containing both short text string and a number. The string can be used to specify what number means -- for example "light = 10" might mean that the light sensor reading is 10.
On the receiving end, the string part of the message is read with the wifi last string block and the number part with the wifi last number block.
Return true when a new wifi message is received.
This block is often used in a when hat to process incoming radio messages. For example this script prints incoming text messages:
Return the number part of the last wifi message received. Return zero if the message did not contain a number.
Return the string part of the last wifi message received. Return the empty string if the message did not contain a string.
Set the group number (0-255) used to send and receive messages.
A group is an independent communications channel. Messages sent by a microcontroller in a given group are received by all other microcontrollers in that group. Messages exchanged by other groups are ignored.
The default group number is zero. The microcontroller reverts to that group when it is reset.