Redpine Wireless module Class. The module class controls the physical module, sending and receiving data from the device. It utilizes a communication interface (ModuleCommunication) to send and receive data. This makes the class independent of the communication protocol.

Because there is only one physical module, this class is a singleton object. You access it by the static Instance method. To setup the Redpine module you must call the static global methods:

  1. **Initialize**: Initializes the communication interface
  2. **setupWifiOnly**: Join a wifi network with security and setup DHCP

Only networking classes should access the module directly. Tcp socket, DNS resolution etc, should be handled by dedicated classes, that uses this class.

Public Types

enum type mono::redpine::Module::ModuleCoExistenceModes

The module can operate in different modes, that controls the different wireless capabilities.


Only enabled Wifi, with embedded TCP/IP

Only Bluetooth Classic (2.0) is enabled

Only Bluetooth LE is enabled

Coex-mode with wifi and BT classic

Coex-mode with wifi and BLE

enum type mono::redpine::Module::WifiSecurityModes

List of Wifi security modes. Use these when you connect to an access point.

The last option SEC_WPA_WPA2 is a mixed mode, that gives priority to WPA2.


No security

Either in WPA/WPA2 mode (Mixed mode)

enum type mono::redpine::Module::BootloaderMessageCodes

Command messages that can be written to the Bootloaders host interface register.


= 0xAB00
= 0x0031
= 0x0037
enum type mono::redpine::Module::BootloaderRegisters

Memory addresses of the registers related the Bootloader


= 0x4105003C
= 0x41050034

Public Functions

void Module::moduleEventHandler()

Callback function installed into the CommunicationInterface interrupt callback listener.

Public Members

mbed::FunctionPointerArg1<bool, ManagementFrame *> *mono::redpine::Module::asyncManagementFrameHandler

The default handler for async incoming management frames.

Such frames are power, socket connect and disconnect events.

Public Static Functions

Module *Module::Instance()


Obtain a reference to the singleton module object

bool Module::initialize(ModuleCommunication *commInterface)

Sends the inirialize command and waits for Card Ready from the module and set the communication interface for this object. After this method is called the module is ready to receive the OperMode command etc.

  • commInterface -

    The module communication interface to be used

bool Module::setupWifiOnly(String ssid, String passphrase, WifiSecurityModes secMode)

Initializes the module in Eifi only mode with enabled TCP/IP stack We expect this mode to be the defult mode, when only using Wifi

The method will set the module in Wifi client mode with the 2.4 GHz band antenna.

  • ssid -

    The SSID name of access point to connect to

  • passphrase -

    The passphrase of the access point to join

  • secMode -

    The access points security setting, default is WPA/WPA2

bool Module::IsNetworkReady()

See id the network is ready and running.

Check to see if the module has a ready network stack with initialized IP configuration. A ready network stack is ready to fetch or send data to and from the internet.

true if the network is ready, false otherwise

Protected Functions


Protected class constructor Can only be called by the Instance() method.

void Module::handleSleepWakeUp()

Handle the modules periodic wake ups Puts the module to sleep again, if no input is to be sent.

void Module::onNetworkReady(ManagementFrame::FrameCompletionData *data)

Callback for the DHCP Mgmt frame response, that indicate the network is ready

virtual void Module::onSystemPowerOnReset()

Called when the system powers on after a reset.

You can override this method. It gets called right after the system power on for the first time, or after a reset condition.

Use this method to setup / initialize components and data structures. It is only called once for each system reset.

virtual void Module::onSystemEnterSleep()

Called right before the MCU goes into sleep mode.

You can override this method to get sleep notifications. Before the CPU stop executing intructions and goes into low power sleep mode, this method gets called.

Use this method to prepare your data or MCU components for sleep. Help preserve battery by power down any peripheral, that is not needed during sleep.

This method can be called many times during your apps life cycle. (That is between resets.) After each sleep period, when the MCU wakes the onSystemWakeFromSleep is guaranteed to be called.

virtual void Module::onSystemWakeFromSleep()

Override to get notified when system wakes from sleep.

You can override this method to get wake-up notifications. When the CPU starts executing intructions and the power system has powered up all peripherals - this method gets called.

Use this method to setup your app to resume after sleep mode.

This method can be called many times during your apps life cycle. (That is between resets.)

virtual void Module::onSystemBatteryLow()

Override to get notified when the battery voltage reaches a critical level.

You can override this method to get battery low notifications. When this methods gets called, you have some time to finish critical tasks. That might writing state to file system or transfer data over the network.

Depending on the health of the battery, the time between this notification and the actual system enforced power off, might vary.

In contrast to the other power aware methods this is only called once in the application life cycle. After the enforced power off, when the battery is charged, the system will automatically reset.

void Module::handleDataPayload(ModuleCommunication::DataPayload const &payload)

Handles an incomming data frame (expect that it contain socket data

bool Module::initAsyncFrame(const DataReceiveBuffer &buffer, ManagementFrame **frame)

Initiazes (constructs) the correct subclass of an async mgmt frame

bool Module::discardIfNeeded(ManagementFrame *frame)


Protected Attributes

bool mono::redpine::Module::communicationInitialized

True is the module communication interface is initialized

bool mono::redpine::Module::networkInitialized

True if the module has its network stack ready

ModuleCommunication *mono::redpine::Module::comIntf

The communication interface used by the module

ModuleCoExistenceModes mono::redpine::Module::OperatingMode

This holds the module currently initalized operation mode

ModulePowerState mono::redpine::Module::CurrentPowerState

The current state of the module, is it awake or sleeping

GenericQueue<ManagementFrame> mono::redpine::Module::requestFrameQueue

A queue over the pending requests to-be-send to the module

GenericQueue<ManagementFrame> mono::redpine::Module::responseFrameQueue

A queue over the pending requests sent / pending to the module

mbed::FunctionPointer mono::redpine::Module::networkReadyHandler

User can install a network ready event callback in this handler

Protected Static Attributes

Module Module::moduleSingleton

The only instantiation of the module class

Construct the module


List of found AP’s, as retreived by the scanNetworks method.

TODO: This class should become generic across H/W!


Public Members

uint32_t mono::redpine::Module::ScannedNetworks::Count

Number of found networks

Network *mono::redpine::Module::ScannedNetworks::networks

List of results


Object to configure static IP

Public Members

uint8_t mono::redpine::Module::StaticIPParams::ipAddress[4]

IPv4 client address

uint8_t mono::redpine::Module::StaticIPParams::netmask[4]

IPv4 netmask

uint8_t mono::redpine::Module::StaticIPParams::gateway[4]

IPv4 Gateway