Skip to content

Commit

Permalink
Merge pull request #5 from nodemcu/dev
Browse files Browse the repository at this point in the history
Update latest code from orig
  • Loading branch information
vowstar committed Dec 5, 2015
2 parents b701fe3 + f9400fd commit 25af2b9
Show file tree
Hide file tree
Showing 80 changed files with 864 additions and 279 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ script:
- cd bin/
- file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin"
- srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
# http://docs.travis-ci.com/user/environment-variables/#Convenience-Variables
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash "$TRAVIS_BUILD_DIR"/tools/pr-build.sh; fi
deploy:
provider: releases
api_key:
Expand Down
11 changes: 5 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

We're really glad you're reading this, because we need volunteer developers to help this project come to fruition.

The following is a set of guidelines for contributing to NodeMCU on GitHub. These are just guidelines, not rules, use your best judgment and feel free to propose changes to this document in a pull request.

#### Table Of Contents
It is appreciated but optional if you raise an issue _before_ you start changing NodeMCU, discussing the proposed change; emphasising that the you are proposing to develop the patch yourself, and outling the strategy for implementation. This type of discussion is what we should be doing on the issues list and it is better to do this before or in parallel to developing the patch rather than having "you should have done it this way" type of feedback on the PR itself.

[Development environment setup](#development-environment-setup)
### Table Of Contents

[Working with Git and GitHub](#working-with-git-and-github)
* [Development environment setup](#development-environment-setup)
* [Working with Git and GitHub](#working-with-git-and-github)
* [General flow](#general-flow)
* [Keeping your fork in sync](#keeping-your-fork-in-sync)
* [Commit messages](#commit-messages)
Expand All @@ -34,7 +33,7 @@ Avoid intermediate merge commits. [Rebase](https://www.atlassian.com/git/tutoria
1. `git checkout <branch-name>`
1. Make changes to the code base and commit them using e.g. `git commit -a -m 'Look ma, I did it'`
1. When you're done:
1. [Squash your commits](http://stackoverflow.com/q/5189560/131929) into one. There are several ways of doing this.
1. [Squash your commits](http://stackoverflow.com/a/5201642/131929) into one. There are several ways of doing this.
1. Bring your fork up-to-date with the NodeMCU upstream repo ([see below](#keeping-your-fork-in-sync)). Then rebase your branch on `dev` running `git rebase dev`.
1. `git push`
1. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/) (PR) on GitHub.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ cs:listen(5683)
myvar=1
cs:var("myvar") -- get coap://192.168.18.103:5683/v1/v/myvar will return the value of myvar: 1

all='[1,2,3]'
cs:var("all", coap.JSON) -- sets content type to json

-- function should tack one string, return one string.
function myfun(payload)
print("myfun called")
Expand Down
5 changes: 5 additions & 0 deletions app/coap/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ typedef enum
COAP_CONTENTTYPE_NONE = -1, // bodge to allow us not to send option block
COAP_CONTENTTYPE_TEXT_PLAIN = 0,
COAP_CONTENTTYPE_APPLICATION_LINKFORMAT = 40,
COAP_CONTENTTYPE_APPLICATION_XML = 41,
COAP_CONTENTTYPE_APPLICATION_OCTET_STREAM = 42,
COAP_CONTENTTYPE_APPLICATION_EXI = 47,
COAP_CONTENTTYPE_APPLICATION_JSON = 50,
} coap_content_type_t;

///////////////////////
Expand Down Expand Up @@ -156,6 +160,7 @@ struct coap_luser_entry{
// char name[MAX_SEGMENTS_SIZE+1]; // +1 for string '\0'
const char *name;
coap_luser_entry *next;
int content_type;
};

struct coap_endpoint_t{
Expand Down
10 changes: 5 additions & 5 deletions app/coap/endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ static int handle_get_variable(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
{
n = lua_gettop(h->L);
lua_getglobal(h->L, h->name);
if (!lua_isnumber(h->L, -1)) {
NODE_DBG ("should be a number.\n");
if (!lua_isnumber(h->L, -1) && !lua_isstring(h->L, -1)) {
NODE_DBG ("should be a number or string.\n");
lua_settop(h->L, n);
return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_NOT_FOUND, COAP_CONTENTTYPE_NONE);
} else {
const char *res = lua_tostring(h->L,-1);
lua_settop(h->L, n);
return coap_make_response(scratch, outpkt, (const uint8_t *)res, c_strlen(res), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
return coap_make_response(scratch, outpkt, (const uint8_t *)res, c_strlen(res), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, h->content_type);
}
}
} else {
Expand Down Expand Up @@ -198,10 +198,10 @@ static int handle_get_id(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, c
return coap_make_response(scratch, outpkt, (const uint8_t *)(&id), sizeof(uint32_t), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
}

coap_luser_entry var_head = {NULL,NULL,NULL};
coap_luser_entry var_head = {NULL,NULL,NULL,0};
coap_luser_entry *variable_entry = &var_head;

coap_luser_entry func_head = {NULL,NULL,NULL};
coap_luser_entry func_head = {NULL,NULL,NULL,0};
coap_luser_entry *function_entry = &func_head;

const coap_endpoint_t endpoints[] =
Expand Down
11 changes: 8 additions & 3 deletions app/driver/onewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,15 @@ uint8_t onewire_search(uint8_t pin, uint8_t *newAddr)
LastFamilyDiscrepancy[pin] = 0;
search_result = FALSE;
}
int i;
for (i = 0; i < 8; i++) newAddr[i] = ROM_NO[pin][i];
else
{
for (rom_byte_number = 0; rom_byte_number < 8; rom_byte_number++)
{
newAddr[rom_byte_number] = ROM_NO[pin][rom_byte_number];
}
}
return search_result;
}
}

#endif

Expand Down
37 changes: 37 additions & 0 deletions app/driver/uart.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#ifndef FUNC_U0RXD
#define FUNC_U0RXD 0
#endif
#ifndef FUNC_U0CTS
#define FUNC_U0CTS 4
#endif


// For event signalling
static uint8 task = USER_TASK_PRIO_MAX;
Expand Down Expand Up @@ -75,6 +79,39 @@ uart_config(uint8 uart_no)
SET_PERI_REG_MASK(UART_INT_ENA(uart_no), UART_RXFIFO_FULL_INT_ENA);
}



/******************************************************************************
* FunctionName : uart0_alt
* Description : Internal used function
* UART0 pins changed to 13,15 if 'on' is set, else set to normal pins
* Parameters : on - 1 = use alternate pins, 0 = use normal pins
* Returns : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
uart0_alt(uint8 on)
{
if (on)
{
PIN_PULLUP_DIS(PERIPHS_IO_MUX_MTDO_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS);
PIN_PULLUP_EN(PERIPHS_IO_MUX_MTCK_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_U0CTS);
// now make RTS/CTS behave as TX/RX
IOSWAP |= (1 << IOSWAPU0);
}
else
{
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
PIN_PULLUP_EN(PERIPHS_IO_MUX_U0RXD_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD);
// now make RX/TX behave as TX/RX
IOSWAP &= ~(1 << IOSWAPU0);
}
}


/******************************************************************************
* FunctionName : uart_tx_one_char
* Description : Internal used function
Expand Down
1 change: 1 addition & 0 deletions app/include/driver/uart.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ typedef struct {
} UartDevice;

void uart_init(UartBautRate uart0_br, UartBautRate uart1_br, uint8 task_prio, os_signal_t sig_input);
void uart0_alt(uint8 on);
void uart0_sendStr(const char *str);
void uart0_putc(const char c);
void uart0_tx_buffer(uint8 *buf, uint16 len);
Expand Down
13 changes: 13 additions & 0 deletions app/include/driver/uart_register.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,17 @@

#define UART_DATE( i ) (REG_UART_BASE( i ) + 0x78)
#define UART_ID( i ) (REG_UART_BASE( i ) + 0x7C)

#define ESP8266_DREG(addr) *((volatile uint32_t *)(0x3FF00000+(addr)))

//IO SWAP Register
#define IOSWAP ESP8266_DREG(0x28)
#define IOSWAPU 0 //Swaps UART
#define IOSWAPS 1 //Swaps SPI
#define IOSWAPU0 2 //Swaps UART 0 pins (u0rxd <-> u0cts), (u0txd <-> u0rts)
#define IOSWAPU1 3 //Swaps UART 1 pins (u1rxd <-> u1cts), (u1txd <-> u1rts)
#define IOSWAPHS 5 //Sets HSPI with higher prio
#define IOSWAP2HS 6 //Sets Two SPI Masters on HSPI
#define IOSWAP2CS 7 //Sets Two SPI Masters on CSPI

#endif // UART_REGISTER_H_INCLUDED
10 changes: 7 additions & 3 deletions app/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
// #define FLASH_16M
#define FLASH_AUTOSIZE
#define FLASH_SAFE_API
// #define DEVELOP_VERSION
#define FULL_VERSION_FOR_USER

#define USE_OPTIMIZE_PRINTF
// Byte 107 of esp_init_data_default, only one of these 3 can be picked
#define ESP_INIT_DATA_ENABLE_READVDD33
//#define ESP_INIT_DATA_ENABLE_READADC
//#define ESP_INIT_DATA_FIXED_VDD33_VALUE 33

// #define DEVELOP_VERSION
#ifdef DEVELOP_VERSION
#define NODE_DEBUG
#define COAP_DEBUG
Expand Down Expand Up @@ -62,8 +64,10 @@
#define LUA_OPTIMIZE_MEMORY 0
#endif /* LUA_OPTRAM */

#define READLINE_INTERVAL 80
#define LUA_TASK_PRIO USER_TASK_PRIO_0
#define LUA_PROCESS_LINE_SIG 2
#define LUA_OPTIMIZE_DEBUG 2

#ifdef DEVKIT_VERSION_0_9
#define KEYLED_INTERVAL 80
Expand Down
44 changes: 22 additions & 22 deletions app/include/user_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@
#define LUA_USE_MODULES

#ifdef LUA_USE_MODULES
#define LUA_USE_MODULES_NODE
#define LUA_USE_MODULES_FILE
#define LUA_USE_MODULES_GPIO
#define LUA_USE_MODULES_WIFI
#define LUA_USE_MODULES_NET
#define LUA_USE_MODULES_PWM
#define LUA_USE_MODULES_I2C
#define LUA_USE_MODULES_SPI
#define LUA_USE_MODULES_TMR
#define LUA_USE_MODULES_ADC
#define LUA_USE_MODULES_UART
#define LUA_USE_MODULES_OW
#define LUA_USE_MODULES_BIT
#define LUA_USE_MODULES_MQTT
#define LUA_USE_MODULES_COAP
//#define LUA_USE_MODULES_ENDUSER_SETUP // USE_DNS in dhcpserver.h needs to be enabled for this module to work.
#define LUA_USE_MODULES_U8G
//#define LUA_USE_MODULES_UCG
// #define LUA_USE_MODULES_WS2801
#define LUA_USE_MODULES_WS2812
//#define LUA_USE_MODULES_BMP085
#define LUA_USE_MODULES_CJSON
#define LUA_USE_MODULES_COAP
#define LUA_USE_MODULES_CRYPTO
#define LUA_USE_MODULES_RC
#define LUA_USE_MODULES_DHT
//#define LUA_USE_MODULES_ENDUSER_SETUP // USE_DNS in dhcpserver.h needs to be enabled for this module to work.
#define LUA_USE_MODULES_FILE
#define LUA_USE_MODULES_GPIO
//#define LUA_USE_MODULES_HX711
#define LUA_USE_MODULES_I2C
#define LUA_USE_MODULES_MQTT
#define LUA_USE_MODULES_NET
#define LUA_USE_MODULES_NODE
#define LUA_USE_MODULES_OW
#define LUA_USE_MODULES_PWM
#define LUA_USE_MODULES_RC
#define LUA_USE_MODULES_RTCFIFO
#define LUA_USE_MODULES_RTCMEM
#define LUA_USE_MODULES_RTCTIME
#define LUA_USE_MODULES_RTCFIFO
#define LUA_USE_MODULES_SNTP
//#define LUA_USE_MODULES_BMP085
#define LUA_USE_MODULES_SPI
#define LUA_USE_MODULES_TMR
#define LUA_USE_MODULES_TSL2561
//#define LUA_USE_MODULES_HX711
#define LUA_USE_MODULES_U8G
#define LUA_USE_MODULES_UART
//#define LUA_USE_MODULES_UCG
#define LUA_USE_MODULES_WIFI
//#define LUA_USE_MODULES_WS2801
#define LUA_USE_MODULES_WS2812

#endif /* LUA_USE_MODULES */
#endif
Expand Down
Loading

0 comments on commit 25af2b9

Please sign in to comment.