BaseStation
BaseStation

Represents a MicroStrain Base Station object

Constants
Default Timeouts
BASE_COMMANDS_DEFAULT_TIMEOUT

50 ms  - The default timeout for a base station command (in milliseconds)

BROADCAST_NODE_ADDRESS

65535  - The address to use for performing Broadcast commands that will be heard by all WirelessNodes on the frequency.

Functions
BaseStation
explicit BaseStation(
Connection &connection,
uint64 baseTimeout BASE_COMMANDS_DEFAULT_TIMEOUT
)

Creates a BaseStation object.

Parameters
connection

The Connection object used for communication

baseTimeout
uint64

The timeout to use for base station commands (optional, default of BASE_COMMANDS_DEFAULT_TIMEOUT (2 seconds))

Exceptions
~BaseStation
virtual ~BaseStation()

Destroys a BaseStation object

eepromHelper
BaseStationEepromHelper& eepromHelper() const

Gets a reference to the BaseStationEepromHelper for this BaseStation.

doCommand
bool doCommand(
ResponsePattern &response,
const ByteStream &cmdBytes,
uint64 timeout
)

Performs a custom command and waits for the response.  When completed, the ResponsePattern parameter will contain any result information.  For a full explanation, see the ResponsePattern class.

Parameters
response

A reference to a custom class that was inherited from the ResponsePattern base class.

cmdBytes
const ByteStream&

The ByteStream containing the command bytes to send.

timeout
uint64

The maximum timeout to use for waiting for the response.

Returns

true if the command was successful (response.success() is true), false otherwise.

Operators
==

Checks that two BaseStation objects are equal.

Returns

true if the two BaseStation objects are identical, false otherwise.

!=

Checks that two BaseStation objects are not equal.

Returns

true if the two BaseStation are not identical, false otherwise.

Variables
m_impl
std::shared_ptr<BaseStation_Impl> m_impl

The BaseStation_Impl class that contains all the implementation logic for the BaseStation class.

Functions
deviceName
static std::string deviceName(
const std::string &serial
)

Static function for creating the universal basestation name that should be used for SensorCloud.

Parameters
serial
const std::string&

The serial of the basestation. This should be identical to calling the serial function on a BaseStation object.

Returns

The universal basestationName.

connection
Connection& connection()

Gets the Connection object that this BaseStation is using.

Returns

The Connection object that this BaseStation is using.

features
const BaseStationFeatures& features() const

Gets a reference to the BaseStationFeatures for this BaseStation.  Note: This will be invalid when the BaseStation is destroyed.

Returns

BaseStationFeatures containing the features for this BaseStation.

Exceptions
lastCommunicationTime
const Timestamp& lastCommunicationTime() const

Gets the Timestamp for the last time MSCL communicated with the BaseStation.  Note: EEPROM reads using the cache, and data collection, will not update this timestamp.

Returns

A Timestamp representing the last time MSCL communicated with the BaseStation. This will be a Timestamp of 0 if never communicated with.

readWriteRetries
void readWriteRetries(
uint8 numRetries
)

Sets the number of retry attempts for reading and writing with the BaseStation.  By default, the number of retries is 0.  Note:  The timeout that is set per command will be per read and write attempt, meaning this retry number is multiplied by the timeout for your overall timeout.

Parameters
numRetries
uint8

The number of retries to set for all reading and writing with the BaseStation.

useEepromCache
void useEepromCache(
bool useCache
)

Sets whether or not to utilize the eeprom cache when configuring this BaseStation (enabled by default). This can be enabled/disabled at any time.  It is highly recommended to have eeprom caching be enabled.  Note:  The eeprom cache stores the last known value that was written to / read from the BaseStation for each eeprom location. If this is enabled, any reads will get the last known value from the cache if it exists, and any writes will not write to the BaseStation if the value attempting to be written is the same as that stored in the cache. Caching of these values will still be performed if this is disabled, however, read and write operations will then always reach out to the actual device.

Parameters
useCache
bool

whether the eeprom cache should be used (true) or not (false).

clearEepromCache
void clearEepromCache()

Clears the eeprom cache for this BaseStation.

frequency
WirelessTypes::Frequency frequency() const

Gets the WirelessTypes::Frequency representing the radio frequency of this BaseStation.  If the frequency is unknown, it will be read from the BaseStation.

Returns

The WirelessTypes::Frequency that this BaseStation is on.

Exceptions
firmwareVersion
Version firmwareVersion() const

Gets the firmware version of the BaseStation.

Returns

A Version representing the firmware version of the BaseStation.

Exceptions
model
WirelessModels::BaseModel model() const

Gets the model of the BaseStation.

Returns

A WirelessModels::BaseModel representing the model of the BaseStation.

Exceptions
serial
std::string serial() const

Gets the serial number of the BaseStation.

Returns

A string representing the serial number of the BaseStation.

Exceptions
name
std::string name() const

Gets the name of the BaseStation. This is the universal basestation name that should be used for SensorCloud.  This is the same as calling BaseStation::deviceName.

Returns

The universal basestation name.

Exceptions
microcontroller
WirelessTypes::MicroControllerType microcontroller() const

Gets the microcontroller of the BaseStation.

Returns

A WirelessTypes::MicroControllerType representing the microcontroller of the BaseStation.

Exceptions
getData
DataSweeps getData(
uint32 timeout 0,
uint32 maxSweeps 0
)

Gets up to the requested amount of DataSweeps of sampled data that was collected by this BaseStation.

Parameters
timeout
uint32

The timeout, in milliseconds, to wait for data if necessary (default of 0).

maxSweeps
uint32

The maximum number of sweeps to return. If this is 0 (default), all sweeps will be returned.

Returns

A DataSweeps object containing all the data sweeps that are available up to the requested number of max sweeps.

Exceptions
totalData
uint32 totalData()

Gets the number of DataSweeps that are currently in the data buffer.

Returns

The number of DataSweeps that are currently in the data buffer.

getNodeDiscoveries
NodeDiscoveries getNodeDiscoveries()

Gets the group of Node Discoveries that were collected by this base station.  Calling this function clears out the Node Discovery buffer, so successively calling this will give you new Node Discoveries.

Returns

A NodeDiscoveries container, holding all the Node Discoveries that were collected by this base station.

Exceptions
timeout
void timeout(
uint64 timeout
)

Sets the timeout to use when waiting for responses from commands.  This timeout is used directly for BaseStation commands, while some additional time is added for Node commands.  Note: Some commands have a minimum timeout that will override this if set lower than the minimum.

Parameters
timeout
uint64

The timeout (in milliseconds) to set for commands.

baseCommandsTimeout

Gets the current timeout to use when waiting for responses from base station commands.  This timeout is used directly for BaseStation commands, while some additional time is added for Node commands.  Note: Some commands have a minimum timeout that will override this if set lower than the minimum.

Returns

The timeout (in milliseconds) set for base station commands.

ping
bool ping()

Pings the base station

Returns

true if successfully pinged the base station, false otherwise

Exceptions
Example Use
BaseStation baseStation(&connection);
baseStation.ping();
readEeprom
uint16 readEeprom(
uint16 eepromAddress
) const

Reads a specific EEPROM address on the Base Station.  If the value stored in the eeprom cache is still valid, this will be returned instead.

Parameters
eepromAddress
uint16

The EEPROM address to be read.

Returns

The uint16 value read from the specified EEPROM location.

Exceptions
writeEeprom
void writeEeprom(
uint16 eepromAddress,
uint16 value
)

Writes the specified value to a specific EEPROM address on the Base Station.  If successful, the cache will be updated with the changed value as well.

Parameters
eepromAddress
uint16

The EEPROM address to write to.

value
uint16

The value to write to the EEPROM address.

Exceptions
enableBeacon
Timestamp enableBeacon()

Enables the beacon on the base station using the system time (UTC) as its starting timestamp.

Returns

A Timestamp representing the initial time that was sent to start the beacon

Exceptions
Example Use
BaseStation baseStation(connection);
baseStation.enableBeacon();
enableBeacon
Timestamp enableBeacon(
uint32 utcTime
)

Enables the beacon on the base station using the given UTC timestamp.

Parameters
utcTime
uint32

The start time for the beacon in UTC seconds from the Unix Epoch (01/01/1970)

Returns

A Timestamp representing the initial time that was sent to start the beacon

Exceptions
Example Use
BaseStation baseStation(connection);
baseStation.enableBeacon(1357846020);
disableBeacon
void disableBeacon()

Disables the beacon on the base station.

Exceptions
Example Use
BaseStation baseStation(connection);
baseStation.disableBeacon();
beaconStatus
BeaconStatus beaconStatus()

Gets the BeaconStatus of the beacon on the base station.

Returns

A BeaconStatus object containing status information of the beacon.

Exceptions
startRfSweepMode
void startRfSweepMode(
uint32 minFreq,
uint32 maxFreq,
uint32 interval,
uint16 options0
)

Starts the BaseStation in RF Sweep Mode.  Note: To exit this Mode, send any command to the BaseStation (such as ping).

Parameters
minFreq
uint32

The minimum frequency to use in the scan in kHz (2400000 = 2.4GHz).

maxFreq
uint32

The maximum frequency to use in the scan in kHz (2400000 = 2.4GHz).

interval
uint32

The interval between frequencies.

options
uint16

This is currently an Advanced setting, used internally.

Exceptions
cyclePower
void cyclePower()

Cycles the power on the base station.

Exceptions
resetRadio
void resetRadio()

Resets the radio on the base station.

Exceptions
changeFrequency
void changeFrequency(
WirelessTypes::Frequency frequency
)

Changes the radio frequency of the base station.

Parameters
frequency

The WirelessTypes::Frequency to change the base station to.

Exceptions
verifyConfig
bool verifyConfig(
const BaseStationConfig &config,
ConfigIssues &outIssues
) const

Checks whether the settings in the given BaseStationConfig are ok to be written to the BaseStation.  Options that are set will also be validated against each other. If an option that needs to be validated isn't currently set, it will be read from the BaseStation.

Parameters
config

The BaseStationConfig to verify.

outIssues
ConfigIssues&

The ConfigIssues that will hold any resulting issues that are found with the configuration.

Returns

true if the configuration is valid. false if the configuration is invalid and outIssues should be checked for more information.

Exceptions
applyConfig
void applyConfig(
const BaseStationConfig &config
)

Applies a BaseStationConfig to the Node.  Note: This applies all options that have been set in the BaseStationConfig.  Before applying, the options will be validated. It is recommended that you perform this validation yourself first by using verifyConfig.

Parameters
config

The BaseStationConfig to apply to the Node.

Exceptions
getTransmitPower
WirelessTypes::TransmitPower getTransmitPower() const

Reads the WirelessTypes::TransmitPower that is currently set on the BaseStation.

Returns

The WirelessTypes::TransmitPower that is currently set on the BaseStation.

Exceptions
getButtonLongPress
BaseStationButton getButtonLongPress(
uint8 buttonNumber
) const

Reads the button settings for a long press action that are currently set on the BaseStation.

Parameters
buttonNumber
uint8

The button number (1 = button 1) to get the value for.

Returns

A BaseStationButton object holding the current long press settings for the requested button number.

Exceptions
getButtonShortPress
BaseStationButton getButtonShortPress(
uint8 buttonNumber
) const

Reads the button settings for a short press action that are currently set on the BaseStation.

Parameters
buttonNumber
uint8

The button number (1 = button 1) to get the value for.

Returns

A BaseStationButton object holding the current short press settings for the requested button number.

Exceptions
getAnalogPairingEnabled
bool getAnalogPairingEnabled() const

Reads the Analog Pairing enabled/disabled setting that is currently set on the BaseStation.  If this is disabled, all other analog pairing settings will be disabled.

Returns

true if Analog Pairing is enabled, false otherwise.

Exceptions
getAnalogTimeoutTime
uint16 getAnalogTimeoutTime() const

Reads the Analog Timeout Time in seconds that is currently set on the BaseStation.

Returns

The analog timeout time in seconds.

Exceptions
getAnalogTimeoutVoltage
float getAnalogTimeoutVoltage() const

Reads the Analog Timeout Voltage that is currently set on the BaseStation.

Returns

The analog timeout voltage.

Exceptions
getAnalogExceedanceEnabled
bool getAnalogExceedanceEnabled() const

Reads the Analog Exceedance enabled/disabled setting that is currently set on the BaseStation.

Returns

true if Analog Exceedance is enabled, false otherwise.

Exceptions
getAnalogPair
BaseStationAnalogPair getAnalogPair(
uint8 portNumber
) const

Reads the BaseStationAnalogPair for the specified port number that is currently set on the BaseStation.

Parameters
portNumber
uint8

The port number (1 = port 1) to get the value for.

Returns

The BaseStationAnalogPair for the specified port number that is currently set on the BaseStation.

Exceptions
node_lastCommunicationTime
const Timestamp& node_lastCommunicationTime(
NodeAddress nodeAddress
) const

Gets the Timestamp for the last time MSCL communicated with the given node address.

Parameters
nodeAddress

The node address of the Node to check for.

Returns

A Timestamp representing the last time MSCL communicated with the Node, through this BaseStation.

node_shortPing
bool node_shortPing(
NodeAddress nodeAddress
)

Pings a specific node.

Parameters
nodeAddress

the node address of the node to ping.

Returns

true if successfully pinged the node, false otherwise.

Exceptions
node_ping
PingResponse node_ping(
NodeAddress nodeAddress
)

Pings the specified Node.

Parameters
nodeAddress

the node address of the node to ping.

Returns

A PingResponse object that can be queried to get details of the ping command's response.

Exceptions
node_sleep
bool node_sleep(
NodeAddress nodeAddress
)

Puts the Node into a low power, sleep mode.  This command attempts to ping the node before sending the sleep command, to verify communication.

Parameters
nodeAddress

The node adderss of the Node to put to sleep.

Returns

true if the sleep command was successful, false otherwise.

Exceptions
node_setToIdle
SetToIdleStatus node_setToIdle(
NodeAddress nodeAddress
)

Attempts to set the node to idle so that it can be communicated with.

Parameters
nodeAddress

the node address of the node to set to idle.

Returns

A SetToIdleStatus object that can be queried to get the status of the Set to Idle operation.

Exceptions
node_readEeprom
bool node_readEeprom(
const WirelessProtocol &protocol,
NodeAddress nodeAddress,
uint16 eepromAddress,
uint16 &eepromValue
)

Reads a value from EEPROM on the specified Node.

Parameters
protocol

the WirelessProtocol for the Node.

nodeAddress

the node address of the Node to read from.

eepromAddress
uint16

the EEPROM address to read the value from.

eepromValue
uint16&

holds the result value read from EEPROM if successful.

Returns

true if the command was successful, false otherwise.

Exceptions
node_writeEeprom
bool node_writeEeprom(
const WirelessProtocol &protocol,
NodeAddress nodeAddress,
uint16 eepromAddress,
uint16 value
)

Writes a value to EEPROM on the specified Node.

Parameters
protocol

the WirelessProtocol for the Node.

nodeAddress

the node address of the node to write to.

eepromAddress
uint16

the EEPROM address to write the value to.

value
uint16

the value to write to EEPROM.

Returns

true if the write eeprom command succeeded, false otherwise.

Exceptions
node_pageDownload
bool node_pageDownload(
const WirelessProtocol &protocol,
NodeAddress nodeAddress,
uint16 pageIndex,
ByteStream &data
)

Downloads a page of logged data from the Node.

Parameters
protocol

The WirelessProtocol for the Node.

nodeAddress

The node address of the Node to download data from.

pageIndex
uint16

The page index to download from the Node.

data

Output parameter that contains the resulting data downloaded from the Node, if any.

Returns

true if the page download command succeded, false otherwise

Exceptions
node_startSyncSampling
bool node_startSyncSampling(
NodeAddress nodeAddress
)

Sends the Start Synchronized Sampling command to a Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

Returns

true if the Start Sync Sampling command succeeded, false otherwise.

Exceptions
node_startNonSyncSampling
void node_startNonSyncSampling(
NodeAddress nodeAddress
)

Sends the Start Non-Synchronized Sampling command to a Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

Exceptions
node_armForDatalogging
bool node_armForDatalogging(
NodeAddress nodeAddress,
const std::string &message ""
)

Sends the Arm For Datalogging command to a Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

message
const std::string&

A message, up to 50 characters, to send with the arm command. This message can be downloaded with the data. Will be trimmed to 50 chars if longer. (Default of "")

Exceptions
node_triggerArmedDatalogging
void node_triggerArmedDatalogging(
NodeAddress nodeAddress
)

Sends the Trigger Armed Datalogging command to a Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

Exceptions
node_erase
bool node_erase(
NodeAddress nodeAddress
)

Sends the Erase command to a Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

Exceptions
node_autoBalance
bool node_autoBalance(
const WirelessProtocol &protocol,
NodeAddress nodeAddress,
uint8 channelNumber,
float targetPercent,
AutoBalanceResult &result
)

Sends the AutoBalance command to a Node.

Parameters
protocol

The WirelessProtocol for the Node.

nodeAddress

The node address of the Node to send the command to.

channelNumber
uint8

The channel number (ch1 = 1, ch8 = 8) to balance.

targetPercent
float

The target percentage (0 - 100) to balance to.

result

The AutoBalanceResult of the command.

Returns

true if the command succeeded, false if it failed.

Exceptions
node_autocal
bool node_autocal(
NodeAddress nodeAddress,
WirelessModels::NodeModel model,
const Version &fwVersion,
AutoCalResult &result
)

Performs automatic calibration for a Wireless Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

model

The WirelessModels::NodeModel of the Node.

fwVersion
const Version&

The firmware Version of the Node.

result

The AutoCalResult reference to hold the result.

Returns

true if the AutoCal command was successful, false otherwise.

Exceptions
node_readSingleSensor
bool node_readSingleSensor(
NodeAddress nodeAddress,
uint8 channelNumber,
uint16 &result
)

Reads the bits value for a single channel on a Wireless Node.

Parameters
nodeAddress

The node address of the Node to send the command to.

channelNumber
uint8

The channel number (ch1 = 1, ch8 = 8) to read.

result
uint16&

Holds the bits value result from the channel on the Node.

Returns

true if the Read Single Sensor command was successful, false otherwise.

Exceptions