SPEEEduino_LowLevel_Library.cpp
IntroductionUse the links in the table of contents to the left to access the documentation. Functions
beginDeepSleepInitiates the deep sleep feature for the ESP8266 module int16_t SPEEEduino_LowLevel::beginDeepSleep( uint16_t sleepTime, bool blocking) ParametersReturn Value0, if it successfully sleeps and recovers and -1 if it times out (when blocking=true), and always 0 if blocking = false DiscussionWARNING: This is a blocking function with potentially long delays if the blocking flag is set to true beginSingleConnectionInitiates a connection when the module is set to single connection mode, in other words, AT+CIPMUX? returns 0 int16_t SPEEEduino_LowLevel::beginSingleConnection( ConnectionType type, String remoteIP, String remotePort) ParametersReturn Value0 if successfully established connection, 1 if there's an error with the connection, 2 if the connection socket is in use, and -1 if the command timed out beginTCPServerStarts a TCP server with a certain port int16_t SPEEEduino_LowLevel::beginTCPServer( TCPServer createServer, uint16_t port) ParametersReturn Value0 if the TCP server is initialised, 1 if the TCP server did not initialise, -1 if the command timed out disconnectAPDisconnect from an access point. int16_t SPEEEduino_LowLevel::disconnectAP() Return Value0 if successfully disconnected access point, 1 if it failed, and -1 if it timed out endConnectionCloses the current connection int16_t SPEEEduino_LowLevel::endConnection( int8_t linkID = -1) ParametersReturn Value0 if the connection is closed, 1 if the command failed, -1 if the command timed out getLocalIPGet the IP address of the module. If the module is in station mode, it retrieves the assigned IP address of the module. If the module is in SoftAP mode, it will retrieve the IP address of the access point created by the module. int16_t SPEEEduino_LowLevel::getLocalIP() Return Value0, if it successfully returns the IP address and -1 if it times out joinAPJoins an access point with the SSID and password specified. Only works for PSK-based networks (password only) int16_t SPEEEduino_LowLevel::joinAP( String ssid, String password) ParametersReturn Value0 if successfully joined access point, 1 if it failed, and -1 if it timed out listAPLists the access points around the device int16_t SPEEEduino_LowLevel::listAP() Return Value0 if successfully listed all the access points, -1 if the request timed out listVersionLists the firmware version of the firmware on board. This information contains the AT version, SDK version and compile time int16_t SPEEEduino_LowLevel::listVersion() Return Value0, if it responds and -1 if it times out openLinkOpens the serial link from the SPEEEduino to the ESP-01 module void SPEEEduino_LowLevel::openLink() rawInputInputs raw text into the ESP-01 module. This command INCLUDES the carriage return and newline characters WARNING: Make sure that you manually check for the response with the wait() function void SPEEEduino_LowLevel::rawInput( String input) ParametersreceiveDataWaits for data with a timeout. ReturnedData SPEEEduino_LowLevel::receiveData( ConnectionAmount connectionAmount, uint32_t timeOut=20000) ParametersReturn ValueA ReturnedData struct containing the link ID (-1 if you're using single connection) and the returned data in the form of a String DiscussionWARNING: This function is a BLOCKING function, meaning that it will pause your program execution resetint16_t SPEEEduino_LowLevel::reset() Return Value0, if it successfully resets and -1 if it times out DiscussionSoftware resets the module sendDataMultipleConnectionSends data on multiple connection mode, this must be run directly after `startSingleConnection()`. Once this completes successfully, you MUST start reading the input int16_t SPEEEduino_LowLevel::sendDataMultipleConnection( String& data, uint8_t linkID) ParametersReturn Value0 if the data is successfully sent, 1 if the socket failed to initialise, 2 if the connection failed after sending, -1 if the process timed out sendDataSingleConnectionSends data on single connection mode, this must be run directly after `startSingleConnection()`. Once this completes successfully, you MUST start reading the input int16_t SPEEEduino_LowLevel::sendDataSingleConnection( String& data) ParametersReturn Value0 if the data is successfully sent, 1 if the socket failed to initialise, 2 if the connection failed after sending, -1 if the process timed out setConnectionAmountSets the mode for the number of simultaneous connections allowed int16_t SPEEEduino_LowLevel::setConnectionAmount( ConnectionAmount amount) ParametersReturn Value0 if successfully set the name of the station, 1 if the command failed, and -1 if the command timed out setDHCPEnabledSets the DHCP to be enabled or disabled for both station and softAP modes. This int16_t SPEEEduino_LowLevel::setDHCPEnabled( bool enabled) ParametersReturn Value0 if successfully set DHCP mode, -1 if it timed out DiscussionWARNING: This function is only for station mode only! setIPSets parameters for static IP allocation without DHCP. int16_t SPEEEduino_LowLevel::setIP( bool permanent, String ip, String gateway="", String netmask="") ParametersReturn Value0 if successfully set static IP, 1 if there's an issue, and -1 if it times out DiscussionWARNING: You must turn DHCP off with setDHCPEnabled() first before setting the IP! This function has NOT been tested on a real device before! setSoftAPSettingsSets the SoftAP's settings, such as the name of the hotspot, password and so on int16_t SPEEEduino_LowLevel::setSoftAPSettings( String& ssid, String& password, uint8_t channel, EncryptionMethod encryptionMethod) ParametersReturn Value0 if successfully set the name of the station, 1 if the command failed, and -1 if the command timed out setSSLBufferSizeSets the SSL buffer size. int16_t SPEEEduino_LowLevel::setSSLBufferSize( uint16_t bufferSize) ParametersReturn Value0 if successfully set the buffer size, 1 if there's an error, 2 if the buffer size is not within range of [2048,4096] and -1 if the command timed out setStationNameSets name of the ESP8266 client (in other words, when it's connected to a Wi-Fi hotspot) int16_t SPEEEduino_LowLevel::setStationName( String& name) ParametersReturn Value0 if successfully set the name of the station, 1 if the command failed, and -1 if the command timed out setWiFiModeSets the Wi-Fi mode of the device to operate as a Wi-Fi station (client), access point, or both. This setting will be saved in non-volatile memory int16_t SPEEEduino_LowLevel::setWiFiMode( WiFiMode mode) ParametersReturn Value0 if successfully set Wi-Fi mode, -1 if it timed out slowOpenLinkOpens the serial link from the SPEEEduino to the ESP-01 module, and imposes an artificial delay void SPEEEduino_LowLevel::slowOpenLink( int delayTime=5000) ParameterssmokeTestA simple smoke test to see if the module responds int16_t SPEEEduino_LowLevel::smokeTest() Return Value0, if the test is successful and -1 if the test times out waitWaits for a certain serial input. This also prints out the serial data before hitting the correct case if debug mode is enabled. int16_t SPEEEduino_LowLevel::wait( char *values, uint16_t timeOut) ParametersReturn Value-1 if timed out, 0, 1, 2, ... if the data matches one of the values in the values string writeCommandFromPROGMEMWrites a command from PROGMEM to the ESP8266's serial ports void SPEEEduino_LowLevel::writeCommandFromPROGMEM( const char *text) Parameters |