Eddystone test using modified DAL

Dependencies:   BLE_API mbed-dev-bin nRF51822

Dependents:   microbit-eddystone

Fork of microbit-dal by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

MicroBitRadioEvent Class Reference

MicroBitRadioEvent Class Reference

Provides a simple broadcast radio abstraction, built upon the raw nrf51822 RADIO module. More...

#include <MicroBitRadioEvent.h>

Public Member Functions

 MicroBitRadioEvent (MicroBitRadio &r)
 Constructor.
int listen (uint16_t id, uint16_t value)
 Associates the given event with the radio channel.
int listen (uint16_t id, uint16_t value, EventModel &eventBus)
 Associates the given event with the radio channel.
int ignore (uint16_t id, uint16_t value)
 Disassociates the given event with the radio channel.
int ignore (uint16_t id, uint16_t value, EventModel &eventBus)
 Disassociates the given events with the radio channel.
void packetReceived ()
 Protocol handler callback.
void eventReceived (MicroBitEvent e)
 Event handler callback.

Detailed Description

Provides a simple broadcast radio abstraction, built upon the raw nrf51822 RADIO module.

This class provides the ability to extend the micro:bit's default EventModel to other micro:bits in the vicinity, in a very similar way to the MicroBitEventService for BLE interfaces.

It is envisaged that this would provide the basis for children to experiment with building their own, simple, custom asynchronous events and actions.

Note:
This API does not contain any form of encryption, authentication or authorisation. Its purpose is solely for use as a teaching aid to demonstrate how simple communications operates, and to provide a sandpit through which learning can take place. For serious applications, BLE should be considered a substantially more secure alternative.

Definition at line 47 of file MicroBitRadioEvent.h.


Constructor & Destructor Documentation

MicroBitRadioEvent ( MicroBitRadio &  r )

Constructor.

Provides a simple broadcast radio abstraction, built upon the raw nrf51822 RADIO module.

Creates an instance of MicroBitRadioEvent which offers the ability to extend the micro:bit's default EventModel to other micro:bits in the vicinity.

Parameters:
rThe underlying radio module used to send and receive data.

This class provides the ability to extend the micro:bit's default EventModel to other micro:bits in the vicinity, in a very similar way to the MicroBitEventService for BLE interfaces.

It is envisaged that this would provide the basis for children to experiment with building their own, simple, custom asynchronous events and actions.

Note:
This API does not contain any form of encryption, authentication or authorisation. Its purpose is solely for use as a teaching aid to demonstrate how simple communications operates, and to provide a sandpit through which learning can take place. For serious applications, BLE should be considered a substantially more secure alternative. Constructor.

Creates an instance of MicroBitRadioEvent which offers the ability to extend the micro:bit's default EventModel to other micro:bits in the vicinity.

Parameters:
rThe underlying radio module used to send and receive data.

Definition at line 51 of file MicroBitRadioEvent.cpp.


Member Function Documentation

void eventReceived ( MicroBitEvent  e )

Event handler callback.

This is called whenever an event is received matching one of those registered through the registerEvent() method described above. Upon receiving such an event, it is wrapped into a radio packet and transmitted to any other micro:bits in the same group.

Definition at line 161 of file MicroBitRadioEvent.cpp.

int ignore ( uint16_t  id,
uint16_t  value,
EventModel eventBus 
)

Disassociates the given events with the radio channel.

Parameters:
idThe id of the events to deregister.
valueThe value of the event to deregister.
eventBusThe EventModel to deregister on.
Returns:
MICROBIT_OK on success.
Note:
MICROBIT_EVT_ANY can be used to deregister all event values matching the given id.

Definition at line 133 of file MicroBitRadioEvent.cpp.

int ignore ( uint16_t  id,
uint16_t  value 
)

Disassociates the given event with the radio channel.

Parameters:
idThe id of the events to deregister.
valueThe value of the event to deregister.
Returns:
MICROBIT_OK on success, or MICROBIT_INVALID_PARAMETER if the default message bus does not exist.
Note:
MICROBIT_EVT_ANY can be used to deregister all event values matching the given id.

Definition at line 112 of file MicroBitRadioEvent.cpp.

int listen ( uint16_t  id,
uint16_t  value,
EventModel eventBus 
)

Associates the given event with the radio channel.

Once registered, all events matching the given registration sent to the given EventModel will be automatically retransmitted on the radio.

Parameters:
idThe id of the events to register.
valuethe value of the event to register.
eventBusThe EventModel to listen for events on.
Returns:
MICROBIT_OK on success.
Note:
The wildcards MICROBIT_ID_ANY and MICROBIT_EVT_ANY can also be in place of the id and value fields.

Definition at line 96 of file MicroBitRadioEvent.cpp.

int listen ( uint16_t  id,
uint16_t  value 
)

Associates the given event with the radio channel.

Once registered, all events matching the given registration sent to this micro:bit's default EventModel will be automatically retransmitted on the radio.

Parameters:
idThe id of the event to register.
valuethe value of the event to register.
Returns:
MICROBIT_OK on success, or MICROBIT_NO_RESOURCES if no default EventModel is available.
Note:
The wildcards MICROBIT_ID_ANY and MICROBIT_EVT_ANY can also be in place of the id and value fields.

Definition at line 71 of file MicroBitRadioEvent.cpp.

void packetReceived (  )

Protocol handler callback.

This is called when the radio receives a packet marked as using the event protocol.

This function process this packet, and fires the event contained inside onto the default EventModel.

Definition at line 144 of file MicroBitRadioEvent.cpp.