Merge pull request #620 from nkolban/master

Removal of hardware reset for logical jshReset
This commit is contained in:
Gordon Williams 2015-10-06 08:12:53 +01:00
commit bb58aadae5
16 changed files with 1465 additions and 1408 deletions

View File

@ -652,7 +652,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = src libs targets/stm32
INPUT = src libs targets/stm32 targets/esp8266
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@ -676,7 +676,7 @@ FILE_PATTERNS =
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = NO
RECURSIVE = YES
# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
@ -698,7 +698,7 @@ EXCLUDE_SYMLINKS = NO
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = *.md
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@ -1214,7 +1214,7 @@ SERVER_BASED_SEARCH = NO
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = YES
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be

View File

@ -27,6 +27,7 @@ static void ipAddrToString(struct ip_addr addr, char *string);
static char *nullTerminateString(char *target, char *source, int sourceLength);
static void setupJsNetwork();
static void pingRecvCB();
static char *wifiConnectStatusToString(uint8 status);
static JsVar *jsScanCallback;
static JsVar *jsWiFiEventCallback;
@ -65,22 +66,20 @@ static char *wifiPhy[] = { 0, "11b", "11g", "11n" };
}*/
/**
* \brief Connect the station to an access point.
* - `ssid` - The network id of the access point.
* - `password` - The password to use to connect to the access point.
*/
/*JSON{
"type" : "staticmethod",
"class" : "ESP8266WiFi",
"name" : "connect",
"generate" : "jswrap_ESP8266WiFi_connect",
"params" : [
["ssid","JsVar","The network SSID"],
["ssid","JsVar","The network id of the access point."],
["password","JsVar","The password to the access point"],
["gotIpCallback", "JsVar", "An optional callback invoked when we have an IP"]
]
}*/
}
*
* Connect the station to an access point.
*/
void jswrap_ESP8266WiFi_connect(
JsVar *jsv_ssid, //!< The SSID of the access point to connect.
JsVar *jsv_password, //!< The password for the access point.
@ -118,7 +117,9 @@ void jswrap_ESP8266WiFi_connect(
if (gotIpCallback != NULL) {
jsGotIpCallback = jsvLockAgainSafe(gotIpCallback);
}
os_printf("jsGotIpCallback=%p\n", jsGotIpCallback);
// Debug
// os_printf("jsGotIpCallback=%p\n", jsGotIpCallback);
// Create strings from the JsVars for the ESP8266 API calls.
char ssid[33];
@ -128,8 +129,9 @@ void jswrap_ESP8266WiFi_connect(
len = jsvGetString(jsv_password, password, sizeof(password)-1);
password[len]='\0';
os_printf("> - ssid=%s, password=%s\n", ssid, password);
// Set the WiFi mode of the ESP8266
os_printf("> - ssid=%s, password=%s\n", ssid, password);
// Set the WiFi mode of the ESP8266
wifi_set_opmode_current(STATION_MODE);
struct station_config stationConfig;
@ -144,13 +146,49 @@ void jswrap_ESP8266WiFi_connect(
// Set the WiFi configuration
wifi_station_set_config(&stationConfig);
uint8 wifiConnectStatus = wifi_station_get_connect_status();
os_printf(" - Current connect status: %s\n", wifiConnectStatusToString(wifiConnectStatus));
if (wifiConnectStatus == STATION_GOT_IP) {
// See issue #618. There are currently three schools of thought on what should happen
// when a connect is issued and we are already connected.
//
// Option #1 - Always perform a disconnect.
// Option #2 - Perform a disconnect if the SSID or PASSWORD are different from current
// Option #3 - Fail the connect if we are already connected.
//
#define ISSUE_618 1
#if ISSUE_618 == 1
wifi_station_disconnect();
#elif ISSUE_618 == 2
struct station_config existingConfig;
wifi_station_get_config(&existingConfig);
if (os_strncpy((char *)existingConfig.ssid, (char *)stationConfig.ssid, 32) == 0 &&
os_strncpy((char *)existingConfig.password, (char *)stationConfig.password, 64) == 0) {
if (jsGotIpCallback != NULL) {
JsVar *params[2];
params[0] = jsvNewFromInteger(STATION_GOT_IP);
params[1] = jsvNewNull();
jsiQueueEvents(NULL, jsGotIpCallback, params, 2);
}
return;
} else {
wifi_station_disconnect();
}
#elif ISSUE_618 == 3
// Add a return code to the function and return an already connected error.
#endif
}
// Perform the network level connection.
wifi_station_connect();
os_printf("< jswrap_ESP8266WiFi_connect\n");
}
/**
* \brief Become an access point.
* Become an access point.
* When we call this function we are instructing the ESP8266 to set itself up as an
* access point to allow other WiFi stations to connect to it. In order to be an access
* point, the ESP8266 needs to know the SSID it should use as well as the password used
@ -223,7 +261,7 @@ void jswrap_ESP8266WiFi_beAccessPoint(
/**
* \brief Determine the list of access points available to us.
* Determine the list of access points available to us.
*/
/*JSON{
"type" : "staticmethod",
@ -261,7 +299,7 @@ void jswrap_ESP8266WiFi_getAccessPoints(
/**
* \brief Disconnect the station from the access point.
* Disconnect the station from the access point.
*/
/*JSON{
"type" : "staticmethod",
@ -286,7 +324,7 @@ void jswrap_ESP8266WiFi_restart() {
/**
* \brief Register a callback function that will be invoked when a WiFi event is detected.
* Register a callback function that will be invoked when a WiFi event is detected.
*/
/*JSON{
"type" : "staticmethod",
@ -326,7 +364,7 @@ void jswrap_ESP8266WiFi_onWiFiEvent(
/**
* \brief Set whether or not the ESP8266 will perform an auto connect on startup.
* Set whether or not the ESP8266 will perform an auto connect on startup.
* A value of true means it will while a value of false means it won't.
*/
/*JSON{
@ -349,7 +387,6 @@ void jswrap_ESP8266WiFi_setAutoConnect(
uint8 newValue = jsvGetBool(autoconnect);
os_printf("New value: %d\n", newValue);
os_printf("jswrap_ESP8266WiFi_setAutoConnect -> Something breaks here :-(\n");
uart_rx_intr_disable(0);
wifi_station_set_auto_connect(newValue);
@ -359,7 +396,7 @@ void jswrap_ESP8266WiFi_setAutoConnect(
/**
* \brief Retrieve whether or not the ESP8266 will perform an auto connect on startup.
* Retrieve whether or not the ESP8266 will perform an auto connect on startup.
* A value of 1 means it will while a value of zero means it won't.
*/
/*JSON{
@ -376,7 +413,7 @@ JsVar *jswrap_ESP8266WiFi_getAutoConnect() {
/**
* \brief Retrieve the reset information that is stored when event the ESP8266 resets.
* Retrieve the reset information that is stored when event the ESP8266 resets.
* The result will be a JS object containing the details.
*/
/*JSON{
@ -402,7 +439,7 @@ JsVar *jswrap_ESP8266WiFi_getRstInfo() {
/**
* \brief Return an object that contains details about the state of the ESP8266.
* Return an object that contains details about the state of the ESP8266.
* - `sdkVersion` - Version of the SDK.
* - `cpuFrequency` - CPU operating frequency.
* - `freeHeap` - Amount of free heap.
@ -429,7 +466,7 @@ JsVar *jswrap_ESP8266WiFi_getState() {
}
/**
* \brief Return the value of an integer representation (4 bytes) of IP address
* Return the value of an integer representation (4 bytes) of IP address
* as a string.
*/
/*JSON{
@ -455,7 +492,7 @@ JsVar *jswrap_ESP8266WiFi_getAddressAsString(
/**
* \brief Retrieve the IP information about this network interface and return a JS
* Retrieve the IP information about this network interface and return a JS
* object that contains its details.
* The object will have the following properties defined upon it:
* - `ip` - The IP address of the interface.
@ -483,7 +520,7 @@ JsVar *jswrap_ESP8266WiFi_getIPInfo() {
/**
* \brief Query the station configuration and return a JS object that represents the
* Query the station configuration and return a JS object that represents the
* current settings.
* The object will have the following properties:
*
@ -514,7 +551,7 @@ JsVar *jswrap_ESP8266WiFi_getStationConfig() {
/**
* \brief Determine the list of connected stations and return them.
* Determine the list of connected stations and return them.
*/
/*JSON{
"type" : "staticmethod",
@ -542,7 +579,7 @@ JsVar *jswrap_ESP8266WiFi_getConnectedStations() {
/**
* \brief Get the signal strength.
* Get the signal strength.
*/
/*JSON{
"type" : "staticmethod",
@ -559,7 +596,7 @@ JsVar *jswrap_ESP8266WiFi_getRSSI() {
/**
* \brief Initialize the ESP8266 environment.
* Initialize the ESP8266 environment.
*/
/*JSON{
"type" : "staticmethod",
@ -693,7 +730,7 @@ void jswrap_ESP8266WiFi_socketEnd(
/**
* \brief Perform a network ping request.
* Perform a network ping request.
* The parameter can be either a String or a numeric IP address.
*/
/*JSON{
@ -759,7 +796,7 @@ void jswrap_ESP8266WiFi_ping(
/**
* \brief Dump the data in the socket.
* Dump the data in the socket.
*/
/*JSON{
"type" : "staticmethod",
@ -778,7 +815,7 @@ void jswrap_ESP8266WiFi_dumpSocket(
}
/**
* \brief Null terminate a string.
* Null terminate a string.
*/
static char *nullTerminateString(char *target, char *source, int sourceLength) {
os_strncpy(target, source, sourceLength);
@ -797,7 +834,7 @@ static void setupJsNetwork() {
/**
* \brief Handle receiving a response from a ping reply.
* Handle receiving a response from a ping reply.
* If a callback function has been supplied we invoked that callback by queuing it for future
* execution. A parameter is supplied to the callback which is a JavaScript object that contains:
* - totalCount
@ -830,7 +867,7 @@ static void pingRecvCB(void *pingOpt, void *pingResponse) {
/**
* \brief Callback function that is invoked at the culmination of a scan.
* Callback function that is invoked at the culmination of a scan.
*/
static void scanCB(void *arg, STATUS status) {
/**
@ -897,7 +934,7 @@ static void scanCB(void *arg, STATUS status) {
/**
* \brief Invoke the JavaScript callback to notify the program that an ESP8266
* Invoke the JavaScript callback to notify the program that an ESP8266
* WiFi event has occurred.
*/
static void sendWifiEvent(uint32 eventType, JsVar *details) {
@ -925,7 +962,7 @@ static void sendWifiEvent(uint32 eventType, JsVar *details) {
/**
* \brief ESP8266 WiFi Event handler.
* ESP8266 WiFi Event handler.
* This function is called by the ESP8266
* environment when significant events happen related to the WiFi environment.
* The event handler is registered with a call to wifi_set_event_handler_cb()
@ -993,7 +1030,7 @@ static void wifiEventHandler(System_Event_t *evt) {
}
/**
* \brief Write an IP address as a dotted decimal string.
* Write an IP address as a dotted decimal string.
*/
// Note: This may be a duplicate ... it appears that we may have an existing function
// in network.c which does exactly this and more!!
@ -1001,3 +1038,29 @@ static void wifiEventHandler(System_Event_t *evt) {
static void ipAddrToString(struct ip_addr addr, char *string) {
os_sprintf(string, "%d.%d.%d.%d", ((char *)&addr)[0], ((char *)&addr)[1], ((char *)&addr)[2], ((char *)&addr)[3]);
}
/**
* Convert an ESP8266 WiFi connect status to a string.
*
* Convert the status (as returned by `wifi_station_get_connect_status()`) to a string
* representation.
* \return A string representation of a WiFi connect status.
*/
static char *wifiConnectStatusToString(uint8 status) {
switch(status) {
case STATION_IDLE:
return "STATION_IDLE";
case STATION_CONNECTING:
return "STATION_CONNECTING";
case STATION_WRONG_PASSWORD:
return "STATION_WRONG_PASSWORD";
case STATION_NO_AP_FOUND:
return "STATION_NO_AP_FOUND";
case STATION_CONNECT_FAIL:
return "STATION_CONNECT_FAIL";
case STATION_GOT_IP:
return "STATION_GOT_IP";
default:
return "Unknown connect status!!";
}
}

File diff suppressed because it is too large Load Diff

View File

@ -117,7 +117,7 @@ unsigned long networkFlipIPAddress(unsigned long addr) {
}
/**
* \brief Get the IP address of a hostname.
* Get the IP address of a hostname.
* Retrieve the IP address of a hostname and return it in the address of the
* ip address passed in. If the hostname is as dotted decimal string, we will
* decode that immediately otherwise we will use the network adapter's `gethostbyname`

View File

@ -32,7 +32,7 @@ JshEventCallbackCallback jshEventCallbacks[EV_EXTI_MAX+1-EV_EXTI0];
// DATA TRANSMIT BUFFER
/**
* \brief A single character to be transmitted.
* A single character to be transmitted.
*/
typedef struct {
IOEventFlags flags; //!< Where this data should be transmitted
@ -40,7 +40,7 @@ typedef struct {
} PACKED_FLAGS TxBufferItem;
/**
* \brief An array of items to transmit.
* An array of items to transmit.
*/
volatile TxBufferItem txBuffer[TXBUFFERMASK+1];
@ -67,7 +67,7 @@ volatile unsigned char ioHead=0, ioTail=0;
/**
* \brief Initialize all the devices.
* Initialize all the devices.
*/
void jshInitDevices() { // called from jshInit
int i;
@ -83,7 +83,7 @@ void jshInitDevices() { // called from jshInit
// ----------------------------------------------------------------------------
/**
* \brief Queue a character for transmission.
* Queue a character for transmission.
*/
void jshTransmit(
IOEventFlags device, //!< The device to be used for transmission.
@ -140,7 +140,7 @@ IOEventFlags jshGetDeviceToTransmit() {
}
/**
* \brief Try and get a character for transmission.
* Try and get a character for transmission.
* \return The next byte to transmit or -1 if there is none.
*/
int jshGetCharToTransmit(
@ -187,7 +187,7 @@ void jshTransmitFlush() {
}
/**
* \brief Discard all the data waiting for transmission.
* Discard all the data waiting for transmission.
*/
void jshTransmitClearDevice(
IOEventFlags device //!< The device to be cleared.
@ -210,7 +210,7 @@ void jshTransmitMove(IOEventFlags from, IOEventFlags to) {
}
/**
* \brief Determine if we have data to be transmitted.
* Determine if we have data to be transmitted.
* \return True if we have data to transmit and false otherwise.
*/
bool jshHasTransmitData() {
@ -218,7 +218,7 @@ bool jshHasTransmitData() {
}
/**
* \brief flag that the buffer has overflowed.
* flag that the buffer has overflowed.
*/
void jshIOEventOverflowed() {
// Error here - just set flag so we don't dump a load of data out
@ -227,7 +227,7 @@ void jshIOEventOverflowed() {
/**
* \brief Send a character to the specified device.
* Send a character to the specified device.
*/
void jshPushIOCharEvent(
IOEventFlags channel, // !< The device to target for output.
@ -340,7 +340,7 @@ bool jshPopIOEventOfType(IOEventFlags eventType, IOEvent *result) {
}
/**
* \brief Determine if we have I/O events to process.
* Determine if we have I/O events to process.
* \return True if there are I/O events to be processed.
*/
bool jshHasEvents() {
@ -369,7 +369,7 @@ bool jshHasEventSpaceForChars(int n) {
// DEVICES
/**
* \brief Get a string representation of a device.
* Get a string representation of a device.
* \return A string representation of a device.
*/
const char *jshGetDeviceString(
@ -417,7 +417,7 @@ const char *jshGetDeviceString(
}
/**
* \brief Get a device identity from a string.
* Get a device identity from a string.
* \return A device identity.
*/
IOEventFlags jshFromDeviceString(

View File

@ -71,7 +71,7 @@ void jsiDebuggerLine(JsVar *line);
// ----------------------------------------------------------------------------
/**
* \brief Get the device from the class variable.
* Get the device from the class variable.
*/
IOEventFlags jsiGetDeviceFromClass(JsVar *class) {
// Devices have their Object data set up to something special
@ -124,7 +124,7 @@ static NO_INLINE void jsiAppendToInputLine(const char *str) {
}
/**
* \brief Change the console to a new location.
* Change the console to a new location.
*/
void jsiSetConsoleDevice(
IOEventFlags device //!< The device to use as a console.
@ -157,7 +157,7 @@ void jsiSetConsoleDevice(
}
/**
* \brief Retrieve the device being used as the console.
* Retrieve the device being used as the console.
*/
IOEventFlags jsiGetConsoleDevice() {
// The `consoleDevice` is the global used to hold the current console. This function
@ -166,7 +166,7 @@ IOEventFlags jsiGetConsoleDevice() {
}
/**
* \brief Send a character to the console.
* Send a character to the console.
*/
NO_INLINE void jsiConsolePrintChar(char data) {
jshTransmit(consoleDevice, (unsigned char)data);
@ -183,7 +183,7 @@ NO_INLINE void jsiConsolePrint(const char *str) {
}
/**
* \brief Perform a printf to the console.
* Perform a printf to the console.
* Execute a printf command to the current JS console.
*/
void jsiConsolePrintf(const char *fmt, ...) {
@ -228,7 +228,7 @@ void jsiConsolePrintStringVarWithNewLineChar(JsVar *v, size_t fromCharacter, cha
}
/**
* \brief Print the contents of a string var - directly.
* Print the contents of a string var - directly.
*/
void jsiConsolePrintStringVar(JsVar *v) {
jsiConsolePrintStringVarWithNewLineChar(v,0,0);
@ -357,7 +357,7 @@ void jsiConsolePrintPosition(struct JsLex *lex, size_t tokenPos) {
}
/**
* \brief Clear the input line of data.
* Clear the input line of data.
*/
void jsiClearInputLine() {
jsiConsoleRemoveInputLine();
@ -368,7 +368,7 @@ void jsiClearInputLine() {
}
/**
* \brief ??? What does this do ???.
* ??? What does this do ???.
*/
void jsiSetBusy(
JsiBusyDevice device, //!< ???
@ -386,7 +386,7 @@ void jsiSetBusy(
}
/**
* \brief Set the status of a pin as a function of whether we are asleep.
* Set the status of a pin as a function of whether we are asleep.
* When called, if a pin is set for a sleep indicator, we set the pin to be true
* if the sleep type is awake and false otherwise.
*/

View File

@ -25,7 +25,7 @@
#endif
/**
* \brief Validate that the pin is a good pin.
* Validate that the pin is a good pin.
* \return True if the pin is valid.
*/
bool jshIsPinValid(Pin pin) {
@ -34,7 +34,7 @@ bool jshIsPinValid(Pin pin) {
}
/**
* \brief Get a pin value from an encoded strin.
* Get a pin value from an encoded strin.
* \return A pin value.
*/
Pin jshGetPinFromString(const char *s) {
@ -223,7 +223,7 @@ void jshSetPinStateIsManual(Pin pin, bool manual) {
// ----------------------------------------------------------------------------
/**
* \brief Get the value of a pin.
* Get the value of a pin.
* \return The value of the pin.
*/
bool jshPinInput(
@ -243,7 +243,7 @@ bool jshPinInput(
/**
* \brief Set the value of a pin.
* Set the value of a pin.
*/
void jshPinOutput(
Pin pin, //!< The pin to set.

View File

@ -15,7 +15,7 @@
#include "jsinteractive.h"
/**
* \brief Dump the internal SPI Info data structure to the console.
* Dump the internal SPI Info data structure to the console.
* This is an internal debugging function.
*/
void jsspiDumpSPIInfo(JshSPIInfo *inf) {
@ -31,7 +31,7 @@ int jsspiHardwareFunc(int data, spi_sender_data *info) {
/**
* \brief Send a single byte through SPI.
* Send a single byte through SPI.
* \return The received byte.
*/
int jsspiFastSoftwareFunc(
@ -56,7 +56,7 @@ int jsspiFastSoftwareFunc(
/**
* \brief Send a single byte through SPI.
* Send a single byte through SPI.
* \return The received byte.
*/
int jsspiSoftwareFunc(
@ -105,7 +105,7 @@ int jsspiSoftwareFunc(
/**
* \brief Populate a JshSPIInfo structure from a JS Object.
* Populate a JshSPIInfo structure from a JS Object.
* The object properties that are examined are:
* * `sck` - The pin to use for the clock.
* * `miso` - The pin to use for Master In/Slave Out.
@ -149,7 +149,7 @@ void jsspiPopulateSPIInfo(
}
/**
* \brief Select the SPI send function.
* Select the SPI send function.
* Get the correct SPI send function (and the data to send to it). We do this
* by examining the device and determining if it is hardware, software fast
* or software regular.

View File

@ -156,7 +156,7 @@ long long stringToIntWithRadix(const char *s, int forceRadix, bool *hasError) {
}
/**
* \brief Convert hex, binary, octal or decimal string into an int.
* Convert hex, binary, octal or decimal string into an int.
*/
long long stringToInt(const char *s) {
return stringToIntWithRadix(s,0,0);
@ -327,7 +327,7 @@ void srand(unsigned int seed) {
/**
* \brief Convert a string to a JS float variable where the string is of a specific radix.
* Convert a string to a JS float variable where the string is of a specific radix.
* \return A JS float variable.
*/
JsVarFloat stringToFloatWithRadix(
@ -413,7 +413,7 @@ JsVarFloat stringToFloatWithRadix(
/**
* \brief convert a string to a floating point JS variable.
* convert a string to a floating point JS variable.
* \return a JS float variable.
*/
JsVarFloat stringToFloat(
@ -512,7 +512,7 @@ JsVarFloat wrapAround(JsVarFloat val, JsVarFloat size) {
}
/**
* \brief Espruino-special printf with a callback.
* Espruino-special printf with a callback.
*
* The supported format specifiers are:
* * `%d` = int

View File

@ -14,7 +14,7 @@
#include "jsvariterator.h"
/**
* \brief Iterate over the contents of the content of a variable, calling callback for each.
* Iterate over the contents of the content of a variable, calling callback for each.
* Contents may be:
* * numeric -> output
* * a string -> output each character
@ -94,7 +94,7 @@ bool jsvIterateCallback(
/**
* \brief An iterable callback that counts how many times it was called.
* An iterable callback that counts how many times it was called.
* This is a function that can be supplied to `jsvIterateCallback`.
*/
static void jsvIterateCallbackCountCb(
@ -108,7 +108,7 @@ static void jsvIterateCallbackCountCb(
/**
* \brief Determine how many items are in this variable that will be iterated over.
* Determine how many items are in this variable that will be iterated over.
* \return The number of iterations we will call for this variable.
*/
int jsvIterateCallbackCount(JsVar *var) {

View File

@ -254,7 +254,7 @@ example `digitalWrite([A1,A1,A0,A0],0b0101)` would pulse A0 followed by A1.
*/
/**
* \brief Set the output of a GPIO.
* Set the output of a GPIO.
*/
void jswrap_io_digitalWrite(
JsVar *pinVar, //!< A pin or pins.
@ -299,7 +299,7 @@ the last array element is the least significant bit, for example if `A0=A1=1` an
*/
/**
* \brief Read the value of a GPIO pin.
* Read the value of a GPIO pin.
*/
JsVarInt jswrap_io_digitalRead(JsVar *pinVar) {
// Hadnle the case where it is an array of pins.
@ -351,7 +351,7 @@ Set the mode of the given pin.
*/
/**
* \brief Set the mode of a pin.
* Set the mode of a pin.
*/
void jswrap_io_pinMode(
Pin pin, //!< The pin to set.

View File

@ -40,7 +40,7 @@ You can call the methods on Pin, or you can use Wiring-style functions such as d
Creates a pin from the given argument (or returns undefined if no argument)
*/
/**
* \brief Create an instance of a Pin class.
* Create an instance of a Pin class.
*/
JsVar *jswrap_pin_constructor(JsVar *val) {
Pin pin = jshGetPinFromVar(val);
@ -189,7 +189,7 @@ Get information about this pin and its capabilities. Of the form:
Will return undefined if pin is not valid.
*/
/**
* \brief
*
*/
JsVar *jswrap_pin_getInfo(
JsVar *parent //!< The class instance representing the pin.

View File

@ -163,7 +163,7 @@ typedef struct {
/**
* \brief Send a single byte to the SPI device, used ad callback.
* Send a single byte to the SPI device, used ad callback.
*/
void jswrap_spi_send_cb(
int c, //!< The byte to send through SPI.
@ -181,7 +181,7 @@ void jswrap_spi_send_cb(
/**
* \brief Send data through SPI.
* Send data through SPI.
* The data can be in a variety of formats including:
* * `numeric` - A single byte is transmitted.
* * `string` - Each character in the string is transmitted.

View File

@ -13,7 +13,7 @@ typedef long long int64_t;
#include "jsutils.h"
/**
* \brief Convert an ESP8266 error code to a string.
* Convert an ESP8266 error code to a string.
* Given an ESP8266 network error code, return a string representation
* of the meaning of that code.
* \return A string representation of an error code.
@ -51,7 +51,7 @@ const char *esp8266_errorToString(
/**
* \brief Write a buffer of data to the console.
* Write a buffer of data to the console.
* The buffer is pointed to by the buffer
* parameter and will be written for the length parameter. This is useful because
* unlike a string, the data does not have to be NULL terminated.

View File

@ -76,14 +76,14 @@ void jshInit() {
} // End of jshInit
/**
* \brief Reset the hardware to a power-on state
* Reset the hardware to a power-on state.
*/
void jshReset() {
system_restart();
//system_restart();
} // End of jshReset
/**
* \brief Handle whatever needs to be done in the idle loop when there's nothing to do
* Handle whatever needs to be done in the idle loop when there's nothing to do.
*
* Nothing is needed on the esp8266. The watchdog timer is taken care of by the SDK.
*/
@ -127,7 +127,7 @@ bool jshSleep(JsSysTime timeUntilWake) {
void jshDelayMicroseconds(int microsec) {
// Keep things simple and make the user responsible if they sleep for too long...
if (microsec > 0) {
os_printf("Delay %ldus\n", microsec);
os_printf("Delay %d us\n", microsec);
os_delay_us(microsec);
}
#if 0
@ -215,7 +215,7 @@ static uint8_t pinFunction(JshPinState state) {
/**
* \brief Convert a pin state to a string representation.
* Convert a pin state to a string representation.
*/
static char *pinStateToString(JshPinState state) {
switch(state) {
@ -251,7 +251,7 @@ static char *pinStateToString(JshPinState state) {
}
/**
* \brief Set the state of the specific pin.
* Set the state of the specific pin.
*
* The possible states are:
*
@ -321,7 +321,7 @@ void jshPinSetState(Pin pin, //!< The pin to have its state changed.
/**
* \brief Return the current state of the selected pin.
* Return the current state of the selected pin.
* \return The current state of the selected pin.
*/
JshPinState jshPinGetState(Pin pin) {
@ -332,7 +332,7 @@ JshPinState jshPinGetState(Pin pin) {
//===== GPIO and PIN stuff =====
/**
* \brief Set the value of the corresponding pin.
* Set the value of the corresponding pin.
*/
void jshPinSetValue(Pin pin, //!< The pin to have its value changed.
bool value //!< The new value of the pin.
@ -344,7 +344,7 @@ void jshPinSetValue(Pin pin, //!< The pin to have its value changed.
/**
* \brief Get the value of the corresponding pin.
* Get the value of the corresponding pin.
* \return The current value of the pin.
*/
bool jshPinGetValue(Pin pin //!< The pin to have its value read.
@ -356,7 +356,7 @@ bool jshPinGetValue(Pin pin //!< The pin to have its value read.
/**
* \brief
*
*/
JsVarFloat jshPinAnalog(Pin pin) {
os_printf("> ESP8266: jshPinAnalog: %d\n", pin);
@ -365,7 +365,7 @@ JsVarFloat jshPinAnalog(Pin pin) {
/**
* \brief
*
*/
int jshPinAnalogFast(Pin pin) {
os_printf("> ESP8266: jshPinAnalogFast: %d\n", pin);
@ -374,7 +374,7 @@ int jshPinAnalogFast(Pin pin) {
/**
* \brief
*
*/
JshPinFunction jshPinAnalogOutput(Pin pin, JsVarFloat value, JsVarFloat freq, JshAnalogOutputFlags flags) { // if freq<=0, the default is used
os_printf("ESP8266: jshPinAnalogOutput: %d, %d, %d\n", pin, (int)value, (int)freq);
@ -384,7 +384,7 @@ JshPinFunction jshPinAnalogOutput(Pin pin, JsVarFloat value, JsVarFloat freq, Js
/**
* \brief
*
*/
void jshSetOutputValue(JshPinFunction func, int value) {
os_printf("ESP8266: jshSetOutputValue %d %d\n", func, value);
@ -392,7 +392,7 @@ void jshSetOutputValue(JshPinFunction func, int value) {
/**
* \brief
*
*/
void jshEnableWatchDog(JsVarFloat timeout) {
os_printf("ESP8266: jshEnableWatchDog %0.3f\n", timeout);
@ -400,7 +400,7 @@ void jshEnableWatchDog(JsVarFloat timeout) {
/**
* \brief
*
*/
bool jshGetWatchedPinState(IOEventFlags device) {
os_printf("ESP8266: jshGetWatchedPinState %d", device);
@ -409,7 +409,7 @@ bool jshGetWatchedPinState(IOEventFlags device) {
/**
* \brief Set the value of the pin to be the value supplied and then wait for
* Set the value of the pin to be the value supplied and then wait for
* a given period and set the pin value again to be the opposite.
*/
void jshPinPulse(Pin pin, //!< The pin to be pulsed.
@ -427,7 +427,7 @@ void jshPinPulse(Pin pin, //!< The pin to be pulsed.
/**
* \brief
*
*/
bool jshCanWatch(Pin pin) {
return false;
@ -435,7 +435,7 @@ bool jshCanWatch(Pin pin) {
/**
* \brief
*
*/
IOEventFlags jshPinWatch(
Pin pin, //!< Unknown
@ -449,7 +449,7 @@ IOEventFlags jshPinWatch(
/**
* \brief
*
*/
JshPinFunction jshGetCurrentPinFunction(Pin pin) {
//os_printf("jshGetCurrentPinFunction %d\n", pin);
@ -457,7 +457,7 @@ JshPinFunction jshGetCurrentPinFunction(Pin pin) {
}
/**
* \brief
*
*/
bool jshIsEventForPin(IOEvent *event, Pin pin) {
return IOEVENTFLAGS_GETTYPE(event->flags) == pinToEVEXTI(pin);
@ -466,7 +466,7 @@ bool jshIsEventForPin(IOEvent *event, Pin pin) {
//===== USART and Serial =====
/**
* \brief
*
*/
void jshUSARTSetup(IOEventFlags device, JshUSARTInfo *inf) {
}
@ -477,8 +477,8 @@ bool jshIsUSBSERIALConnected() {
} // End of jshIsUSBSERIALConnected
/**
* \brief
* Kick a device into action (if required).
*
* For instance we may need
* to set up interrupts. In this ESP8266 implementation, we transmit all the
* data that can be found associated with the device.
@ -493,7 +493,8 @@ void jshUSARTKick(
//===== SPI =====
/**
* \brief Unknown
* Unknown
*
*
*/
void jshSPISetup(
@ -516,7 +517,7 @@ int jshSPISend(
/**
\brief * Send 16 bit data through the given SPI device.
* Send 16 bit data through the given SPI device.
*/
void jshSPISend16(
IOEventFlags device, //!< Unknown
@ -529,7 +530,7 @@ void jshSPISend16(
/**
* \brief Set whether to send 16 bits or 8 over SPI.
* Set whether to send 16 bits or 8 over SPI.
*/
void jshSPISet16(
IOEventFlags device, //!< Unknown
@ -540,7 +541,7 @@ void jshSPISet16(
/**
* \brief Wait until SPI send is finished.
* Wait until SPI send is finished.
*/
void jshSPIWait(
IOEventFlags device //!< Unknown
@ -630,7 +631,7 @@ static void saveTime() {
(uint32_t)(rtcTimeStamp.timeStamp >> 32);
system_rtc_mem_write(RTC_TIME_ADDR, &rtcTimeStamp, sizeof(rtcTimeStamp));
os_printf("RTC write: %lu %lu 0x%08x\n", (uint32_t)(rtcTimeStamp.timeStamp/1000000),
rtcTimeStamp.hwTimeStamp, rtcTimeStamp.cksum);
rtcTimeStamp.hwTimeStamp, (int)rtcTimeStamp.cksum);
}
/**
@ -641,13 +642,6 @@ JsSysTime jshGetSystemTime() { // in us
} // End of jshGetSystemTime
bool jshFlashContainsCode() {
os_printf("ESP8266: jshFlashContainsCode\n");
return false;
}
/**
* Set the current time in microseconds.
*/
@ -703,8 +697,8 @@ static void systemTimeInit(void) {
uint32_t cksum = rtcTimeStamp.cksum ^ rtcTimeStamp.hwTimeStamp ^
(uint32_t)(rtcTimeStamp.timeStamp & 0xffffffff) ^
(uint32_t)(rtcTimeStamp.timeStamp >> 32);
os_printf("RTC read: %lu %lu 0x%08x (0x%08x)\n", (uint32_t)(rtcTimeStamp.timeStamp/1000000),
rtcTimeStamp.hwTimeStamp, rtcTimeStamp.cksum, cksum);
os_printf("RTC read: %d %d 0x%08x (0x%08x)\n", (int)(rtcTimeStamp.timeStamp/1000000),
(int)rtcTimeStamp.hwTimeStamp, (unsigned int)rtcTimeStamp.cksum, (unsigned int)cksum);
if (reason < 1 || reason > 4 || cksum != 0xdeadbeef) {
// we lost track of time, start at zero
os_printf("RTC: cannot restore time\n");
@ -754,7 +748,7 @@ void jshUtilTimerDisable() {
}
void jshUtilTimerStart(JsSysTime period) {
os_printf("UStimer arm %lluus\n");
os_printf("UStimer arm\n");
os_timer_arm_us(&utilTimer, (uint32_t)period, 0);
}
@ -826,7 +820,7 @@ unsigned int jshGetRandomNumber() {
//===== Read-write flash =====
/**
* \brief Read data from flash memory into the buffer.
* Read data from flash memory into the buffer.
*
* This reads from flash using memory-mapped reads. Only works for the first 1MB and
* requires 4-byte aligned reads.
@ -856,7 +850,7 @@ void jshFlashRead(
/**
* \brief Write data to flash memory from the buffer.
* Write data to flash memory from the buffer.
*
* This is called from jswrap_flash_write and ... which guarantee that addr is 4-byte aligned
* and len is a multiple of 4.
@ -883,7 +877,7 @@ void jshFlashWrite(
/**
* \brief Return start address and size of the flash page the given address resides in.
* Return start address and size of the flash page the given address resides in.
* Returns false if no page.
*/
bool jshFlashGetPage(
@ -901,7 +895,7 @@ bool jshFlashGetPage(
/**
* \brief Erase the flash page containing the address.
* Erase the flash page containing the address.
*/
void jshFlashErasePage(
uint32_t addr //!<

View File

@ -47,7 +47,7 @@ static os_timer_t mainLoopSuspendTimer;
#if 0
/**
* \brief A callback function to be invoked when a line has been entered on the telnet client.
* A callback function to be invoked when a line has been entered on the telnet client.
* Here we want to pass that line to the JS parser for processing.
*/
static void telnetLineCB(char *line) {
@ -79,7 +79,7 @@ static char *flash_maps[] = {
};
/**
* \brief Dump the ESP8266 restart information.
* Dump the ESP8266 restart information.
* This is purely for debugging.
* When an ESP8266 crashes, before it ends, it records its exception information.
* This function retrieves that data and logs it.
@ -102,7 +102,7 @@ static void dumpRestart() {
/**
* \brief Queue a task for the main loop.
* Queue a task for the main loop.
*/
static void queueTaskMainLoop() {
system_os_post(TASK_APP_QUEUE, TASK_APP_MAINLOOP, 0);
@ -110,7 +110,7 @@ static void queueTaskMainLoop() {
/**
* \brief Suspend processing the main loop for a period of time.
* Suspend processing the main loop for a period of time.
*/
void suspendMainLoop(
uint32 interval //!< suspension interval in milliseconds
@ -121,7 +121,7 @@ void suspendMainLoop(
/**
* \brief Enable main loop processing.
* Enable main loop processing.
*/
static void enableMainLoop() {
suspendMainLoopFlag = false;
@ -129,7 +129,7 @@ static void enableMainLoop() {
}
/**
* \brief Idle callback from the SDK, triggers an idle loop iteration
* Idle callback from the SDK, triggers an idle loop iteration
*/
static void idle(void) {
// The idle callback comes form the SDK's ets_run function just before it puts the
@ -143,7 +143,7 @@ static void idle(void) {
/**
* \brief The event handler for ESP8266 tasks as created by system_os_post() on the TASK_APP_QUEUE.
* The event handler for ESP8266 tasks as created by system_os_post() on the TASK_APP_QUEUE.
*/
static void eventHandler(
os_event_t *pEvent //!<
@ -178,7 +178,7 @@ static void eventHandler(
static uint32 lastTime = 0;
/**
* \brief Perform the main loop processing.
* Perform the main loop processing.
* This is where work is performed
* as often as possible.
*/
@ -244,7 +244,7 @@ void user_rf_pre_init() {
/**
* \brief The main entry point in an ESP8266 application.
* The main entry point in an ESP8266 application.
* It is where the logic of ESP8266 starts.
*/
void user_init() {