Jim Flynn / Mbed OS aws-iot-device-sdk-mbed-c
Embed: (wiki syntax)

« Back to documentation index

BG96 Class Reference

BG96 Class Reference

BG96Interface class. More...

#include <BG96.h>

Public Member Functions

 BG96 (bool debug=false)
 ----------------------------------------------------------
bool startup (void)
 Init the BG96.
void waitBG96Ready (void)
 Wait for 'RDY' signal or timeout waiting...
void reset (void)
 Reset BG96.
nsapi_error_t connect (const char *apn, const char *username, const char *password)
 Connect BG96 to APN.
bool disconnect (void)
 Disconnect BG96 from AP.
const char * getIPAddress (char *)
 Get the IP address of BG96.
const char * getMACAddress (char *)
 Get the MAC address of BG96.
bool isConnected (void)
 Check if BG96 is conenected.
bool open (const char type, int id, const char *addr, int port)
 Open a socketed connection.
bool send (int id, const void *data, uint32_t amount)
 Sends data to an open socket.
int32_t recv (int, void *, uint32_t)
 Receives data from an open socket.
bool close (int id)
 Closes a socket.
bool readable ()
 Checks if data is available.
bool writeable ()
 Checks if data can be written.
bool resolveUrl (const char *name, char *str)
 Resolves a URL name to IP address.
int setContext (int i)
 ----------------------------------------------------------
void doDebug (int f)
 ----------------------------------------------------------
const char * getRev (char *)
 Return the BG96 revision info.
bool getError (char *)
 Return the last error to occur.
int rxAvail (int)
 Return the amount a data available.
bool chkRxAvail (int id)
 Return true/false if rx data is available.

Detailed Description

BG96Interface class.

Interface to a BG96 module.

Definition at line 66 of file BG96.h.


Constructor & Destructor Documentation

BG96 ( bool  debug = false )

----------------------------------------------------------

constructor

Parameters:
none
Return values:
none

Definition at line 82 of file BG96.cpp.


Member Function Documentation

bool chkRxAvail ( int  id )

Return true/false if rx data is available.

----------------------------------------------------------

Parameters:
socketto check

check if RX data has arrived

Parameters:
idof BG96 socket
Return values:
true/false

Definition at line 496 of file BG96.cpp.

bool close ( int  id )

Closes a socket.

----------------------------------------------------------

Parameters:
idid of socket to close, valid only 0-4
Returns:
true only if socket is closed successfully

close the BG96 socket

Parameters:
idof BG96 socket
Return values:
trueof close successful false on failure. <0 if error

Definition at line 453 of file BG96.cpp.

nsapi_error_t connect ( const char *  apn,
const char *  username,
const char *  password 
)

Connect BG96 to APN.

----------------------------------------------------------

Parameters:
apnthe name of the APN
username(not used)
password(not used)
Returns:
nsapi_error_t

connect to APN

Parameters:
apnstring
username(not used)
password(not used)
Return values:
nsapi_error_t

Definition at line 232 of file BG96.cpp.

bool disconnect ( void   )

Disconnect BG96 from AP.

----------------------------------------------------------

Returns:
true if BG96 is disconnected successfully

disconnect from an APN

Parameters:
none
Return values:
true/falseif disconnect was successful or not

Definition at line 278 of file BG96.cpp.

void doDebug ( int  f )

----------------------------------------------------------

enable AT command tracing

Parameters:
integer,ifmsb is set, tracing enabled
Return values:
none

Definition at line 124 of file BG96.cpp.

bool getError ( char *  str )

Return the last error to occur.

----------------------------------------------------------

Parameters:
char*[at least 40 long]

get last error code

Parameters:
none.
Return values:
returnstrue/false if successful and updated error string

Definition at line 432 of file BG96.cpp.

const char * getIPAddress ( char *  ipstr )

Get the IP address of BG96.

----------------------------------------------------------

Returns:
null-teriminated IP address or null if no IP address is assigned

obtain the IP address socket is using

Parameters:
none
Return values:
stringcontaining IP or NULL on failure

Definition at line 345 of file BG96.cpp.

const char * getMACAddress ( char *  sn )

Get the MAC address of BG96.

----------------------------------------------------------

Returns:
null-terminated MAC address or null if no MAC address is assigned

return the MAC

Parameters:
none
Return values:
stringcontaining the MAC or NULL on failure MAC is created using the ICCID of the SIM

Definition at line 365 of file BG96.cpp.

const char * getRev ( char *  combined )

Return the BG96 revision info.

----------------------------------------------------------

Parameters:
none.get BG96 SW version
none
Return values:
stringcontaining SW version

Definition at line 104 of file BG96.cpp.

bool isConnected ( void   )

Check if BG96 is conenected.

----------------------------------------------------------

Returns:
true only if the chip has an IP address

determine if BG96 is connected to an APN

Parameters:
none
Return values:
trueor false

Definition at line 388 of file BG96.cpp.

bool open ( const char  type,
int  id,
const char *  addr,
int  port 
)

Open a socketed connection.

----------------------------------------------------------

Parameters:
typethe type of socket to open "u" (UDP) or "t" (TCP)
idfor saving socket number to (returned by BG96)
portport to open connection with
addrthe IP address of the destination
Returns:
true only if socket opened successfully

open a BG96 socket

Parameters:
typeof socket to open ('u' or 't')
idof BG96 socket
address(IP)
portof the socket
Return values:
trueif successful, else false on failure

Definition at line 402 of file BG96.cpp.

bool readable (  )

Checks if data is available.

----------------------------------------------------------

determine if BG96 is readable

Parameters:
none
Return values:
true/false

Definition at line 324 of file BG96.cpp.

int32_t recv ( int  id,
void *  data,
uint32_t  cnt 
)

Receives data from an open socket.

----------------------------------------------------------

Parameters:
idto receive from
pointerto data for returned information
amountnumber of bytes to be received
Returns:
the number of bytes received

receive data from BG96

Parameters:
idof BG96 socket
pointerto location to store returned data
countof the number of bytes to get
Return values:
numberof bytes returned or 0

Definition at line 532 of file BG96.cpp.

void reset ( void   )

Reset BG96.

----------------------------------------------------------

Returns:
true if BG96 resets successfully

perform a HW reset of the BG96

Parameters:
none
Return values:
none

Definition at line 167 of file BG96.cpp.

bool resolveUrl ( const char *  name,
char *  ipstr 
)

Resolves a URL name to IP address.

----------------------------------------------------------

perform DNS lookup of URL to determine IP address

Parameters:
stringcontaining the URL
Return values:
stringcontaining the IP results from the URL DNS

Definition at line 293 of file BG96.cpp.

int rxAvail ( int  id )

Return the amount a data available.

----------------------------------------------------------

Parameters:
char*[at least 40 long]

check for the amount of data available to read

Parameters:
idof BG96 socket
Return values:
numberof bytes in RX buffer or 0

Definition at line 512 of file BG96.cpp.

bool send ( int  id,
const void *  data,
uint32_t  amount 
)

Sends data to an open socket.

----------------------------------------------------------

Parameters:
idof socket to send to
datato be sent
amountof data to be sent
Returns:
true only if data sent successfully

send data to the BG96

Parameters:
idof BG96 socket
pointerto the data to send
numberof bytes to send
Return values:
trueif send successfull false otherwise

Definition at line 472 of file BG96.cpp.

int setContext ( int  i )

----------------------------------------------------------

set the contextID for the BG96. This context will be used for all subsequent operations

Parameters:
intof desired context. if <1, return the current context
Return values:
currentcontext

Definition at line 151 of file BG96.cpp.

bool startup ( void   )

Init the BG96.

----------------------------------------------------------

Parameters:
modemode in which to startup
Returns:
true only if BG96 has started up correctly

startup BG96 module

Parameters:
none
Return values:
trueif successful, false otherwise

Definition at line 208 of file BG96.cpp.

void waitBG96Ready ( void   )

Wait for 'RDY' signal or timeout waiting...

Returns:
none.
bool writeable (  )

Checks if data can be written.

----------------------------------------------------------

determine if BG96 is writable

Parameters:
none
Return values:
true/false

Definition at line 334 of file BG96.cpp.