DESERT 4.0.0
UwInterpreterS2C Class Reference

#include <uwinterpreters2c.h>

Collaboration diagram for UwInterpreterS2C:
Collaboration graph

Public Types

enum class  Response {
  RECVIM = 0 , RECV , OK , EMPTY ,
  BUSY , DELIVERING , DELIVERED , DELIVEREDIM ,
  DROPCNT , PHYOFF , NOT_ACCEPTED , WRONG_ADDR ,
  CONN_CLOSED , BUFF_NOT_EMPTY , OUT_OF_RANGE , PROTOCOL_ID ,
  INTERNAL , BUFFER_FULL , FAIL , CURR_SETTINGS ,
  MODEM_STATUS , INIT_NOISE , INIT_DEAF , INIT_LISTEN ,
  RECVSTART , RECVEND , RECVFAIL , SENDSTART ,
  SENDEND , BITRATE , UNKNOWN , USBLANGLES ,
  USBLLONG , NO_COMMAND
}
 

Public Member Functions

 UwInterpreterS2C ()
 
virtual ~UwInterpreterS2C ()
 
std::string buildSend (std::string msg, int dest)
 
std::string buildSendIM (std::string msg, int dest, bool ack)
 
std::string buildATZ (int level)
 
std::string buildGetATL ()
 
std::string buildSetATL (int level)
 
std::string buildGetATAL ()
 
std::string buildSetATAL (int addr)
 
std::string buildATDI ()
 
std::string buildATS ()
 
std::string buildATV ()
 
UwInterpreterS2C::Response findResponse (std::vector< char >::iterator beg, std::vector< char >::iterator end, std::vector< char >::iterator &rsp)
 
bool parseResponse (UwInterpreterS2C::Response rsp, std::vector< char >::iterator end, std::vector< char >::iterator rsp_beg, std::vector< char >::iterator &rsp_end, std::string &rx_payload)
 
void setExtProtoMode (bool enabled)
 
std::shared_ptr< USBLInfogetUSBLInfo ()
 
void setTerminator (std::string terminator)
 

Private Attributes

std::string sep
 
std::string r_term
 
std::string w_term
 
bool ext_proto_mode
 
std::shared_ptr< USBLInfousbl_info
 

Static Private Attributes

static std::vector< std::pair< std::string, UwInterpreterS2C::Response > > syntax_pool
 

Member Enumeration Documentation

◆ Response

enum class UwInterpreterS2C::Response
strong

Enum listing the types of commands that could be received or sent by a S2C device; See the EvoLogics S2C manuals or reach for www.evologics.de

Enumerator
RECVIM 
RECV 
OK 
EMPTY 
BUSY 
DELIVERING 
DELIVERED 
DELIVEREDIM 
DROPCNT 
PHYOFF 
NOT_ACCEPTED 
WRONG_ADDR 
CONN_CLOSED 
BUFF_NOT_EMPTY 
OUT_OF_RANGE 
PROTOCOL_ID 
INTERNAL 
BUFFER_FULL 
FAIL 
CURR_SETTINGS 
MODEM_STATUS 
INIT_NOISE 
INIT_DEAF 
INIT_LISTEN 
RECVSTART 
RECVEND 
RECVFAIL 
SENDSTART 
SENDEND 
BITRATE 
UNKNOWN 
USBLANGLES 
USBLLONG 
NO_COMMAND 

Constructor & Destructor Documentation

◆ UwInterpreterS2C()

UwInterpreterS2C::UwInterpreterS2C ( )

Class constructor

References usbl_info.

◆ ~UwInterpreterS2C()

UwInterpreterS2C::~UwInterpreterS2C ( )
virtual

Class destructor

Member Function Documentation

◆ buildATDI()

std::string UwInterpreterS2C::buildATDI ( )

Method that builds the command to check the IM delivery status

Returns
string of the requested command

References w_term.

◆ buildATS()

std::string UwInterpreterS2C::buildATS ( )

Method that builds the command to ask for modem status: it enlists local address, acoustic link status and pool status and whether promiscous mode is on.

Returns
string of the requested command

References w_term.

◆ buildATV()

std::string UwInterpreterS2C::buildATV ( )

Method that builds the command to ask for current settings: it enlists source level, gain, retry timeout, carrier ID and other See the EvoLogics S2C manuals or reach for www.evologics.de

Returns
string of the requested command

References w_term.

◆ buildATZ()

std::string UwInterpreterS2C::buildATZ ( int  level)

Method that builds a reboot sequence: depending on the provided index different levels of reset can be requested.

Parameters
levelinteger level of reset requested
Returns
string of the requested command

References w_term.

◆ buildGetATAL()

std::string UwInterpreterS2C::buildGetATAL ( )

Method that builds the command to set the local address of the device

Returns
string of the requested command

References w_term.

◆ buildGetATL()

std::string UwInterpreterS2C::buildGetATL ( )

Method that builds the command to get the source level of the device

Returns
string of the requested command

References w_term.

◆ buildSend()

std::string UwInterpreterS2C::buildSend ( std::string  msg,
int  dest 
)

Method that builds the command to send data through SEND command SEND is used to send burst data: payload is saved in S2C internal memory until the device is ready to transmit, at the negotiated bitrate.

Parameters
msgstring containing the payload to be sent
destinteger number representing the destination local address
Returns
string of the requested command

References ext_proto_mode, sep, and w_term.

◆ buildSendIM()

std::string UwInterpreterS2C::buildSendIM ( std::string  msg,
int  dest,
bool  ack 
)

Method that builds the command to send data through SENDIM command SENDIM is used to send Instant Messages: these messages are immediately transmitted at the minimum bitrate availbale in the device.

Parameters
msgstring containing the payload to be sent
destinteger number representing the destination local address
ackboolean set to true if ACK is needed, false otherwise
Returns
string of the requested command

References ext_proto_mode, sep, and w_term.

◆ buildSetATAL()

std::string UwInterpreterS2C::buildSetATAL ( int  addr)

Method that builds the command to set the local address of the device

Parameters
levelinteger value of the Local Address of the device
Returns
string of the requested command

References w_term.

◆ buildSetATL()

std::string UwInterpreterS2C::buildSetATL ( int  level)

Method that builds the command to set the source level of the device

Parameters
levelinteger level of the Source Level of the device
Returns
string of the requested command

References w_term.

◆ findResponse()

UwInterpreterS2C::Response UwInterpreterS2C::findResponse ( std::vector< char >::iterator  beg,
std::vector< char >::iterator  end,
std::vector< char >::iterator &  rsp 
)

Method to look for S2C response inside a provided chunk of unparsed data This method only finds the beginning of the returned response,not the end

Parameters
begiterator to beginning of search section
enditerator to end of search section
rspoutput iterator first response found
Returns
type of the first valid response found, of type UwInterpreterS2C::Response

References NO_COMMAND, and syntax_pool.

◆ getUSBLInfo()

std::shared_ptr< USBLInfo > UwInterpreterS2C::getUSBLInfo ( )

Method to retrieve the USBL information saved upon reception of a USBL message

Returns
USBLinfo structure loaded with values

References usbl_info.

◆ parseResponse()

bool UwInterpreterS2C::parseResponse ( UwInterpreterS2C::Response  rsp,
std::vector< char >::iterator  end,
std::vector< char >::iterator  rsp_beg,
std::vector< char >::iterator &  rsp_end,
std::string &  rx_payload 
)

Method that tries to parse a found response: if the response section of the buffer, which needs to be passed, is found to be incomplete, the method return false. If parsing is successful, proper action is taken. The method also locates the end of the response looking for term.

Parameters
[in]rspresponse found by call to UwInterpreterS2C::findResponse
[in]endbeginning of the buffer section to parse
[in]rsp_begof the responses as found by findResponse()
[out]rsp_endof the response, if found by parsing
[out]rx_payloadcontaining the payload stored in the response, if any.
Returns
false if attempt to parse command fails (e.g., for missing bytes)

References BITRATE, BUFFER_FULL, BUSY, CURR_SETTINGS, DELIVERED, DELIVEREDIM, DELIVERING, DROPCNT, EMPTY, ext_proto_mode, FAIL, MODEM_STATUS, OK, r_term, RECV, RECVEND, RECVFAIL, RECVIM, RECVSTART, SENDEND, SENDSTART, UNKNOWN, usbl_info, USBLANGLES, and USBLLONG.

◆ setExtProtoMode()

void UwInterpreterS2C::setExtProtoMode ( bool  enabled)

Method that sets whether Extended Protocol Mode is used or not

Parameters
enabledtrue if Extended Protocol Mode is used, false otherwise

References ext_proto_mode.

◆ setTerminator()

void UwInterpreterS2C::setTerminator ( std::string  terminator)
inline

Method that sets the terminator for the AT commands wrtten to device

Parameters
[in]terminatortype of the terminator

References w_term.

Member Data Documentation

◆ ext_proto_mode

bool UwInterpreterS2C::ext_proto_mode
private

Flag telling if Extened Protol Mode is in use

Referenced by buildSend(), buildSendIM(), parseResponse(), and setExtProtoMode().

◆ r_term

std::string UwInterpreterS2C::r_term
private

Terminating sequence for commands read from device

Referenced by parseResponse().

◆ sep

std::string UwInterpreterS2C::sep
private

Separator for paramters fo the commands: a comma

Referenced by buildSend(), and buildSendIM().

◆ syntax_pool

std::vector< std::pair< std::string, UwInterpreterS2C::Response > > UwInterpreterS2C::syntax_pool
staticprivate

Vector holding all possible commands for the S2C syntax and corresponding identifying token. It is important that RECV and RECVIM remain at the beginning, as the other commands may be inside the binary payload of these two.

Referenced by findResponse().

◆ usbl_info

std::shared_ptr<USBLInfo> UwInterpreterS2C::usbl_info
private

Strucure holding info retrived via USBL message

Referenced by getUSBLInfo(), parseResponse(), and UwInterpreterS2C().

◆ w_term

std::string UwInterpreterS2C::w_term
private

Terminating sequence for commands wrtten to device

Referenced by buildATDI(), buildATS(), buildATV(), buildATZ(), buildGetATAL(), buildGetATL(), buildSend(), buildSendIM(), buildSetATAL(), buildSetATL(), and setTerminator().


The documentation for this class was generated from the following files: