fixing homekit filestroage build. Still have issue with c++ in fileio
This commit is contained in:
6 files changed
+24
-10
No files matched your search
@@ -13,7 +13,7 @@
|
||||
//#include <pstorage.h>
|
||||
//#include <app_scheduler.h>
|
||||
#include <nrf_soc.h>
|
||||
#include "nffs/nffs.h"
|
||||
#include "Bluefruit_FileIO.h"
|
||||
#include "utility/debug.h"
|
||||
|
||||
#include "rtos.h"
|
||||
@@ -107,7 +107,13 @@ static uint8_t crypto_loadKeys(void)
|
||||
crypto_persistent_keys_t keys = {};
|
||||
|
||||
uint32_t keylen = sizeof(keys);
|
||||
fsutil_read_file(CRYPTO_KEYFILE, 0, keylen, &keys, &keylen);
|
||||
|
||||
File file(CRYPTO_KEYFILE, FILE_READ, InternalFS);
|
||||
VERIFY(file, 0);
|
||||
|
||||
keylen = file.read(&keys, keylen);
|
||||
|
||||
file.close();
|
||||
|
||||
if (keys.valid0 == 0x55 && keys.valid1 == 0xAA && keys.instance == CRYPTO_INSTANCE)
|
||||
{
|
||||
@@ -156,7 +162,12 @@ void crypto_storeKeys(void)
|
||||
keys.valid0 = 0x55;
|
||||
keys.valid1 = 0xAA;
|
||||
|
||||
fsutil_write_file(CRYPTO_KEYFILE, &keys, sizeof(keys));
|
||||
File file(CRYPTO_KEYFILE, FILE_WRITE, InternalFS);
|
||||
VERIFY(file,);
|
||||
|
||||
file.write(&keys, sizeof(keys));
|
||||
|
||||
file.close();
|
||||
|
||||
// err_code = pstorage_update(&handle, (uint8_t*)&keys, sizeof(keys), 0);
|
||||
// APP_ERROR_CHECK(err_code);
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <bluefruit.h>
|
||||
#include "HAPUuid.h"
|
||||
#include "HAPPairing.h"
|
||||
#include <Nffs.h>
|
||||
#include "Bluefruit_FileIO.h"
|
||||
|
||||
#include "crypto/crypto.h"
|
||||
|
||||
@@ -159,7 +159,8 @@ err_t HAPPairing::begin(void)
|
||||
setDeviceID(mac);
|
||||
|
||||
// Init cryptography
|
||||
Nffs.mkdir_p("/adafruit/homekit");
|
||||
if ( !InternalFS.exists("/adafruit/homekit") ) InternalFS.mkdir("/adafruit/homekit");
|
||||
|
||||
crypto_init();
|
||||
|
||||
return ERROR_NONE;
|
||||
|
||||
+4
-4
@@ -12,7 +12,6 @@
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <Nffs.h>
|
||||
#include <bluefruit.h>
|
||||
#include <BLEHomekit.h>
|
||||
|
||||
@@ -126,8 +125,10 @@ void setup()
|
||||
Bluefruit.setTxPower(4);
|
||||
Bluefruit.setName("Bluefruit52");
|
||||
|
||||
//Nffs.remove(CRYPTO_KEYFILE);
|
||||
//fsutil_write_file(CRYPTO_KEYFILE, &test_keys, sizeof(test_keys));
|
||||
//InternalFS.remove(CRYPTO_KEYFILE);
|
||||
//File file(CRYPTO_KEYFILE, FILE_WRITE, InternalFS);
|
||||
//file.write(&test_keys, sizeof(test_keys));
|
||||
//file.close();
|
||||
|
||||
homekit.begin();
|
||||
|
||||
@@ -186,4 +187,3 @@ void loop()
|
||||
digitalToggle(LED_RED);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void BLECentral::_event_handler(ble_evt_t* evt)
|
||||
// Peripheral request to change connection parameter
|
||||
ble_gap_conn_params_t* request_param = &evt->evt.gap_evt.params.conn_param_update_request.conn_params;
|
||||
|
||||
LOG_LV2("GAP", "Conn Param Update Request: (min, max, lattency, sup) = (%.2f, %.2f, %d, %d)",
|
||||
LOG_LV2("GAP", "Conn Param Update Request: (min, max, latency, sup) = (%.2f, %.2f, %d, %d)",
|
||||
request_param->min_conn_interval*1.25f, request_param->max_conn_interval*1.25f, request_param->slave_latency, request_param->conn_sup_timeout*10);
|
||||
|
||||
// Central could perform checks to accept or reject request
|
||||
|
||||
@@ -58,6 +58,7 @@ class FatFS: public BluefruitFS::FileSystemClass
|
||||
bool rmdir_r (char const *filepath);
|
||||
bool format (bool eraseall);
|
||||
|
||||
// Internal API: shouldn't be used by Arduino sketch
|
||||
virtual size_t _f_write (void* fhdl, uint8_t const *buf, size_t size);
|
||||
virtual int _f_read (void* fhdl, void *buf, uint16_t nbyte);
|
||||
virtual void _f_flush (void* fhdl);
|
||||
|
||||
@@ -58,6 +58,7 @@ class LittleFS: public BluefruitFS::FileSystemClass
|
||||
bool rmdir_r (char const *filepath);
|
||||
bool format (bool eraseall);
|
||||
|
||||
// Internal API: shouldn't be used by Arduino sketch
|
||||
virtual size_t _f_write (void* fhdl, uint8_t const *buf, size_t size);
|
||||
virtual int _f_read (void* fhdl, void *buf, uint16_t nbyte);
|
||||
virtual void _f_flush (void* fhdl);
|
||||
|
||||
Reference in new issue
Block a user