Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
310faf7f
Unverified
Commit
310faf7f
authored
Sep 07, 2019
by
Terry Ellison
Committed by
GitHub
Sep 07, 2019
Browse files
Merge pull request #2886 from nodemcu/dev
Next master drop
parents
68c425c0
a08e74d9
Changes
368
Hide whitespace changes
Inline
Side-by-side
app/platform/hw_timer.h
View file @
310faf7f
...
...
@@ -30,5 +30,13 @@ bool ICACHE_RAM_ATTR platform_hw_timer_close(os_param_t owner);
uint32_t
ICACHE_RAM_ATTR
platform_hw_timer_get_delay_ticks
(
os_param_t
owner
);
bool
platform_hw_timer_init_exclusive
(
FRC1_TIMER_SOURCE_TYPE
source_type
,
bool
autoload
,
void
(
*
frc1_timer_cb
)(
os_param_t
),
os_param_t
arg
,
void
(
*
nmi_timer_cb
)(
void
)
);
bool
ICACHE_RAM_ATTR
platform_hw_timer_close_exclusive
();
bool
ICACHE_RAM_ATTR
platform_hw_timer_arm_ticks_exclusive
(
uint32_t
ticks
);
bool
ICACHE_RAM_ATTR
platform_hw_timer_arm_us_exclusive
(
uint32_t
microseconds
);
#endif
app/platform/pin_map.h
View file @
310faf7f
...
...
@@ -2,7 +2,7 @@
#ifndef __PIN_MAP_H__
#define __PIN_MAP_H__
#include
"c_types
.h
"
#include
<stdint
.h
>
#include "user_config.h"
#include "gpio.h"
...
...
app/platform/platform.c
View file @
310faf7f
...
...
@@ -2,9 +2,9 @@
#include "platform.h"
#include "common.h"
#include
"c_
stdio.h
"
#include
"c_
string.h
"
#include
"c_
stdlib.h
"
#include
<
stdio.h
>
#include
<
string.h
>
#include
<
stdlib.h
>
#include "llimits.h"
#include "gpio.h"
#include "user_interface.h"
...
...
@@ -320,7 +320,7 @@ int platform_gpio_register_intr_hook(uint32_t bits, platform_hook_function hook)
}
// These return NULL if the count = 0 so only error check if > 0)
nh
.
entry
=
c_
malloc
(
nh
.
count
*
sizeof
(
*
(
nh
.
entry
))
);
nh
.
entry
=
malloc
(
nh
.
count
*
sizeof
(
*
(
nh
.
entry
))
);
if
(
nh
.
count
&&
!
(
nh
.
entry
))
{
return
0
;
// Allocation failure
}
...
...
@@ -345,7 +345,7 @@ int platform_gpio_register_intr_hook(uint32_t bits, platform_hook_function hook)
platform_gpio_hook
=
nh
;
ETS_GPIO_INTR_ENABLE
();
c_
free
(
oh
.
entry
);
free
(
oh
.
entry
);
return
1
;
}
#endif // GPIO_INTERRUPT_HOOK_ENABLE
...
...
@@ -735,16 +735,19 @@ uint32_t platform_i2c_setup( unsigned id, uint8_t sda, uint8_t scl, uint32_t spe
platform_gpio_mode
(
sda
,
PLATFORM_GPIO_INPUT
,
PLATFORM_GPIO_PULLUP
);
// inside this func call platform_pwm_close
platform_gpio_mode
(
scl
,
PLATFORM_GPIO_INPUT
,
PLATFORM_GPIO_PULLUP
);
// disable gpio interrupt first
i2c_master_gpio_init
(
sda
,
scl
);
return
PLATFORM_I2C_SPEED_SLOW
;
return
i2c_master_setup
(
id
,
sda
,
scl
,
speed
);
}
bool
platform_i2c_configured
(
unsigned
id
){
return
i2c_master_configured
(
id
);
}
void
platform_i2c_send_start
(
unsigned
id
){
i2c_master_start
();
i2c_master_start
(
id
);
}
void
platform_i2c_send_stop
(
unsigned
id
){
i2c_master_stop
();
i2c_master_stop
(
id
);
}
int
platform_i2c_send_address
(
unsigned
id
,
uint16_t
address
,
int
direction
){
...
...
@@ -754,22 +757,17 @@ int platform_i2c_send_address( unsigned id, uint16_t address, int direction ){
PLATFORM_I2C_DIRECTION_RECEIVER
==
1
)
)
{
direction
=
(
direction
==
PLATFORM_I2C_DIRECTION_TRANSMITTER
)
?
0
:
1
;
}
i2c_master_writeByte
(
(
uint8_t
)
((
address
<<
1
)
|
direction
));
// Low-level returns nack (0=acked); we return ack (1=acked).
return
!
i2c_master_getAck
();
return
i2c_master_writeByte
(
id
,
(
uint8_t
)
((
address
<<
1
)
+
(
direction
==
PLATFORM_I2C_DIRECTION_TRANSMITTER
?
0
:
1
))
);
}
int
platform_i2c_send_byte
(
unsigned
id
,
uint8_t
data
){
i2c_master_writeByte
(
data
);
// Low-level returns nack (0=acked); we return ack (1=acked).
return
!
i2c_master_getAck
();
int
platform_i2c_send_byte
(
unsigned
id
,
uint8_t
data
){
return
i2c_master_writeByte
(
id
,
data
);
}
int
platform_i2c_recv_byte
(
unsigned
id
,
int
ack
){
uint8_t
r
=
i2c_master_readByte
();
i2c_master_setAck
(
!
ack
);
return
r
;
return
i2c_master_readByte
(
id
,
ack
);
}
// *****************************************************************************
...
...
@@ -867,15 +865,15 @@ uint32_t platform_s_flash_write( const void *from, uint32_t toaddr, uint32_t siz
uint32_t
*
apbuf
=
NULL
;
uint32_t
fromaddr
=
(
uint32_t
)
from
;
if
(
(
fromaddr
&
blkmask
)
||
(
fromaddr
>=
INTERNAL_FLASH_MAPPED_ADDRESS
))
{
apbuf
=
(
uint32_t
*
)
c_
malloc
(
size
);
apbuf
=
(
uint32_t
*
)
malloc
(
size
);
if
(
!
apbuf
)
return
0
;
c_
memcpy
(
apbuf
,
from
,
size
);
memcpy
(
apbuf
,
from
,
size
);
}
system_soft_wdt_feed
();
r
=
flash_write
(
toaddr
,
apbuf
?
(
uint32
*
)
apbuf
:
(
uint32
*
)
from
,
size
);
if
(
apbuf
)
c_
free
(
apbuf
);
free
(
apbuf
);
if
(
SPI_FLASH_RESULT_OK
==
r
)
return
size
;
else
{
...
...
@@ -905,10 +903,10 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
r
=
flash_read
(
fromaddr
,
to2
,
size2
);
if
(
SPI_FLASH_RESULT_OK
==
r
)
{
os_
memmove
(
to
,
to2
,
size2
);
memmove
(
to
,
to2
,
size2
);
// This is overlapped so must be memmove and not memcpy
char
back
[
INTERNAL_FLASH_READ_UNIT_SIZE
]
__attribute__
((
aligned
(
INTERNAL_FLASH_READ_UNIT_SIZE
)));
r
=
flash_read
(
fromaddr
+
size2
,(
uint32
*
)
back
,
INTERNAL_FLASH_READ_UNIT_SIZE
);
os_
memcpy
((
uint8_t
*
)
to
+
size2
,
back
,
INTERNAL_FLASH_READ_UNIT_SIZE
);
memcpy
((
uint8_t
*
)
to
+
size2
,
back
,
INTERNAL_FLASH_READ_UNIT_SIZE
);
}
}
else
...
...
@@ -925,7 +923,6 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
int
platform_flash_erase_sector
(
uint32_t
sector_id
)
{
NODE_DBG
(
"flash_erase_sector(%u)
\n
"
,
sector_id
);
system_soft_wdt_feed
();
return
flash_erase
(
sector_id
)
==
SPI_FLASH_RESULT_OK
?
PLATFORM_OK
:
PLATFORM_ERR
;
}
...
...
@@ -938,7 +935,7 @@ static uint32_t flash_map_meg_offset (void) {
return
m0
+
m1
;
}
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
)
{
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
)
{
uint32_t
meg
=
flash_map_meg_offset
();
return
(
meg
&
1
)
?
-
1
:
mapped_addr
-
INTERNAL_FLASH_MAPPED_ADDRESS
+
meg
;
}
...
...
@@ -948,7 +945,137 @@ uint32_t platform_flash_phys2mapped (uint32_t phys_addr) {
return
(
meg
&
1
)
?
-
1
:
phys_addr
+
INTERNAL_FLASH_MAPPED_ADDRESS
-
meg
;
}
uint32_t
platform_flash_get_partition
(
uint32_t
part_id
,
uint32_t
*
addr
)
{
partition_item_t
pt
=
{
0
,
0
,
0
};
system_partition_get_item
(
SYSTEM_PARTITION_CUSTOMER_BEGIN
+
part_id
,
&
pt
);
if
(
addr
)
{
*
addr
=
pt
.
addr
;
}
return
pt
.
type
==
0
?
0
:
pt
.
size
;
}
/*
* The Reboot Config Records are stored in the 4K flash page at offset 0x10000 (in
* the linker section .irom0.ptable) and is used for configuration changes that
* persist across reboots. This page contains a sequence of records, each of which
* is word-aligned and comprises a header and body of length 0-64 words. The 4-byte
* header comprises a length, a RCR id, and two zero fill bytes. These are written
* using flash NAND writing rules, so any unused area (all 0xFF) can be overwritten
* by a new record without needing to erase the RCR page. Ditto any existing
* record can be marked as deleted by over-writing the header with the id set to
* PLATFORM_RCR_DELETED (0x0). Note that the last word is not used additions so a
* scan for PLATFORM_RCR_FREE will always terminate.
*
* The number of updates is extremely low, so it is unlikely (but possible) that
* the page might fill with the churn of new RCRs, so in this case the write function
* compacts the page by eliminating all deleted records. This does require a flash
* sector erase.
*
* NOTE THAT THIS ALGO ISN'T 100% ROBUST, eg. a powerfail between the erase and the
* wite-back will leave the page unitialised; ditto a powerfail between the record
* appned and old deletion will leave two records. However this is better than the
* general integrity of SPIFFS, for example and the vulnerable window is typically
* less than 1 mSec every configuration change.
*/
extern
uint32_t
_irom0_text_start
[];
#define RCR_WORD(i) (_irom0_text_start[i])
#define WORDSIZE sizeof(uint32_t)
#define FLASH_SECTOR_WORDS (INTERNAL_FLASH_SECTOR_SIZE/WORDSIZE)
uint32_t
platform_rcr_read
(
uint8_t
rec_id
,
void
**
rec
)
{
//DEBUG os_printf("platform_rcr_read(%d,%08x)\n",rec_id,rec);
platform_rcr_t
*
rcr
=
(
platform_rcr_t
*
)
&
RCR_WORD
(
0
);
uint32_t
i
=
0
;
/*
* Chain down the RCR page looking for a record that matches the record
* ID. If found return the size of the record and optionally its address.
*/
while
(
1
)
{
// copy RCR header into RAM to avoid unaligned exceptions
platform_rcr_t
r
=
(
platform_rcr_t
)
RCR_WORD
(
i
);
if
(
r
.
id
==
rec_id
)
{
if
(
rec
)
*
rec
=
&
RCR_WORD
(
i
+
1
);
return
r
.
len
*
WORDSIZE
;
}
else
if
(
r
.
id
==
PLATFORM_RCR_FREE
)
{
break
;
}
i
+=
1
+
r
.
len
;
}
return
~
0
;
}
/*
* Chain down the RCR page and look for an existing record that matches the record
* ID and the first free record. If there is enough room, then append the new
* record and mark any previous record as deleted. If the page is full then GC,
* erase the page and rewrite with the GCed content.
*/
#define MAXREC 65
uint32_t
platform_rcr_write
(
uint8_t
rec_id
,
const
void
*
inrec
,
uint8_t
n
)
{
uint32_t
nwords
=
(
n
+
WORDSIZE
-
1
)
/
WORDSIZE
;
uint32_t
reclen
=
(
nwords
+
1
)
*
WORDSIZE
;
uint32_t
*
prev
=
NULL
,
*
new
=
NULL
;
// make local stack copy of inrec including header and any trailing fill bytes
uint32_t
rec
[
MAXREC
];
if
(
nwords
>=
MAXREC
)
return
~
0
;
rec
[
0
]
=
0
;
rec
[
nwords
]
=
0
;
((
platform_rcr_t
*
)
rec
)
->
id
=
rec_id
;
((
platform_rcr_t
*
)
rec
)
->
len
=
nwords
;
memcpy
(
rec
+
1
,
inrec
,
n
);
// let memcpy handle 0 and odd byte cases
// find previous copy if any and exit if the replacement is the same value
uint8_t
np
=
platform_rcr_read
(
rec_id
,
(
void
**
)
&
prev
);
if
(
prev
&&
!
os_memcmp
(
prev
-
1
,
rec
,
reclen
))
return
n
;
// find next free slot
platform_rcr_read
(
PLATFORM_RCR_FREE
,
(
void
**
)
&
new
);
uint32_t
nfree
=
&
RCR_WORD
(
FLASH_SECTOR_WORDS
)
-
new
;
// Is there enough room to fit the rec in the RCR page?
if
(
nwords
<
nfree
)
{
// Note inequality needed to leave at least one all set word
uint32_t
addr
=
platform_flash_mapped2phys
((
uint32_t
)
&
new
[
-
1
]);
platform_s_flash_write
(
rec
,
addr
,
reclen
);
if
(
prev
)
{
// If a previous exists, then overwrite the hdr as DELETED
platform_rcr_t
rcr
=
{
0
};
addr
=
platform_flash_mapped2phys
((
uint32_t
)
&
prev
[
-
1
]);
rcr
.
id
=
PLATFORM_RCR_DELETED
;
rcr
.
len
=
np
/
WORDSIZE
;
platform_s_flash_write
(
&
rcr
,
addr
,
WORDSIZE
);
}
}
else
{
platform_rcr_t
*
rcr
=
(
platform_rcr_t
*
)
&
RCR_WORD
(
0
),
newrcr
=
{
0
};
uint32_t
flash_addr
=
platform_flash_mapped2phys
((
uint32_t
)
&
RCR_WORD
(
0
));
uint32_t
*
buf
,
i
,
l
,
pass
;
for
(
pass
=
1
;
pass
<=
2
;
pass
++
)
{
for
(
i
=
0
,
l
=
0
;
i
<
FLASH_SECTOR_WORDS
-
nfree
;
)
{
platform_rcr_t
r
=
rcr
[
i
];
// again avoid unaligned exceptions
if
(
r
.
id
==
PLATFORM_RCR_FREE
)
break
;
if
(
r
.
id
!=
PLATFORM_RCR_DELETED
&&
r
.
id
!=
rec_id
)
{
if
(
pass
==
2
)
memcpy
(
buf
+
l
,
rcr
+
i
,
(
r
.
len
+
1
)
*
WORDSIZE
);
l
+=
r
.
len
+
1
;
}
i
+=
r
.
len
+
1
;
}
if
(
pass
==
2
)
memcpy
(
buf
+
l
,
rec
,
reclen
);
l
+=
nwords
+
1
;
if
(
pass
==
1
)
buf
=
malloc
(
l
*
WORDSIZE
);
if
(
l
>=
FLASH_SECTOR_WORDS
||
!
buf
)
return
~
0
;
}
platform_flash_erase_sector
(
flash_addr
/
INTERNAL_FLASH_SECTOR_SIZE
);
platform_s_flash_write
(
buf
,
flash_addr
,
l
*
WORDSIZE
);
free
(
buf
);
}
return
nwords
*
WORDSIZE
;
}
void
*
platform_print_deprecation_note
(
const
char
*
msg
,
const
char
*
time_frame
)
{
c_
printf
(
"Warning, deprecated API! %s. It will be removed %s. See documentation for details.
\n
"
,
msg
,
time_frame
);
printf
(
"Warning, deprecated API! %s. It will be removed %s. See documentation for details.
\n
"
,
msg
,
time_frame
);
}
app/platform/platform.h
View file @
310faf7f
...
...
@@ -3,9 +3,9 @@
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#include <stdint.h>
#include "cpu_esp8266.h"
#include "c_types.h"
#include "driver/pwm.h"
#include "driver/uart.h"
#include "task/task.h"
...
...
@@ -235,7 +235,8 @@ void platform_sigma_delta_set_target( uint8_t target );
enum
{
PLATFORM_I2C_SPEED_SLOW
=
100000
,
PLATFORM_I2C_SPEED_FAST
=
400000
PLATFORM_I2C_SPEED_FAST
=
400000
,
PLATFORM_I2C_SPEED_FASTPLUS
=
1000000
};
// I2C direction
...
...
@@ -251,6 +252,7 @@ static inline int platform_i2c_exists( unsigned id ) { return id < NUM_I2C; }
static
inline
int
platform_i2c_exists
(
unsigned
id
)
{
return
0
;
}
#endif
uint32_t
platform_i2c_setup
(
unsigned
id
,
uint8_t
sda
,
uint8_t
scl
,
uint32_t
speed
);
bool
platform_i2c_configured
(
unsigned
id
);
void
platform_i2c_send_start
(
unsigned
id
);
void
platform_i2c_send_stop
(
unsigned
id
);
int
platform_i2c_send_address
(
unsigned
id
,
uint16_t
address
,
int
direction
);
...
...
@@ -287,13 +289,7 @@ int platform_flash_erase_sector( uint32_t sector_id );
*/
uint32_t
platform_flash_mapped2phys
(
uint32_t
mapped_addr
);
uint32_t
platform_flash_phys2mapped
(
uint32_t
phys_addr
);
// *****************************************************************************
// Allocator support
void
*
platform_get_first_free_ram
(
unsigned
id
);
void
*
platform_get_last_free_ram
(
unsigned
id
);
uint32_t
platform_flash_get_partition
(
uint32_t
part_id
,
uint32_t
*
addr
);
// *****************************************************************************
// Other glue
...
...
@@ -321,4 +317,40 @@ void* platform_print_deprecation_note( const char *msg, const char *time_frame);
if( !platform_ ## mod ## _check_ ## resmod ## _id( id, resid ) )\
return luaL_error( L, #resmod" %d not valid with " #mod " %d", ( unsigned )resid, ( unsigned )id )
// *****************************************************************************
// Reboot config page
/*
* The 4K flash page in the linker section .irom0.ptable (offset 0x10000) is used
* for configuration changes that persist across reboots. This 4k page contains a
* sequence of records that are written using flash NAND writing rules. See the
* header app/spiffs/spiffs_nucleus.h for a discussion of how SPIFFS uses these. A
* similar technique is used here.
*
* Each record is word aligned and the first two bytes of the record are its size
* and record type. Type 0xFF means unused and type 0x00 means deleted. New
* records can be added by overwriting the first unused slot. Records can be
* replaced by adding the new version, then setting the type of the previous version
* to deleted. This all works and can be implemented with platform_s_flash_write()
* upto the 4K limit.
*
* If a new record cannot fit into the page then the deleted records are GCed by
* copying the active records into a RAM scratch pad, erasing the page and writing
* them back. Yes, this is powerfail unsafe for a few mSec, but this is no worse
* than writing to SPIFFS and won't even occur in normal production use.
*/
#define IROM_PTABLE_ATTR __attribute__((section(".irom0.ptable")))
#define PLATFORM_PARTITION(n) (SYSTEM_PARTITION_CUSTOMER_BEGIN + n)
#define PLATFORM_RCR_DELETED 0x0
#define PLATFORM_RCR_PT 0x1
#define PLATFORM_RCR_PHY_DATA 0x2
#define PLATFORM_RCR_REFLASH 0x3
#define PLATFORM_RCR_FREE 0xFF
typedef
union
{
uint32_t
hdr
;
struct
{
uint8_t
len
,
id
;
};
}
platform_rcr_t
;
uint32_t
platform_rcr_read
(
uint8_t
rec_id
,
void
**
rec
);
uint32_t
platform_rcr_write
(
uint8_t
rec_id
,
const
void
*
rec
,
uint8_t
size
);
#endif
app/platform/sdcard.c
View file @
310faf7f
#include "platform.h"
#include "driver/spi.h"
#include
"c_types
.h
"
#include
<stdint
.h
>
#include "sdcard.h"
...
...
app/platform/sdcard.h
View file @
310faf7f
#ifndef _SDCARD_H
#define _SDCARD_H
#include "c_types.h"
#include <stdint.h>
#include <stddef.h>
int
platform_sdcard_init
(
uint8_t
spi_no
,
uint8_t
ss_pin
);
int
platform_sdcard_status
(
void
);
...
...
app/platform/u8x8_nodemcu_hal.c
View file @
310faf7f
...
...
@@ -6,11 +6,12 @@
#ifdef LUA_USE_MODULES_U8G2
#include <string.h>
#include
"c_
stdlib.h
"
#include
<
stdlib.h
>
#include "platform.h"
#define U8X8_USE_PINS
#define U8X8_WITH_USER_PTR
#include "u8x8_nodemcu_hal.h"
// static variables containing info about the i2c link
...
...
@@ -45,7 +46,7 @@ static void force_flush_buffer(u8x8_t *u8x8)
{
// spi hal has a buffer that can be flushed
if
(
u8x8
->
byte_cb
==
u8x8_byte_nodemcu_spi
)
{
hal_spi_t
*
hal
=
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
;
hal_spi_t
*
hal
=
u8x8
->
user_ptr
;
flush_buffer_spi
(
hal
);
}
}
...
...
@@ -164,7 +165,7 @@ uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
uint8_t
u8x8_byte_nodemcu_i2c
(
u8x8_t
*
u8x8
,
uint8_t
msg
,
uint8_t
arg_int
,
void
*
arg_ptr
)
{
uint8_t
*
data
;
hal_i2c_t
*
hal
=
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
;
hal_i2c_t
*
hal
=
u8x8
->
user_ptr
;
switch
(
msg
)
{
case
U8X8_MSG_BYTE_SEND
:
...
...
@@ -186,12 +187,12 @@ uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
case
U8X8_MSG_BYTE_INIT
:
{
// the
hal memb
er initially contains the i2c id
// the
user point
er initially contains the i2c id
int
id
=
(
int
)
hal
;
if
(
!
(
hal
=
c_
malloc
(
sizeof
(
hal_i2c_t
)
)))
if
(
!
(
hal
=
malloc
(
sizeof
(
hal_i2c_t
)
)))
return
0
;
hal
->
id
=
id
;
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
=
hal
;
u8x8
->
user_ptr
=
hal
;
}
break
;
...
...
@@ -229,7 +230,7 @@ uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
uint8_t
u8x8_byte_nodemcu_spi
(
u8x8_t
*
u8x8
,
uint8_t
msg
,
uint8_t
arg_int
,
void
*
arg_ptr
)
{
hal_spi_t
*
hal
=
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
;
hal_spi_t
*
hal
=
u8x8
->
user_ptr
;
switch
(
msg
)
{
case
U8X8_MSG_BYTE_INIT
:
...
...
@@ -237,12 +238,12 @@ uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
/* disable chipselect */
u8x8_gpio_SetCS
(
u8x8
,
u8x8
->
display_info
->
chip_disable_level
);
// the
hal memb
er initially contains the spi host id
// the
user point
er initially contains the spi host id
int
host
=
(
int
)
hal
;
if
(
!
(
hal
=
c_
malloc
(
sizeof
(
hal_spi_t
)
)))
if
(
!
(
hal
=
malloc
(
sizeof
(
hal_spi_t
)
)))
return
0
;
hal
->
host
=
host
;
((
u8g2_nodemcu_t
*
)
u8x8
)
->
hal
=
hal
;
u8x8
->
user_ptr
=
hal
;
hal
->
buffer
.
data
=
NULL
;
hal
->
last_dc
=
0
;
...
...
@@ -259,7 +260,7 @@ uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
case
U8X8_MSG_BYTE_START_TRANSFER
:
hal
->
buffer
.
size
=
256
;
if
(
!
(
hal
->
buffer
.
data
=
(
uint8_t
*
)
c_
malloc
(
hal
->
buffer
.
size
)))
if
(
!
(
hal
->
buffer
.
data
=
(
uint8_t
*
)
malloc
(
hal
->
buffer
.
size
)))
return
0
;
hal
->
buffer
.
used
=
0
;
...
...
@@ -273,13 +274,13 @@ uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
while
(
hal
->
buffer
.
size
-
hal
->
buffer
.
used
<
arg_int
)
{
hal
->
buffer
.
size
*=
2
;
uint8_t
*
tmp
;
if
(
!
(
tmp
=
(
uint8_t
*
)
c_
malloc
(
hal
->
buffer
.
size
)))
{
c_
free
(
hal
->
buffer
.
data
);
if
(
!
(
tmp
=
(
uint8_t
*
)
malloc
(
hal
->
buffer
.
size
)))
{
free
(
hal
->
buffer
.
data
);
hal
->
buffer
.
data
=
NULL
;
return
0
;
}
os_memcpy
(
tmp
,
hal
->
buffer
.
data
,
hal
->
buffer
.
used
);
c_
free
(
hal
->
buffer
.
data
);
free
(
hal
->
buffer
.
data
);
hal
->
buffer
.
data
=
tmp
;
}
os_memcpy
(
hal
->
buffer
.
data
+
hal
->
buffer
.
used
,
arg_ptr
,
arg_int
);
...
...
@@ -294,7 +295,7 @@ uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
u8x8_gpio_SetCS
(
u8x8
,
u8x8
->
display_info
->
chip_disable_level
);
c_
free
(
hal
->
buffer
.
data
);
free
(
hal
->
buffer
.
data
);
hal
->
buffer
.
data
=
NULL
;
break
;
...
...
app/platform/u8x8_nodemcu_hal.h
View file @
310faf7f
...
...
@@ -8,7 +8,6 @@
// extend standard u8g2_t struct with info that's needed in the communication callbacks
typedef
struct
{
u8g2_t
u8g2
;
void
*
hal
;
// elements for the overlay display driver
struct
{
...
...
app/platform/ucg_nodemcu_hal.c
View file @
310faf7f
...
...
@@ -5,7 +5,7 @@
#ifdef LUA_USE_MODULES_UCG
#include <string.h>
#include
"c_
stdlib.h
"
#include
<
stdlib.h
>
#include "platform.h"
...
...
app/platform/vfs.c
View file @
310faf7f
#include "c_stdlib.h"
#include "c_stdio.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "vfs.h"
#include "vfs_int.h"
#define LDRV_TRAVERSAL 0
// This interferes with our clearerr member in our ops struct
#undef clearerr
// ---------------------------------------------------------------------------
// RTC system interface
//
static
s
int32_t
(
*
rtc_cb
)(
vfs_time
*
tm
)
=
NULL
;
static
int32_t
(
*
rtc_cb
)(
vfs_time
*
tm
)
=
NULL
;
// called by operating system
void
vfs_register_rtc_cb
(
s
int32_t
(
*
cb
)(
vfs_time
*
tm
)
)
void
vfs_register_rtc_cb
(
int32_t
(
*
cb
)(
vfs_time
*
tm
)
)
{
// allow NULL pointer to unregister callback function
rtc_cb
=
cb
;
}
// called by file system drivers
s
int32_t
vfs_get_rtc
(
vfs_time
*
tm
)
int32_t
vfs_get_rtc
(
vfs_time
*
tm
)
{
if
(
rtc_cb
)
{
return
rtc_cb
(
tm
);
...
...
@@ -33,15 +34,18 @@ sint32_t vfs_get_rtc( vfs_time *tm )
static
int
dir_level
=
1
;
static
const
char
*
normalize_path
(
const
char
*
path
)
{
#if ! LDRV_TRAVERSAL
return
path
;
#define normalize_path(p) (p)
#else
static
const
char
*
normalize_path
(
const
char
*
path
)
{
const
char
*
temp
=
path
;
size_t
len
;
while
((
len
=
c_
strlen
(
temp
))
>=
2
)
{
while
((
len
=
strlen
(
temp
))
>=
2
)
{
if
(
temp
[
0
]
==
'.'
&&
temp
[
1
]
==
'.'
)
{
--
dir_level
;
if
(
len
>=
4
&&
dir_level
>
0
)
{
...
...
@@ -63,8 +67,8 @@ static const char *normalize_path( const char *path )
// path traverses via root
return
temp
;
}
#endif
}
#endif
// ---------------------------------------------------------------------------
...
...
@@ -85,7 +89,7 @@ vfs_vol *vfs_mount( const char *name, int num )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
vfs_vol
*
r
=
fs_fns
->
mount
(
outname
,
num
);
c_
free
(
outname
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -108,7 +112,7 @@ int vfs_open( const char *name, const char *mode )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
int
r
=
(
int
)
fs_fns
->
open
(
outname
,
mode
);
c_
free
(
outname
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -131,7 +135,7 @@ vfs_dir *vfs_opendir( const char *name )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
vfs_dir
*
r
=
fs_fns
->
opendir
(
outname
);
c_
free
(
outname
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -139,7 +143,7 @@ vfs_dir *vfs_opendir( const char *name )
return
NULL
;
}
s
int32_t
vfs_stat
(
const
char
*
name
,
struct
vfs_stat
*
buf
)
int32_t
vfs_stat
(
const
char
*
name
,
struct
vfs_stat
*
buf
)
{
vfs_fs_fns
*
fs_fns
;
const
char
*
normname
=
normalize_path
(
name
);
...
...
@@ -153,8 +157,8 @@ sint32_t vfs_stat( const char *name, struct vfs_stat *buf )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
s
int32_t
r
=
fs_fns
->
stat
(
outname
,
buf
);
c_
free
(
outname
);
int32_t
r
=
fs_fns
->
stat
(
outname
,
buf
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -162,7 +166,7 @@ sint32_t vfs_stat( const char *name, struct vfs_stat *buf )
return
VFS_RES_ERR
;
}
s
int32_t
vfs_remove
(
const
char
*
name
)
int32_t
vfs_remove
(
const
char
*
name
)
{
vfs_fs_fns
*
fs_fns
;
const
char
*
normname
=
normalize_path
(
name
);
...
...
@@ -176,8 +180,8 @@ sint32_t vfs_remove( const char *name )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
s
int32_t
r
=
fs_fns
->
remove
(
outname
);
c_
free
(
outname
);
int32_t
r
=
fs_fns
->
remove
(
outname
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -185,7 +189,7 @@ sint32_t vfs_remove( const char *name )
return
VFS_RES_ERR
;
}
s
int32_t
vfs_rename
(
const
char
*
oldname
,
const
char
*
newname
)
int32_t
vfs_rename
(
const
char
*
oldname
,
const
char
*
newname
)
{
vfs_fs_fns
*
fs_fns
;
const
char
*
normoldname
=
normalize_path
(
oldname
);
...
...
@@ -203,19 +207,19 @@ sint32_t vfs_rename( const char *oldname, const char *newname )
#ifdef BUILD_FATFS
if
(
myfatfs_realm
(
normoldname
,
&
oldoutname
,
FALSE
))
{
if
(
fs_fns
=
myfatfs_realm
(
normnewname
,
&
newoutname
,
FALSE
))
{
s
int32_t
r
=
fs_fns
->
rename
(
oldoutname
,
newoutname
);
c_
free
(
oldoutname
);
c_
free
(
newoutname
);
int32_t
r
=
fs_fns
->
rename
(
oldoutname
,
newoutname
);
free
(
oldoutname
);
free
(
newoutname
);
return
r
;
}
c_
free
(
oldoutname
);
free
(
oldoutname
);
}
#endif
return
-
1
;
}
s
int32_t
vfs_mkdir
(
const
char
*
name
)
int32_t
vfs_mkdir
(
const
char
*
name
)
{
vfs_fs_fns
*
fs_fns
;
const
char
*
normname
=
normalize_path
(
name
);
...
...
@@ -227,8 +231,8 @@ sint32_t vfs_mkdir( const char *name )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
s
int32_t
r
=
fs_fns
->
mkdir
(
outname
);
c_
free
(
outname
);
int32_t
r
=
fs_fns
->
mkdir
(
outname
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -236,7 +240,7 @@ sint32_t vfs_mkdir( const char *name )
return
VFS_RES_ERR
;
}
s
int32_t
vfs_fsinfo
(
const
char
*
name
,
uint32_t
*
total
,
uint32_t
*
used
)
int32_t
vfs_fsinfo
(
const
char
*
name
,
uint32_t
*
total
,
uint32_t
*
used
)
{
vfs_fs_fns
*
fs_fns
;
char
*
outname
;
...
...
@@ -253,7 +257,7 @@ sint32_t vfs_fsinfo( const char *name, uint32_t *total, uint32_t *used )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
c_
free
(
outname
);
free
(
outname
);
return
fs_fns
->
fsinfo
(
total
,
used
);
}
#endif
...
...
@@ -261,7 +265,7 @@ sint32_t vfs_fsinfo( const char *name, uint32_t *total, uint32_t *used )
return
VFS_RES_ERR
;
}
s
int32_t
vfs_fscfg
(
const
char
*
name
,
uint32_t
*
phys_addr
,
uint32_t
*
phys_size
)
int32_t
vfs_fscfg
(
const
char
*
name
,
uint32_t
*
phys_addr
,
uint32_t
*
phys_size
)
{
vfs_fs_fns
*
fs_fns
;
char
*
outname
;
...
...
@@ -280,7 +284,7 @@ sint32_t vfs_fscfg( const char *name, uint32_t *phys_addr, uint32_t *phys_size)
return
VFS_RES_ERR
;
}
s
int32_t
vfs_format
(
void
)
int32_t
vfs_format
(
void
)
{
vfs_fs_fns
*
fs_fns
;
char
*
outname
;
...
...
@@ -299,7 +303,7 @@ sint32_t vfs_format( void )
return
0
;
}
s
int32_t
vfs_chdir
(
const
char
*
path
)
int32_t
vfs_chdir
(
const
char
*
path
)
{
vfs_fs_fns
*
fs_fns
;
const
char
*
normpath
=
normalize_path
(
path
);
...
...
@@ -315,9 +319,9 @@ sint32_t vfs_chdir( const char *path )
}
else
{
level
=
normpath
;
}
while
(
c_
strlen
(
level
)
>
0
)
{
while
(
strlen
(
level
)
>
0
)
{
dir_level
++
;
if
(
level
=
c_
strchr
(
level
,
'/'
))
{
if
(
level
=
strchr
(
level
,
'/'
))
{
level
++
;
}
else
{
break
;
...
...
@@ -328,7 +332,7 @@ sint32_t vfs_chdir( const char *path )
#ifdef BUILD_SPIFFS
if
(
fs_fns
=
myspiffs_realm
(
normpath
,
&
outname
,
TRUE
))
{
// our SPIFFS integration doesn't support directories
if
(
c_
strlen
(
outname
)
==
0
)
{
if
(
strlen
(
outname
)
==
0
)
{
ok
=
VFS_RES_OK
;
}
}
...
...
@@ -336,7 +340,7 @@ sint32_t vfs_chdir( const char *path )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normpath
,
&
outname
,
TRUE
))
{
if
(
c_
strchr
(
outname
,
':'
))
{
if
(
strchr
(
outname
,
':'
))
{
// need to set FatFS' default drive
fs_fns
->
chdrive
(
outname
);
// and force chdir to root in case path points only to root
...
...
@@ -345,14 +349,14 @@ sint32_t vfs_chdir( const char *path )
if
(
fs_fns
->
chdir
(
outname
)
==
VFS_RES_OK
)
{
ok
=
VFS_RES_OK
;
}
c_
free
(
outname
);
free
(
outname
);
}
#endif
return
ok
==
VFS_RES_OK
?
VFS_RES_OK
:
VFS_RES_ERR
;
}
s
int32_t
vfs_errno
(
const
char
*
name
)
int32_t
vfs_errno
(
const
char
*
name
)
{
vfs_fs_fns
*
fs_fns
;
char
*
outname
;
...
...
@@ -369,8 +373,8 @@ sint32_t vfs_errno( const char *name )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
s
int32_t
r
=
fs_fns
->
ferrno
(
);
c_
free
(
outname
);
int32_t
r
=
fs_fns
->
ferrno
(
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -378,7 +382,7 @@ sint32_t vfs_errno( const char *name )
return
VFS_RES_ERR
;
}
s
int32_t
vfs_ferrno
(
int
fd
)
int32_t
vfs_ferrno
(
int
fd
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
...
...
@@ -397,8 +401,8 @@ sint32_t vfs_ferrno( int fd )
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
name
,
&
outname
,
FALSE
))
{
s
int32_t
r
=
fs_fns
->
ferrno
(
);
c_
free
(
outname
);
int32_t
r
=
fs_fns
->
ferrno
(
);
free
(
outname
);
return
r
;
}
#endif
...
...
@@ -417,14 +421,14 @@ void vfs_clearerr( const char *name )
#ifdef BUILD_SPIFFS
if
(
fs_fns
=
myspiffs_realm
(
normname
,
&
outname
,
FALSE
))
{
fs_fns
->
clearerr
(
);
fs_fns
->
clearerr
(
);
}
#endif
#ifdef BUILD_FATFS
if
(
fs_fns
=
myfatfs_realm
(
normname
,
&
outname
,
FALSE
))
{
fs_fns
->
clearerr
(
);
c_
free
(
outname
);
fs_fns
->
clearerr
(
);
free
(
outname
);
}
#endif
}
...
...
@@ -434,9 +438,9 @@ const char *vfs_basename( const char *path )
const
char
*
basename
;
// deduce basename (incl. extension) for length check
if
(
basename
=
c_
strrchr
(
path
,
'/'
))
{
if
(
basename
=
strrchr
(
path
,
'/'
))
{
basename
++
;
}
else
if
(
basename
=
c_
strrchr
(
path
,
':'
))
{
}
else
if
(
basename
=
strrchr
(
path
,
':'
))
{
basename
++
;
}
else
{
basename
=
path
;
...
...
@@ -452,7 +456,7 @@ const char *vfs_basename( const char *path )
int
vfs_getc
(
int
fd
)
{
unsigned
char
c
=
0xFF
;
s
int32_t
res
;
int32_t
res
;
if
(
!
vfs_eof
(
fd
))
{
if
(
1
!=
vfs_read
(
fd
,
&
c
,
1
))
{
...
...
app/platform/vfs.h
View file @
310faf7f
...
...
@@ -15,7 +15,7 @@
// vfs_close - close file descriptor and free memory
// fd: file descriptor
// Returns: VFS_RES_OK or negative value in case of error
static
s
int32_t
vfs_close
(
int
fd
)
{
static
int32_t
vfs_close
(
int
fd
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
close
(
f
)
:
VFS_RES_ERR
;
}
...
...
@@ -25,7 +25,7 @@ static sint32_t vfs_close( int fd ) {
// ptr: destination data buffer
// len: requested length
// Returns: Number of bytes read, or VFS_RES_ERR in case of error
static
s
int32_t
vfs_read
(
int
fd
,
void
*
ptr
,
size_t
len
)
{
static
int32_t
vfs_read
(
int
fd
,
void
*
ptr
,
size_t
len
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
read
(
f
,
ptr
,
len
)
:
VFS_RES_ERR
;
}
...
...
@@ -35,7 +35,7 @@ static sint32_t vfs_read( int fd, void *ptr, size_t len ) {
// ptr: source data buffer
// len: requested length
// Returns: Number of bytes written, or VFS_RES_ERR in case of error
static
s
int32_t
vfs_write
(
int
fd
,
const
void
*
ptr
,
size_t
len
)
{
static
int32_t
vfs_write
(
int
fd
,
const
void
*
ptr
,
size_t
len
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
write
(
f
,
ptr
,
len
)
:
VFS_RES_ERR
;
}
...
...
@@ -51,7 +51,7 @@ int vfs_ungetc( int c, int fd );
// VFS_SEEK_CUR - set pointer to current position + off
// VFS_SEEK_END - set pointer to end of file + off
// Returns: New position, or VFS_RES_ERR in case of error
static
s
int32_t
vfs_lseek
(
int
fd
,
s
int32_t
off
,
int
whence
)
{
static
int32_t
vfs_lseek
(
int
fd
,
int32_t
off
,
int
whence
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
lseek
(
f
,
off
,
whence
)
:
VFS_RES_ERR
;
}
...
...
@@ -59,7 +59,7 @@ static sint32_t vfs_lseek( int fd, sint32_t off, int whence ) {
// vfs_eof - test for end-of-file
// fd: file descriptor
// Returns: 0 if not at end, != 0 if end of file
static
s
int32_t
vfs_eof
(
int
fd
)
{
static
int32_t
vfs_eof
(
int
fd
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
eof
(
f
)
:
VFS_RES_ERR
;
}
...
...
@@ -67,7 +67,7 @@ static sint32_t vfs_eof( int fd ) {
// vfs_tell - get read/write position
// fd: file descriptor
// Returns: Current position
static
s
int32_t
vfs_tell
(
int
fd
)
{
static
int32_t
vfs_tell
(
int
fd
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
tell
(
f
)
:
VFS_RES_ERR
;
}
...
...
@@ -75,7 +75,7 @@ static sint32_t vfs_tell( int fd ) {
// vfs_flush - flush write cache to file
// fd: file descriptor
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
static
s
int32_t
vfs_flush
(
int
fd
)
{
static
int32_t
vfs_flush
(
int
fd
)
{
vfs_file
*
f
=
(
vfs_file
*
)
fd
;
return
f
?
f
->
fns
->
flush
(
f
)
:
VFS_RES_ERR
;
}
...
...
@@ -91,7 +91,7 @@ static uint32_t vfs_size( int fd ) {
// vfs_ferrno - get file system specific errno
// fd: file descriptor
// Returns: errno
s
int32_t
vfs_ferrno
(
int
fd
);
int32_t
vfs_ferrno
(
int
fd
);
// ---------------------------------------------------------------------------
// dir functions
...
...
@@ -100,13 +100,13 @@ sint32_t vfs_ferrno( int fd );
// vfs_closedir - close directory descriptor and free memory
// dd: dir descriptor
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
static
s
int32_t
vfs_closedir
(
vfs_dir
*
dd
)
{
return
dd
->
fns
->
close
(
dd
);
}
static
int32_t
vfs_closedir
(
vfs_dir
*
dd
)
{
return
dd
->
fns
->
close
(
dd
);
}
// vfs_readdir - read next directory item
// dd: dir descriptor
// buf: pre-allocated stat structure to be filled in
// Returns: VFS_RES_OK if next item found, otherwise VFS_RES_ERR
static
s
int32_t
vfs_readdir
(
vfs_dir
*
dd
,
struct
vfs_stat
*
buf
)
{
return
dd
->
fns
->
readdir
(
dd
,
buf
);
}
static
int32_t
vfs_readdir
(
vfs_dir
*
dd
,
struct
vfs_stat
*
buf
)
{
return
dd
->
fns
->
readdir
(
dd
,
buf
);
}
// ---------------------------------------------------------------------------
// volume functions
...
...
@@ -115,7 +115,7 @@ static sint32_t vfs_readdir( vfs_dir *dd, struct vfs_stat *buf ) { return dd->fn
// vfs_umount - unmount logical drive and free memory
// vol: volume object
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
static
s
int32_t
vfs_umount
(
vfs_vol
*
vol
)
{
return
vol
->
fns
->
umount
(
vol
);
}
static
int32_t
vfs_umount
(
vfs_vol
*
vol
)
{
return
vol
->
fns
->
umount
(
vol
);
}
// ---------------------------------------------------------------------------
// file system functions
...
...
@@ -142,56 +142,56 @@ vfs_dir *vfs_opendir( const char *name );
// name: file or directory name
// buf: pre-allocated structure to be filled in
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_stat
(
const
char
*
name
,
struct
vfs_stat
*
buf
);
int32_t
vfs_stat
(
const
char
*
name
,
struct
vfs_stat
*
buf
);
// vfs_remove - remove file or directory
// name: file or directory name
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_remove
(
const
char
*
name
);
int32_t
vfs_remove
(
const
char
*
name
);
// vfs_rename - rename file or directory
// name: file or directory name
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_rename
(
const
char
*
oldname
,
const
char
*
newname
);
int32_t
vfs_rename
(
const
char
*
oldname
,
const
char
*
newname
);
// vfs_mkdir - create directory
// name: directory name
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_mkdir
(
const
char
*
name
);
int32_t
vfs_mkdir
(
const
char
*
name
);
// vfs_fsinfo - get file system info
// name: logical drive identifier
// total: receives total amount
// used: received used amount
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_fsinfo
(
const
char
*
name
,
uint32_t
*
total
,
uint32_t
*
used
);
int32_t
vfs_fsinfo
(
const
char
*
name
,
uint32_t
*
total
,
uint32_t
*
used
);
// vfs_format - format file system
// Returns: 1, or 0 in case of error
s
int32_t
vfs_format
(
void
);
int32_t
vfs_format
(
void
);
// vfs_chdir - change default directory
// path: new default directory
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_chdir
(
const
char
*
path
);
int32_t
vfs_chdir
(
const
char
*
path
);
// vfs_fscfg - query configuration settings of file system
// phys_addr: pointer to store physical address information
// phys_size: pointer to store physical size information
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
s
int32_t
vfs_fscfg
(
const
char
*
name
,
uint32_t
*
phys_addr
,
uint32_t
*
phys_size
);
int32_t
vfs_fscfg
(
const
char
*
name
,
uint32_t
*
phys_addr
,
uint32_t
*
phys_size
);
// vfs_errno - get file system specific errno
// name: logical drive identifier
// Returns: errno
s
int32_t
vfs_errno
(
const
char
*
name
);
int32_t
vfs_errno
(
const
char
*
name
);
// vfs_clearerr - cleaer file system specific errno
void
vfs_clearerr
(
const
char
*
name
);
// vfs_register_rtc_cb - register callback function for RTC query
// cb: pointer to callback function
void
vfs_register_rtc_cb
(
s
int32_t
(
*
cb
)(
vfs_time
*
tm
)
);
void
vfs_register_rtc_cb
(
int32_t
(
*
cb
)(
vfs_time
*
tm
)
);
// vfs_basename - identify basename (incl. extension)
// path: full file system path
...
...
app/platform/vfs_int.h
View file @
310faf7f
...
...
@@ -3,16 +3,10 @@
#ifndef __VFS_INT_H__
#define __VFS_INT_H__
#include <c_string.h>
#include <c_stdint.h>
#if 0
#include "spiffs.h"
#include "fatfs_prefix_lib.h"
#include "ff.h"
#endif
#include <string.h>
#include <stdint.h>
#include "user_config.h"
#define VFS_EOF -1
...
...
@@ -62,15 +56,15 @@ struct vfs_stat {
// file descriptor functions
struct
vfs_file_fns
{
s
int32_t
(
*
close
)(
const
struct
vfs_file
*
fd
);
s
int32_t
(
*
read
)(
const
struct
vfs_file
*
fd
,
void
*
ptr
,
size_t
len
);
s
int32_t
(
*
write
)(
const
struct
vfs_file
*
fd
,
const
void
*
ptr
,
size_t
len
);
s
int32_t
(
*
lseek
)(
const
struct
vfs_file
*
fd
,
s
int32_t
off
,
int
whence
);
s
int32_t
(
*
eof
)(
const
struct
vfs_file
*
fd
);
s
int32_t
(
*
tell
)(
const
struct
vfs_file
*
fd
);
s
int32_t
(
*
flush
)(
const
struct
vfs_file
*
fd
);
int32_t
(
*
close
)(
const
struct
vfs_file
*
fd
);
int32_t
(
*
read
)(
const
struct
vfs_file
*
fd
,
void
*
ptr
,
size_t
len
);
int32_t
(
*
write
)(
const
struct
vfs_file
*
fd
,
const
void
*
ptr
,
size_t
len
);
int32_t
(
*
lseek
)(
const
struct
vfs_file
*
fd
,
int32_t
off
,
int
whence
);
int32_t
(
*
eof
)(
const
struct
vfs_file
*
fd
);
int32_t
(
*
tell
)(
const
struct
vfs_file
*
fd
);
int32_t
(
*
flush
)(
const
struct
vfs_file
*
fd
);
uint32_t
(
*
size
)(
const
struct
vfs_file
*
fd
);
s
int32_t
(
*
ferrno
)(
const
struct
vfs_file
*
fd
);
int32_t
(
*
ferrno
)(
const
struct
vfs_file
*
fd
);
};
typedef
const
struct
vfs_file_fns
vfs_file_fns
;
...
...
@@ -83,8 +77,8 @@ typedef const struct vfs_dir vfs_dir;
// dir descriptor functions
struct
vfs_dir_fns
{
s
int32_t
(
*
close
)(
const
struct
vfs_dir
*
dd
);
s
int32_t
(
*
readdir
)(
const
struct
vfs_dir
*
dd
,
struct
vfs_stat
*
buf
);
int32_t
(
*
close
)(
const
struct
vfs_dir
*
dd
);
int32_t
(
*
readdir
)(
const
struct
vfs_dir
*
dd
,
struct
vfs_stat
*
buf
);
};
typedef
const
struct
vfs_dir_fns
vfs_dir_fns
;
...
...
@@ -97,7 +91,7 @@ typedef const struct vfs_vol vfs_vol;
// volume functions
struct
vfs_vol_fns
{
s
int32_t
(
*
umount
)(
const
struct
vfs_vol
*
vol
);
int32_t
(
*
umount
)(
const
struct
vfs_vol
*
vol
);
};
typedef
const
struct
vfs_vol_fns
vfs_vol_fns
;
...
...
@@ -105,17 +99,17 @@ struct vfs_fs_fns {
vfs_vol
*
(
*
mount
)(
const
char
*
name
,
int
num
);
vfs_file
*
(
*
open
)(
const
char
*
name
,
const
char
*
mode
);
vfs_dir
*
(
*
opendir
)(
const
char
*
name
);
s
int32_t
(
*
stat
)(
const
char
*
name
,
struct
vfs_stat
*
buf
);
s
int32_t
(
*
remove
)(
const
char
*
name
);
s
int32_t
(
*
rename
)(
const
char
*
oldname
,
const
char
*
newname
);
s
int32_t
(
*
mkdir
)(
const
char
*
name
);
s
int32_t
(
*
fsinfo
)(
uint32_t
*
total
,
uint32_t
*
used
);
s
int32_t
(
*
fscfg
)(
uint32_t
*
phys_addr
,
uint32_t
*
phys_size
);
s
int32_t
(
*
format
)(
void
);
s
int32_t
(
*
chdrive
)(
const
char
*
);
s
int32_t
(
*
chdir
)(
const
char
*
);
s
int32_t
(
*
ferrno
)(
void
);
void
(
*
clearerr
)(
void
);
int32_t
(
*
stat
)(
const
char
*
name
,
struct
vfs_stat
*
buf
);
int32_t
(
*
remove
)(
const
char
*
name
);
int32_t
(
*
rename
)(
const
char
*
oldname
,
const
char
*
newname
);
int32_t
(
*
mkdir
)(
const
char
*
name
);
int32_t
(
*
fsinfo
)(
uint32_t
*
total
,
uint32_t
*
used
);
int32_t
(
*
fscfg
)(
uint32_t
*
phys_addr
,
uint32_t
*
phys_size
);
int32_t
(
*
format
)(
void
);
int32_t
(
*
chdrive
)(
const
char
*
);
int32_t
(
*
chdir
)(
const
char
*
);
int32_t
(
*
ferrno
)(
void
);
void
(
*
clearerr
)(
void
);
};
typedef
const
struct
vfs_fs_fns
vfs_fs_fns
;
...
...
@@ -123,6 +117,6 @@ typedef const struct vfs_fs_fns vfs_fs_fns;
vfs_fs_fns
*
myspiffs_realm
(
const
char
*
inname
,
char
**
outname
,
int
set_current_drive
);
vfs_fs_fns
*
myfatfs_realm
(
const
char
*
inname
,
char
**
outname
,
int
set_current_drive
);
s
int32_t
vfs_get_rtc
(
vfs_time
*
tm
);
int32_t
vfs_get_rtc
(
vfs_time
*
tm
);
#endif
app/pm/Makefile
View file @
310faf7f
...
...
@@ -38,15 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
INCLUDES
+=
-I
./include
INCLUDES
+=
-I
../include
INCLUDES
+=
-I
../../include
INCLUDES
+=
-I
../lua
INCLUDES
+=
-I
../platform
INCLUDES
+=
-I
../libc
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
app/pm/pmSleep.c
View file @
310faf7f
...
...
@@ -370,7 +370,7 @@ void pmSleep_suspend(pmSleep_param_t *cfg){
wifi_fpm_set_wakeup_cb
(
resume_cb
);
// Set resume C callback
c_
memcpy
(
&
current_config
,
cfg
,
sizeof
(
pmSleep_param_t
));
memcpy
(
&
current_config
,
cfg
,
sizeof
(
pmSleep_param_t
));
PMSLEEP_DBG
(
"sleep duration is %d"
,
current_config
.
sleep_duration
);
os_timer_disarm
(
&
null_mode_check_timer
);
...
...
app/pm/swtimer.c
View file @
310faf7f
...
...
@@ -37,18 +37,19 @@
* Once there are no more suspended timers, the function returns
*
*
*/
#include "module.h"
*/
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
#include "user_interface.h"
#include "user_modules.h"
#include
"c_
string.h
"
#include
"c_
stdlib.h
"
#include
"
ctype.h
"
#include
"c_types
.h
"
#include
<
string.h
>
#include
<
stdlib.h
>
#include
<
ctype.h
>
#include <stdint.h>
#include
<stddef
.h
>
//#define SWTMR_DEBUG
#if !defined(SWTMR_DBG) && defined(LUA_USE_MODULES_SWTMR_DBG)
...
...
@@ -138,7 +139,7 @@ void swtmr_suspend_timers(){
size_t
registered_cb_qty
=
lua_objlen
(
L
,
-
1
);
//allocate a temporary array to hold the list of callback pointers
cb_registry_item_t
**
cb_reg_array
=
c
_z
alloc
(
sizeof
(
cb_registry_item_t
*
)
*
registered_cb_qty
);
cb_registry_item_t
**
cb_reg_array
=
calloc
(
1
,
sizeof
(
cb_registry_item_t
*
)
*
registered_cb_qty
);
if
(
!
cb_reg_array
){
luaL_error
(
L
,
"%s: unable to suspend timers, out of memory!"
,
__func__
);
return
;
...
...
@@ -242,7 +243,7 @@ void swtmr_suspend_timers(){
}
//tmr_cb_ptr_array is no longer needed.
c_
free
(
cb_reg_array
);
free
(
cb_reg_array
);
//add suspended_timer_list pointer to swtimer table.
lua_pushstring
(
L
,
SUSP_LIST_STR
);
...
...
@@ -391,7 +392,7 @@ void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy){
static
void
add_to_reg_queue
(
void
*
timer_cb_ptr
,
uint8
suspend_policy
){
if
(
!
timer_cb_ptr
)
return
;
tmr_cb_queue_t
*
queue_temp
=
c
_z
alloc
(
sizeof
(
tmr_cb_queue_t
));
tmr_cb_queue_t
*
queue_temp
=
calloc
(
1
,
sizeof
(
tmr_cb_queue_t
));
if
(
!
queue_temp
){
//it's boot time currently and we're already out of memory, something is very wrong...
dbg_printf
(
"
\n\t
%s:out of memory, rebooting."
,
__FUNCTION__
);
...
...
@@ -430,7 +431,7 @@ static void process_cb_register_queue(task_param_t param, uint8 priority)
void
*
cb_ptr_tmp
=
register_queue_ptr
->
tmr_cb_ptr
;
swtmr_cb_register
(
cb_ptr_tmp
,
register_queue_ptr
->
suspend_policy
);
register_queue
=
register_queue
->
next
;
c_
free
(
register_queue_ptr
);
free
(
register_queue_ptr
);
}
return
;
}
...
...
@@ -457,7 +458,7 @@ int print_timer_list(lua_State* L){
}
lua_pop
(
L
,
1
);
size_t
registered_cb_qty
=
lua_objlen
(
L
,
-
1
);
cb_registry_item_t
**
cb_reg_array
=
c
_z
alloc
(
sizeof
(
cb_registry_item_t
*
)
*
registered_cb_qty
);
cb_registry_item_t
**
cb_reg_array
=
calloc
(
1
,
sizeof
(
cb_registry_item_t
*
)
*
registered_cb_qty
);
if
(
!
cb_reg_array
){
luaL_error
(
L
,
"%s: unable to suspend timers, out of memory!"
,
__func__
);
return
0
;
...
...
@@ -490,7 +491,7 @@ int print_timer_list(lua_State* L){
timer_list_ptr
=
timer_list_ptr
->
timer_next
;
}
c_
free
(
cb_reg_array
);
free
(
cb_reg_array
);
lua_pop
(
L
,
1
);
return
0
;
...
...
@@ -530,15 +531,15 @@ int resume_timers_lua(lua_State* L){
return
0
;
}
static
const
LUA_REG_TYPE
test_swtimer_debug
_map
[]
=
{
{
LSTRKE
Y
(
"
timer_list
"
),
LFUNCVAL
(
print_timer_list
)
},
{
LSTRKE
Y
(
"
susp_timer_list
"
),
LFUNCVAL
(
print_susp_timer_list
)
},
{
LSTRKE
Y
(
"
suspend
"
),
LFUNCVAL
(
suspend_timers_lua
)
},
{
LSTRKE
Y
(
"
resume
"
),
LFUNCVAL
(
resume_timers_lua
)
},
{
LNILKEY
,
LNILVAL
}
};
LROT_BEGIN
(
test_swtimer_debug
)
LROT_FUNCENTR
Y
(
timer_list
,
print_timer_list
)
LROT_FUNCENTR
Y
(
susp_timer_list
,
print_susp_timer_list
)
LROT_FUNCENTR
Y
(
suspend
,
suspend_timers_lua
)
LROT_FUNCENTR
Y
(
resume
,
resume_timers_lua
)
LROT_END
(
test_swtimer_debug
,
NULL
,
0
)
NODEMCU_MODULE
(
SWTMR_DBG
,
"SWTMR_DBG"
,
test_swtimer_debug
_map
,
NULL
);
NODEMCU_MODULE
(
SWTMR_DBG
,
"SWTMR_DBG"
,
test_swtimer_debug
,
NULL
);
#endif
app/sjson/Makefile
View file @
310faf7f
...
...
@@ -37,11 +37,6 @@ DEFINES += -include memcompat.h -include json_config.h
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
INCLUDES
+=
-I
./include
INCLUDES
+=
-I
../include
INCLUDES
+=
-I
../../include
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
app/sjson/memcompat.h
View file @
310faf7f
#ifndef __MEMCOMPAT_H__
#define __MEMCOMPAT_H__
#include
"c_types
.h
"
#include
<stdint
.h
>
#include "mem.h"
static
inline
void
*
malloc
(
size_t
sz
)
{
return
os_malloc
(
sz
);
}
static
inline
void
free
(
void
*
p
)
{
return
os_free
(
p
);
}
static
inline
void
*
calloc
(
size_t
n
,
size_t
sz
)
{
return
os_zalloc
(
n
*
sz
);
}
#endif
app/smart/Makefile
View file @
310faf7f
...
...
@@ -36,9 +36,6 @@ endif
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
INCLUDES
+=
-I
../libc
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
app/smart/smart.c
View file @
310faf7f
#include
"c_
stdio.h
"
#include
"c_
stdlib.h
"
#include
"c_
string.h
"
#include
<
stdio.h
>
#include
<
stdlib.h
>
#include
<
string.h
>
#include "user_interface.h"
#include "smart.h"
#include "pm/swtimer.h"
...
...
@@ -39,7 +39,7 @@ int smart_check(uint8_t *nibble, uint16_t len, uint8_t *dst, uint8_t *got){
uint16_t
dst_len
=
len
/
NIBBLE_PER_BYTE
;
uint16_t
byte_num
=
0
,
bit_num
=
0
;
int
i
=
0
,
res
=
1
;
// assume ok.
c_
memset
(
dst
,
0
,
dst_len
);
memset
(
dst
,
0
,
dst_len
);
if
(
NIBBLE_PER_BYTE
==
1
){
for
(
i
=
0
;
i
<
len
;
i
++
){
...
...
@@ -161,7 +161,7 @@ void detect(uint8 *arg, uint16 len){
if
(
len
-
am
[
i
]
->
base_len
==
am
[
i
]
->
flag
[
0
])
// store new source-dest adress pair to the map until flag[0] is got
{
// BSSID, SA, DA, store the SA, DA
c_
memcpy
(
am
[
i
]
->
addr
,
&
buf
[
ADDR_MATCH_START
],
ADDR_MATCH_LENGTH
);
memcpy
(
am
[
i
]
->
addr
,
&
buf
[
ADDR_MATCH_START
],
ADDR_MATCH_LENGTH
);
am
[
i
]
->
flag_match_num
++
;
// =1
am
[
i
]
->
cur_base_seq
=
seq
;
// assume the first seq is found
am
[
i
]
->
base_seq_valid
=
1
;
...
...
@@ -169,7 +169,7 @@ void detect(uint8 *arg, uint16 len){
}
break
;
// break any way for the next packet to come
}
else
if
(
0
==
c_
memcmp
(
am
[
i
]
->
addr
,
&
buf
[
ADDR_MATCH_START
],
ADDR_MATCH_LENGTH
)){
// source-dest adress pair match
else
if
(
0
==
memcmp
(
am
[
i
]
->
addr
,
&
buf
[
ADDR_MATCH_START
],
ADDR_MATCH_LENGTH
)){
// source-dest adress pair match
if
(
am
[
i
]
->
base_seq_valid
==
0
){
if
(
len
-
am
[
i
]
->
base_len
==
am
[
i
]
->
flag
[
0
])
{
// found the new flag[0]
// here flag_match_num is already = 1
...
...
@@ -236,7 +236,7 @@ void detect(uint8 *arg, uint16 len){
// break out, or loop done.
goto
end
;
}
else
{
// cur_base_seq is ref to SSID_FLAG when patern is alread found
if
(
0
!=
c_
memcmp
(
matched
->
addr
,
&
buf
[
ADDR_MATCH_START
],
ADDR_MATCH_LENGTH
)){
// source-dest adress pair not match, ignore it
if
(
0
!=
memcmp
(
matched
->
addr
,
&
buf
[
ADDR_MATCH_START
],
ADDR_MATCH_LENGTH
)){
// source-dest adress pair not match, ignore it
return
;
}
if
(
matched
->
base_seq_valid
==
0
){
// SSID_FLAG seq invalid, need to find the next valid seq number
...
...
@@ -455,7 +455,7 @@ void reset_map(smart_addr_map **am, size_t num){
am
[
i
]
->
base_seq_valid
=
0
;
am
[
i
]
->
ssid_len
=
0
;
am
[
i
]
->
pwd_len
=
0
;
c_
memset
(
am
[
i
]
->
addr
,
0
,
ADDR_MATCH_LENGTH
);
memset
(
am
[
i
]
->
addr
,
0
,
ADDR_MATCH_LENGTH
);
if
(
SEP_1_INDEX
==
0
){
am
[
i
]
->
flag
[
0
]
=
SEP_1
;
am
[
i
]
->
flag
[
1
]
=
SEP_2
;
...
...
@@ -511,34 +511,34 @@ void smart_end(){
for
(
i
=
0
;
i
<
ADDR_MAP_NUM
;
++
i
)
{
if
(
am
[
i
]){
c_
free
(
am
[
i
]);
free
(
am
[
i
]);
am
[
i
]
=
NULL
;
}
matched
=
NULL
;
}
if
(
sta_conf
){
c_
free
(
sta_conf
);
free
(
sta_conf
);
sta_conf
=
NULL
;
}
if
(
got_password
){
c_
free
(
got_password
);
free
(
got_password
);
got_password
=
NULL
;
}
if
(
got_ssid
){
c_
free
(
got_ssid
);
free
(
got_ssid
);
got_ssid
=
NULL
;
}
if
(
password_nibble
){
c_
free
(
password_nibble
);
free
(
password_nibble
);
password_nibble
=
NULL
;
}
if
(
ssid_nibble
){
c_
free
(
ssid_nibble
);
free
(
ssid_nibble
);
ssid_nibble
=
NULL
;
}
// system_restart(); // restart to enable the mode
...
...
@@ -583,14 +583,14 @@ void smart_next_channel(){
NODE_ERR
(
"switch to channel %d
\n
"
,
cur_channel
);
wifi_set_channel
(
cur_channel
);
reset_map
(
am
,
ADDR_MAP_NUM
);
c_
memset
(
sta_conf
->
ssid
,
0
,
sizeof
(
sta_conf
->
ssid
));
c_
memset
(
sta_conf
->
password
,
0
,
sizeof
(
sta_conf
->
password
));
memset
(
sta_conf
->
ssid
,
0
,
sizeof
(
sta_conf
->
ssid
));
memset
(
sta_conf
->
password
,
0
,
sizeof
(
sta_conf
->
password
));
c_
memset
(
got_ssid
,
0
,
SSID_BIT_MAX
);
c_
memset
(
got_password
,
0
,
PWD_BIT_MAX
);
memset
(
got_ssid
,
0
,
SSID_BIT_MAX
);
memset
(
got_password
,
0
,
PWD_BIT_MAX
);
c_
memset
(
ssid_nibble
,
0
,
SSID_NIBBLE_MAX
);
c_
memset
(
password_nibble
,
0
,
PWD_NIBBLE_MAX
);
memset
(
ssid_nibble
,
0
,
SSID_NIBBLE_MAX
);
memset
(
password_nibble
,
0
,
PWD_NIBBLE_MAX
);
os_timer_disarm
(
&
smart_timer
);
os_timer_arm
(
&
smart_timer
,
TIME_OUT_PER_CHANNEL
,
0
);
// no repeat
...
...
@@ -604,7 +604,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
for
(
i
=
0
;
i
<
ADDR_MAP_NUM
;
++
i
)
{
if
(
!
am
[
i
]){
am
[
i
]
=
(
smart_addr_map
*
)
c
_z
alloc
(
sizeof
(
smart_addr_map
));
am
[
i
]
=
(
smart_addr_map
*
)
calloc
(
1
,
sizeof
(
smart_addr_map
));
if
(
!
am
[
i
]){
NODE_DBG
(
"smart_begin map no memory
\n
"
);
smart_end
();
...
...
@@ -613,7 +613,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
}
if
(
!
sta_conf
){
sta_conf
=
(
struct
station_config
*
)
c
_z
alloc
(
sizeof
(
struct
station_config
));
sta_conf
=
(
struct
station_config
*
)
calloc
(
1
,
sizeof
(
struct
station_config
));
if
(
!
sta_conf
){
NODE_DBG
(
"smart_begin sta_conf no memory
\n
"
);
smart_end
();
...
...
@@ -622,7 +622,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if
(
!
ssid_nibble
){
ssid_nibble
=
(
uint8_t
*
)
c
_z
alloc
(
SSID_NIBBLE_MAX
);
ssid_nibble
=
(
uint8_t
*
)
calloc
(
1
,
SSID_NIBBLE_MAX
);
if
(
!
ssid_nibble
){
NODE_DBG
(
"smart_begin sta_conf no memory
\n
"
);
smart_end
();
...
...
@@ -631,7 +631,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if
(
!
password_nibble
){
password_nibble
=
(
uint8_t
*
)
c
_z
alloc
(
PWD_NIBBLE_MAX
);
password_nibble
=
(
uint8_t
*
)
calloc
(
1
,
PWD_NIBBLE_MAX
);
if
(
!
password_nibble
){
NODE_DBG
(
"smart_begin sta_conf no memory
\n
"
);
smart_end
();
...
...
@@ -640,7 +640,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if
(
!
got_ssid
){
got_ssid
=
(
uint8_t
*
)
c
_z
alloc
(
SSID_BIT_MAX
);
got_ssid
=
(
uint8_t
*
)
calloc
(
1
,
SSID_BIT_MAX
);
if
(
!
got_ssid
){
NODE_DBG
(
"smart_begin sta_conf no memory
\n
"
);
smart_end
();
...
...
@@ -649,7 +649,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if
(
!
got_password
){
got_password
=
(
uint8_t
*
)
c
_z
alloc
(
PWD_BIT_MAX
);
got_password
=
(
uint8_t
*
)
calloc
(
1
,
PWD_BIT_MAX
);
if
(
!
got_password
){
NODE_DBG
(
"smart_begin sta_conf no memory
\n
"
);
smart_end
();
...
...
@@ -657,14 +657,14 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
}
reset_map
(
am
,
ADDR_MAP_NUM
);
//
c_
memset(sta_conf->ssid, 0, sizeof(sta_conf->ssid));
//
c_
memset(sta_conf->password, 0, sizeof(sta_conf->password));
// memset(sta_conf->ssid, 0, sizeof(sta_conf->ssid));
// memset(sta_conf->password, 0, sizeof(sta_conf->password));
//
c_
memset(got_ssid, 0, SSID_BIT_MAX);
//
c_
memset(got_password, 0, PWD_BIT_MAX);
// memset(got_ssid, 0, SSID_BIT_MAX);
// memset(got_password, 0, PWD_BIT_MAX);
//
c_
memset(ssid_nibble, 0, SSID_NIBBLE_MAX);
//
c_
memset(password_nibble, 0, PWD_NIBBLE_MAX);
// memset(ssid_nibble, 0, SSID_NIBBLE_MAX);
// memset(password_nibble, 0, PWD_NIBBLE_MAX);
mode
=
wifi_get_opmode
();
if
(
(
STATION_MODE
==
mode
)
||
(
mode
==
STATIONAP_MODE
)
){
wifi_station_set_auto_connect
(
false
);
...
...
app/spiffs/Makefile
View file @
310faf7f
...
...
@@ -22,7 +22,7 @@ endif
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
DEFINES
+=
-D
printf
=
c_printf
#
DEFINES += -D
DEVELOPMENT_TOOLS -DNODE_DEBUG -DSPIFFS_API_DBG=NODE_DBG
#############################################################
# Recursion Magic - Don't touch this!!
...
...
@@ -36,9 +36,5 @@ DEFINES += -Dprintf=c_printf
# Required for each makefile to inherit from the parent
#
INCLUDES
:=
$(INCLUDES)
-I
$(PDIR)
include
INCLUDES
+=
-I
./
INCLUDES
+=
-I
../libc
INCLUDES
+=
-I
../platform
PDIR
:=
../
$(PDIR)
sinclude
$(PDIR)Makefile
Prev
1
…
10
11
12
13
14
15
16
17
18
19
Next
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