#ifndef  _STORAGE_H__
#define  _STORAGE_H__

#include <stdint.h>

#define DEV_NUMER_ADDR_OFFSET                               0x10
#define DEV_SUB_CODE_ADDR_OFFSET                            0x20   //2byte [0x20,0x21]
#define DEV_BUS_BAUD_ADDR_OFFSET                            0x22    //8byte [0x22,0x29]
#define DEV_PASSWORD_ADDR_OFFSET                            0x2A    //6byte [0x2A, 0x2F]

#define NET_LOCAL_CFG_ADDR_OFFSET                           0x30 // 0x70   // sizeof(Local_Net_Cfg):32byte
#define NET_CENTER_CFG_ADDR_OFFSET                          0x50   // sizeof(NET_CENTER_INFO): 12byte
#define IOT_NET_CFG_ADDR                                    0x60   // sizeof(IOT_NET_INFO):226(0xE2), 
#define IOT_TOPIC_CFG_ADDR                                  (0x60 + 232)  // sizeof(IOT_Topic): 129(0x81)


char get_ble_safe_flag(void);
void open_ble_safe_flag(void);
void close_ble_safe_flag(void);
char check_ble_safe_pass(uint8_t * devpass);
void set_ble_safe_pass(uint8_t * devpass);

void alter_dev_serila(uint8_t *serial);
void alter_dev_baud(uint8_t *baudbuf);

void factory_dev_info(void);
void output_cfg_from_flash(void);
void load_cfg_from_flash(void);


void SPI_Flash_Read(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t size);
void SPI_Flash_Write(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size);

void storage_init(void);

#endif
