您好,希望在程序运行后,修改连接AP的SSID和密码,并且能够保存,这样下次上电运行,就可以读出这些信息,并且还需要保存一些其他的应用参数。这些参数应该可以通过程序 保存在 SPI接口的FLASH中。但是文档中似乎找不到 在程序中保存自定义参数的 方法,如果有,求指点!!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好,希望在程序运行后,修改连接AP的SSID和密码,并且能够保存,这样下次上电运行,就可以读出这些信息,并且还需要保存一些其他的应用参数。这些参数应该可以通过程序 保存在 SPI接口的FLASH中。但是文档中似乎找不到 在程序中保存自定义参数的 方法,如果有,求指点!!
使用
char* DeviceFileName = "MyFile.txt";
unsigned long MaxSize = 63 * 1024; //62.5K is max file size
long DeviceFileHandle = -1;
_i32 RetVal; //negative retval is an error
unsigned long Offset = 0;
unsigned char InputBuffer[100];
_u32 MasterToken = 0;
// Create a file and write data. The file in this example is secured, without signature and with a fail safe commit
//create a secure file if not exists and open it for write.
DeviceFileHandle = sl_FsOpen(unsigned char *)DeviceFileName,
SL_FS_CREATE|SL_FS_OVERWRITE | SL_FS_CREATE_SECURE | SL_FS_CREATE_NOSIGNATURE | SL_FS_CREATE_MAX_SIZE( MaxSize ),
&MasterToken);
Offset = 0;
//Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
RetVal = sl_FsWrite( DeviceFileHandle, Offset, (unsigned char *)"HelloWorld", strlen("HelloWorld"));
RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
// open the same file for read, using the Token we got from the creation procedure above
DeviceFileHandle = sl_FsOpen(unsigned char *)DeviceFileName,
SL_FS_READ,
&MasterToken);
Offset = 0;
RetVal = sl_FsRead( DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));
RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
上面的程序也不可以吗?