Micro-bit Network Challenge

Build a ‘mini’ school network.

Using micro-bits and coding in python build a replica school network.

The network should allow for student laptops to communicate with other devices on the network, be they in the same room or in another classroom.

Messages will have the following format

  • { senderID, desinationID, payload }
  • { ‘A7’, ‘E28’, ‘Hi’}

Each student must build a classroom network with the following

  • THREE student laptop micro-bits
  • ONE classroom WAP micro-bit

The WAP has a routing table and directs any traffic sent to devices in the same classroom directly to the destination device. Any traffic sent to devices outside that classroom are sent to the correct WAP using the wap_routing_table.

wap_routing_table = { ‘A’: 5, ‘M’: 15, ‘E’: 25}

LAPTOP Micro-Bits

Each laptop micro-bit must be able to

  • Have a unique channel for that classroom
  • Send a message to a specific Laptop through the WAP
  • Display a message received

WAP Micro-bit

WAP micro-bit must be able to

  • Have a unique channel
  • Receive a message from a laptop in its classroom and either
    1. Send the message to a specific laptop in its classroom
    2. Send the message to the switch for laptops in other classrooms
  • Receive a message from a switch and
    1. Send the message to a specific laptop in its classroom
    2. Send the message to the correct WAP in another classroom

Routing Table

Each message sent needs to include the following information

  • Sender ID ( ‘A5’ , ‘M15’, ‘E25’)
  • Destination (‘M17’)
  • Payload

from microbit import *
import radio

# message components
# { senderID, desinationID, payload }
# { 'A7', 'E28', 'Hi'}

wap_routing_table = { 'A': 5, 'M': 15, 'E': 25}

# Turn on Radio
radio.on()
radio.config(channel=1)


# wait for a message
while True:
    msg = radio.receive()

    if msg:
        senderID, destinationID, payload = msg.split(':')

        # Get First Letter of senderID
        senderClass = senderID[0]

        # Get First Letter of destinationID
        destinationClass = destinationID[0]
        
        # Get number from destinationID
        destinationNumber = int(destinationID[1:])
        

        WAP_channel = wap_routing_table[destinationClass]
        radio.config(channel=WAP_channel)

        radio.send(msg)

        radio.config(channel=1)

Task One:

Resources: 2 x Laptop – Micro-bit

Code TWO micro-bits to send a receive data from one to the other.
Each micro-bit needs to be able to send and receive data.

Task Two:

Resources: 2 x Laptop – Micro-bit, 1 x WAP Micro-bit

Laptop – Micro-bit:
Each micro-bit needs to be able to receive data.
Code TWO micro-bits to send a receive data from one to the other.
Each micro-bit needs to be able to send data to the WAP.

WAP – Micro-bit:
Code the WAP micro-bit to receive data
Code the WAP micro-bit to forward data to the correct laptop micro-bit using the ID number as the channel

Task Three:

Resources: 2 x Laptop – Micro-bit, 1 x WAP Micro-bit
connection to resources from another student

Laptop – Micro-bit:
Each micro-bit needs to be able to receive data.
Code TWO micro-bits to send a receive data from one to the other.
Each micro-bit needs to be able to send data to the WAP.

WAP – Micro-bit:
Code the WAP micro-bit to receive data
Code the WAP micro-bit to forward data to the correct laptop micro-bit using the ID number as the channel for Laptops within its classroom
Code the WAP micro-bit to forward data to the orrect WAP micro-bit using the routing_table