Commit f51b4725 authored by HuangRui's avatar HuangRui
Browse files
parents 6986d9e5 7c820b4e
......@@ -27,8 +27,8 @@ Tencent QQ group: 309957875<br />
- fix wifi smart connect
- add spi module (done)
- add mqtt module (done)
- add coap module
- cross compiler
- add coap module (in coap branch)
- cross compiler (done)
# Change log
2015-02-13<br />
......
......@@ -3,11 +3,11 @@
#define NODE_VERSION_MAJOR 0U
#define NODE_VERSION_MINOR 9U
#define NODE_VERSION_REVISION 5U
#define NODE_VERSION_REVISION 6U
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 0.9.5"
#define BUILD_DATE "build 20150213"
#define NODE_VERSION "NodeMCU 0.9.6"
#define BUILD_DATE "build 20150216"
// #define DEVKIT_VERSION_0_9 1 // define this only if you use NodeMCU devkit v0.9
......@@ -77,8 +77,6 @@
#endif /* LUA_USE_DEVICE_DRIVER */
// #define LUA_NUMBER_INTEGRAL
#define LUA_OPTRAM
#ifdef LUA_OPTRAM
#define LUA_OPTIMIZE_MEMORY 2
......
......@@ -692,6 +692,8 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
lf.f = fs_open(filename, FS_RDONLY);
if (lf.f < FS_OPEN_OK) return errfsfile(L, "open", fnameindex);
}
// if(fs_size(lf.f)>LUAL_BUFFERSIZE)
// return luaL_error(L, "file is too big");
c = fs_getc(lf.f);
if (c == '#') { /* Unix exec. file? */
lf.extraline = 1;
......
......@@ -542,7 +542,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
*/
#define LUAL_BUFFERSIZE (BUFSIZ*4)
#define LUAL_BUFFERSIZE ((BUFSIZ)*4)
/* }================================================================== */
......
/******************************************************************************
* FunctionName : espconn_init
* Description : dummy the espconn_init
* Parameters : none
* Returns : none
*******************************************************************************/
void espconn_init()
{
// dummy function, do nothing.
}
......@@ -1241,6 +1241,31 @@ static int net_socket_unhold( lua_State* L )
return 0;
}
// Lua: ip,port = sk:getpeer()
static int net_socket_getpeer( lua_State* L )
{
lnet_userdata *nud;
const char *mt = "net.socket";
nud = (lnet_userdata *)luaL_checkudata(L, 1, mt);
luaL_argcheck(L, nud, 1, "Server/Socket expected");
if(nud!=NULL && nud->pesp_conn!=NULL ){
char temp[20] = {0};
c_sprintf(temp, IPSTR, IP2STR( &(nud->pesp_conn->proto.tcp->remote_ip) ) );
if ( nud->pesp_conn->proto.tcp->remote_port != 0 ) {
lua_pushstring( L, temp );
lua_pushinteger( L, nud->pesp_conn->proto.tcp->remote_port );
} else {
lua_pushnil( L );
lua_pushnil( L );
}
} else {
lua_pushnil( L );
lua_pushnil( L );
}
return 2;
}
// Lua: socket:dns( string, function(ip) )
static int net_socket_dns( lua_State* L )
{
......@@ -1302,6 +1327,7 @@ static const LUA_REG_TYPE net_socket_map[] =
{ LSTRKEY( "hold" ), LFUNCVAL ( net_socket_hold ) },
{ LSTRKEY( "unhold" ), LFUNCVAL ( net_socket_unhold ) },
{ LSTRKEY( "dns" ), LFUNCVAL ( net_socket_dns ) },
{ LSTRKEY( "getpeer" ), LFUNCVAL ( net_socket_getpeer ) },
// { LSTRKEY( "delete" ), LFUNCVAL ( net_socket_delete ) },
{ LSTRKEY( "__gc" ), LFUNCVAL ( net_socket_delete ) },
#if LUA_OPTIMIZE_MEMORY > 0
......
......@@ -95,6 +95,7 @@ static int node_chipid( lua_State* L )
// Lua: readvdd33()
static int node_readvdd33( lua_State* L )
{
// uint32_t vdd33 = system_get_vdd33();
uint32_t vdd33 = readvdd33();
lua_pushinteger(L, vdd33);
return 1;
......
......@@ -24,6 +24,7 @@ SPIFlashInfo flash_get_info(void)
{
volatile SPIFlashInfo spi_flash_info ICACHE_STORE_ATTR;
spi_flash_info = *((SPIFlashInfo *)(FLASH_MAP_START_ADDRESS));
// spi_flash_read(0, (uint32 *)(& spi_flash_info), sizeof(spi_flash_info));
return spi_flash_info;
}
......@@ -56,9 +57,11 @@ uint32_t flash_get_size_byte(void)
case SIZE_32MBIT:
// 32Mbit, 4MByte
flash_size = 4 * 1024 * 1024;
break;
case SIZE_64MBIT:
// 64Mbit, 8MByte
flash_size = 8 * 1024 * 1024;
break;
case SIZE_128MBIT:
// 128Mbit, 16MByte
flash_size = 16 * 1024 * 1024;
......@@ -131,7 +134,15 @@ bool flash_set_size_byte(uint32_t size)
uint16_t flash_get_sec_num(void)
{
return flash_get_size_byte() / SPI_FLASH_SEC_SIZE;
//static uint16_t sec_num = 0;
// return flash_get_size_byte() / (SPI_FLASH_SEC_SIZE);
// c_printf("\nflash_get_size_byte()=%d\n", ( flash_get_size_byte() / (SPI_FLASH_SEC_SIZE) ));
// if( sec_num == 0 )
//{
// sec_num = 4 * 1024 * 1024 / (SPI_FLASH_SEC_SIZE);
//}
//return sec_num;
return ( flash_get_size_byte() / (SPI_FLASH_SEC_SIZE) );
}
uint8_t flash_get_mode(void)
......@@ -232,13 +243,14 @@ bool flash_self_destruct(void)
return true;
}
uint8_t byte_of_aligned_array(const uint8_t* aligned_array, uint32_t index)
uint8_t byte_of_aligned_array(const uint8_t *aligned_array, uint32_t index)
{
if( (((uint32_t)aligned_array)%4) != 0 ){
if ( (((uint32_t)aligned_array) % 4) != 0 )
{
NODE_DBG("aligned_array is not 4-byte aligned.\n");
return 0;
}
uint32_t v = ((uint32_t *)aligned_array)[ index/4 ];
uint32_t v = ((uint32_t *)aligned_array)[ index / 4 ];
uint8_t *p = (uint8_t *) (&v);
return p[ (index%4) ];
return p[ (index % 4) ];
}
......@@ -3,6 +3,7 @@
#include "ets_sys.h"
#include "user_config.h"
#include "cpu_esp8266.h"
#define FLASH_MAP_START_ADDRESS (INTERNAL_FLASH_START_ADDRESS)
/******************************************************************************
......@@ -29,8 +30,8 @@
typedef struct
{
uint8_t unknown0;
uint8_t unknown1;
uint8_t e9;
uint8_t segments;
enum
{
MODE_QIO = 0,
......
......@@ -69,6 +69,7 @@
#define fs_format myspiffs_format
#define fs_check myspiffs_check
#define fs_rename myspiffs_rename
#define fs_size myspiffs_size
#define FS_NAME_MAX_LENGTH SPIFFS_OBJ_NAME_LEN
......
......@@ -165,6 +165,9 @@ void myspiffs_clearerr( int fd ){
int myspiffs_rename( const char *old, const char *newname ){
return SPIFFS_rename(&fs, (char *)old, (char *)newname);
}
size_t myspiffs_size( int fd ){
return SPIFFS_size(&fs, (spiffs_file)fd);
}
#if 0
void test_spiffs() {
char buf[12];
......
......@@ -423,6 +423,7 @@ s32_t SPIFFS_check(spiffs *fs);
*/
s32_t SPIFFS_eof(spiffs *fs, spiffs_file fh);
s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh);
s32_t SPIFFS_size(spiffs *fs, spiffs_file fh);
#if SPIFFS_TEST_VISUALISATION
/**
......@@ -465,5 +466,6 @@ int myspiffs_error( int fd );
void myspiffs_clearerr( int fd );
int myspiffs_check( void );
int myspiffs_rename( const char *old, const char *newname );
size_t myspiffs_size( int fd );
#endif /* SPIFFS_H_ */
......@@ -798,6 +798,25 @@ s32_t SPIFFS_tell(spiffs *fs, spiffs_file fh) {
return res;
}
s32_t SPIFFS_size(spiffs *fs, spiffs_file fh) {
SPIFFS_API_CHECK_MOUNT(fs);
SPIFFS_LOCK(fs);
spiffs_fd *fd;
s32_t res;
res = spiffs_fd_get(fs, fh, &fd);
SPIFFS_API_CHECK_RES(fs, res);
#if SPIFFS_CACHE_WR
spiffs_fflush_cache(fs, fh);
#endif
res = fd->size;
SPIFFS_UNLOCK(fs);
return res;
}
#if SPIFFS_TEST_VISUALISATION
s32_t SPIFFS_vis(spiffs *fs) {
s32_t res = SPIFFS_OK;
......
This diff is collapsed.
......@@ -89,6 +89,7 @@ bool system_rtc_mem_write(uint8 des_addr, const void *src_addr, uint16 save_size
void system_uart_swap(void);
uint16 system_adc_read(void);
uint16 system_get_vdd33(void);
const char *system_get_sdk_version(void);
......
......@@ -71,7 +71,6 @@ SECTIONS
_irom0_text_start = ABSOLUTE(.);
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
*(.literal.* .text.*)
*(.rodata2.text)
_irom0_text_end = ABSOLUTE(.);
_flash_used_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment