Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
2859286e
Commit
2859286e
authored
Apr 03, 2015
by
HuangRui
Browse files
Merge branch 'dev' of
https://github.com/nodemcu/nodemcu-firmware
parents
fc3ad901
1c2ee75a
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
README.md
View file @
2859286e
...
...
@@ -36,6 +36,12 @@ Tencent QQ group: 309957875<br />
-
cross compiler (done)
# Change log
2015-03-31
<br
/>
polish mqtt module, add queue for mqtt module.
<br
/>
add reconnect option to mqtt.connect api, :connect( host, port, secure, auto_reconnect, function(client) )
<br
/>
move node.readvdd33 to adc.readvdd33.
<br
/>
tools/esptool.py supported NodeMCU devkit automatic flash.
2015-03-18
<br
/>
update u8glib.
<br
/>
merge everything to master.
...
...
@@ -237,7 +243,7 @@ m:subscribe("/topic",0, function(conn) print("subscribe success") end)
-- publish a message with data = hello, QoS = 0, retain = 0
m
:
publish
(
"/topic"
,
"hello"
,
0
,
0
,
function
(
conn
)
print
(
"sent"
)
end
)
m
:
close
();
-- if auto-reconnect = 1, will
reconnec
t.
m
:
close
();
-- if auto-reconnect =
=
1, will
disable auto-reconnect and then disconnect from hos
t.
-- you can call m:connect again
```
...
...
app/include/user_version.h
View file @
2859286e
...
...
@@ -7,6 +7,6 @@
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMCU 0.9.5"
#define BUILD_DATE "build 20150
331
"
#define BUILD_DATE "build 20150
403
"
#endif
/* __USER_VERSION_H__ */
app/modules/mqtt.c
View file @
2859286e
This diff is collapsed.
Click to expand it.
app/mqtt/msg_queue.c
View file @
2859286e
...
...
@@ -58,3 +58,25 @@ msg_queue_t * msg_dequeue(msg_queue_t **head){
node
->
next
=
NULL
;
return
node
;
}
msg_queue_t
*
msg_peek
(
msg_queue_t
**
head
){
if
(
!
head
||
!*
head
){
return
NULL
;
}
return
*
head
;
// fetch head.
}
int
msg_size
(
msg_queue_t
**
head
){
if
(
!
head
||
!*
head
){
return
0
;
}
int
i
=
1
;
msg_queue_t
*
tail
=
*
head
;
if
(
tail
){
while
(
tail
->
next
!=
NULL
){
tail
=
tail
->
next
;
i
++
;
}
}
return
i
;
}
app/mqtt/msg_queue.h
View file @
2859286e
...
...
@@ -18,6 +18,8 @@ typedef struct msg_queue_t {
msg_queue_t
*
msg_enqueue
(
msg_queue_t
**
head
,
mqtt_message_t
*
msg
,
uint16_t
msg_id
,
int
msg_type
,
int
publish_qos
);
void
msg_destroy
(
msg_queue_t
*
node
);
msg_queue_t
*
msg_dequeue
(
msg_queue_t
**
head
);
msg_queue_t
*
msg_peek
(
msg_queue_t
**
head
);
int
msg_size
(
msg_queue_t
**
head
);
#ifdef __cplusplus
}
...
...
app/platform/flash_fs.h
View file @
2859286e
...
...
@@ -71,6 +71,9 @@
#define fs_rename myspiffs_rename
#define fs_size myspiffs_size
#define fs_mount myspiffs_mount
#define fs_unmount myspiffs_unmount
#define FS_NAME_MAX_LENGTH SPIFFS_OBJ_NAME_LEN
#endif
...
...
app/spiffs/spiffs.c
View file @
2859286e
...
...
@@ -42,7 +42,7 @@ The small 4KB sectors allow for greater flexibility in applications th
********************/
void
spiffs_mount
()
{
void
my
spiffs_mount
()
{
spiffs_config
cfg
;
cfg
.
phys_addr
=
(
u32_t
)
platform_flash_get_first_free_block_address
(
NULL
);
cfg
.
phys_addr
+=
0x3000
;
...
...
@@ -69,6 +69,10 @@ void spiffs_mount() {
NODE_DBG
(
"mount res: %i
\n
"
,
res
);
}
void
myspiffs_unmount
()
{
SPIFFS_unmount
(
&
fs
);
}
// FS formatting function
// Returns 1 if OK, 0 for error
int
myspiffs_format
(
void
)
...
...
@@ -85,7 +89,7 @@ int myspiffs_format( void )
while
(
sect_first
<=
sect_last
)
if
(
platform_flash_erase_sector
(
sect_first
++
)
==
PLATFORM_ERR
)
return
0
;
spiffs_mount
();
my
spiffs_mount
();
return
1
;
}
...
...
app/spiffs/spiffs.h
View file @
2859286e
...
...
@@ -477,6 +477,8 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages);
#if SPIFFS_CACHE
#endif
void
myspiffs_mount
();
void
myspiffs_unmount
();
int
myspiffs_open
(
const
char
*
name
,
int
flags
);
int
myspiffs_close
(
int
fd
);
size_t
myspiffs_write
(
int
fd
,
const
void
*
ptr
,
size_t
len
);
...
...
app/user/Makefile
View file @
2859286e
...
...
@@ -44,6 +44,7 @@ INCLUDES += -I ../libc
INCLUDES
+=
-I
../platform
INCLUDES
+=
-I
../lua
INCLUDES
+=
-I
../wofs
INCLUDES
+=
-I
../spiffs
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
app/user/user_main.c
View file @
2859286e
...
...
@@ -14,8 +14,7 @@
#include "c_stdlib.h"
#include "c_stdio.h"
#include "romfs.h"
#include "flash_fs.h"
#include "user_interface.h"
#include "ets_sys.h"
...
...
@@ -44,7 +43,6 @@ void task_init(void){
system_os_task
(
task_lua
,
USER_TASK_PRIO_0
,
taskQueue
,
TASK_QUEUE_LEN
);
}
extern
void
spiffs_mount
();
// extern void test_spiffs();
// extern int test_romfs();
...
...
@@ -70,6 +68,15 @@ void nodemcu_init(void)
flash_init_data_default
();
// Flash blank data at FLASHSIZE - 0x02000 Byte.
flash_init_data_blank
();
if
(
!
fs_format
()
)
{
NODE_ERR
(
"
\n
i*** ERROR ***: unable to format. FS might be compromised.
\n
"
);
NODE_ERR
(
"It is advised to re-flash the NodeMCU image.
\n
"
);
}
else
{
NODE_ERR
(
"format done.
\n
"
);
}
fs_unmount
();
// mounted by format.
}
#endif // defined(FLASH_SAFE_API)
...
...
@@ -94,7 +101,7 @@ void nodemcu_init(void)
// test_romfs();
#elif defined ( BUILD_SPIFFS )
spif
fs_mount
();
fs_mount
();
// test_spiffs();
#endif
// endpoint_setup();
...
...
examples/fragment.lua
View file @
2859286e
...
...
@@ -418,7 +418,7 @@ m:publish("/topic1","hello",0,0)
m
:
publish
(
"/topic3"
,
"hello"
,
0
,
0
)
m
:
publish
(
"/topic4"
,
"hello"
,
0
,
0
)
m
:
publish
(
"/topic1"
,
"hello1"
,
0
,
0
)
m
:
publish
(
"/topic2"
,
"hello2"
,
0
,
0
)
m
:
publish
(
"/topic1"
,
"hello"
,
1
,
0
)
m
:
subscribe
(
"/topic3"
,
2
,
function
(
m
)
print
(
"sub done"
)
end
)
m
:
subscribe
(
"/topic3"
,
0
,
function
(
m
)
print
(
"sub done"
)
end
)
m
:
publish
(
"/topic3"
,
"hello3"
,
2
,
0
)
m
=
mqtt
.
Client
()
...
...
@@ -450,3 +450,25 @@ end)
m
:
connect
(
"192.168.18.88"
,
1883
)
m
:
close
()
m
=
mqtt
.
Client
()
m
:
connect
(
"192.168.18.88"
,
1883
)
m
:
on
(
"message"
,
function
(
m
,
t
,
pl
)
print
(
t
..
":"
)
if
pl
~=
nil
then
print
(
pl
)
end
end
)
m
:
subscribe
(
"/topic1"
,
0
,
function
(
m
)
print
(
"sub done"
)
end
)
m
:
publish
(
"/topic1"
,
"hello3"
,
2
,
0
)
m
:
publish
(
"/topic1"
,
"hello2"
,
2
,
0
)
m
:
publish
(
"/topic1"
,
"hello3"
,
0
,
0
)
m
:
publish
(
"/topic1"
,
"hello2"
,
2
,
0
)
m
:
subscribe
(
"/topic2"
,
2
,
function
(
m
)
print
(
"sub done"
)
end
)
m
:
publish
(
"/topic2"
,
"hello3"
,
0
,
0
)
m
:
publish
(
"/topic2"
,
"hello2"
,
2
,
0
)
m
=
mqtt
.
Client
()
m
:
on
(
"connect"
,
function
(
m
)
print
(
"connection "
..
node
.
heap
())
m
:
subscribe
(
"/topic1"
,
0
,
function
(
m
)
print
(
"sub done"
)
end
)
m
:
publish
(
"/topic1"
,
"hello3"
,
0
,
0
)
m
:
publish
(
"/topic1"
,
"hello2"
,
2
,
0
)
end
)
m
:
on
(
"offline"
,
function
(
conn
)
print
(
"disconnect to broker..."
)
print
(
node
.
heap
())
end
)
m
:
connect
(
"192.168.18.88"
,
1883
,
0
,
1
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment