|
|
|
@ -4,6 +4,7 @@ |
|
|
|
#include "lorawan/LoRaWANInterface.h" |
|
|
|
#include "lorawan/LoRaWANInterface.h" |
|
|
|
#include "lorawan/system/lorawan_data_structures.h" |
|
|
|
#include "lorawan/system/lorawan_data_structures.h" |
|
|
|
#include "mbed.h" |
|
|
|
#include "mbed.h" |
|
|
|
|
|
|
|
#include "nvstore.h" |
|
|
|
|
|
|
|
|
|
|
|
#if MBED_CONF_APP_DHT_ENABLED |
|
|
|
#if MBED_CONF_APP_DHT_ENABLED |
|
|
|
#include "DHT.h" |
|
|
|
#include "DHT.h" |
|
|
|
@ -67,6 +68,35 @@ HX711 loadcell(MBED_CONF_APP_HX711_DATA, MBED_CONF_APP_HX711_CLK); |
|
|
|
int main(void) { |
|
|
|
int main(void) { |
|
|
|
lorawan_status_t retcode; |
|
|
|
lorawan_status_t retcode; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if NVSTORE_ENABLED |
|
|
|
|
|
|
|
NVStore &nvstore = NVStore::get_instance(); |
|
|
|
|
|
|
|
int rc; |
|
|
|
|
|
|
|
uint16_t key; |
|
|
|
|
|
|
|
// Values read or written by NVStore need to be aligned to a uint32_t address (even if their sizes
|
|
|
|
|
|
|
|
// aren't)
|
|
|
|
|
|
|
|
uint32_t value; |
|
|
|
|
|
|
|
// Initialize NVstore. Note that it can be skipped, as it is lazily called by all other APIs
|
|
|
|
|
|
|
|
rc = nvstore.init(); |
|
|
|
|
|
|
|
printf("Init NVStore. \n"); |
|
|
|
|
|
|
|
// Show NVStore size, maximum number of keys and area addresses and sizes
|
|
|
|
|
|
|
|
printf("NVStore size is %d.\n", nvstore.size()); |
|
|
|
|
|
|
|
printf("NVStore max number of keys is %d (out of %d possible ones in this flash configuration).\n", |
|
|
|
|
|
|
|
nvstore.get_max_keys(), nvstore.get_max_possible_keys()); |
|
|
|
|
|
|
|
printf("NVStore areas:\n"); |
|
|
|
|
|
|
|
for (uint8_t area = 0; area < NVSTORE_NUM_AREAS; area++) { |
|
|
|
|
|
|
|
uint32_t area_address; |
|
|
|
|
|
|
|
size_t area_size; |
|
|
|
|
|
|
|
nvstore.get_area_params(area, area_address, area_size); |
|
|
|
|
|
|
|
printf("Area %d: address 0x%08lx, size %d (0x%x).\n", area, area_address, area_size, area_size); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
printf("NVStore is disabled for this board\n"); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(1) { |
|
|
|
|
|
|
|
wait(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if MBED_CONF_APP_HX711_ENABLED |
|
|
|
#if MBED_CONF_APP_HX711_ENABLED |
|
|
|
loadcell.powerDown(); |
|
|
|
loadcell.powerDown(); |
|
|
|
loadcell.setScale(MBED_CONF_APP_HX711_SCALE); |
|
|
|
loadcell.setScale(MBED_CONF_APP_HX711_SCALE); |
|
|
|
|