Thanh Nguyen
/
Alarm3Sensors_240220
no
Revision 33:63c42cbe3459, committed 2020-02-24
- Comitter:
- hnript
- Date:
- Mon Feb 24 07:38:20 2020 +0000
- Parent:
- 32:febff0fd3195
- Commit message:
- ver1
Changed in this revision
diff -r febff0fd3195 -r 63c42cbe3459 examples/example_config.h --- a/examples/example_config.h Thu Sep 13 15:32:55 2018 -0500 +++ b/examples/example_config.h Mon Feb 24 07:38:20 2020 +0000 @@ -1,6 +1,7 @@ #ifndef __EXAMPLE__CONFIG_H__ #define __EXAMPLE__CONFIG_H__ +#define AMR_NTN 0 // see amr.cpp #define OTA_EXAMPLE 1 // see ota_example.cpp #define AUTO_OTA_EXAMPLE 2 // see auto_ota_example.cpp #define MANUAL_EXAMPLE 3 // see manual_example.cpp @@ -9,7 +10,8 @@ // the active example is the one that will be compiled #if !defined(ACTIVE_EXAMPLE) -#define ACTIVE_EXAMPLE OTA_EXAMPLE +#define ACTIVE_EXAMPLE AMR_NTN +//#define ACTIVE_EXAMPLE MANUAL_EXAMPLE #endif // the active channel plan is the one that will be compiled @@ -21,8 +23,9 @@ // CP_AS923 // CP_AS923_JAPAN // CP_IN865 +// CP_VN919 #if !defined(CHANNEL_PLAN) -#define CHANNEL_PLAN CP_US915 +#define CHANNEL_PLAN CP_VN919 #endif #endif
diff -r febff0fd3195 -r 63c42cbe3459 examples/src/amr.cpp
diff -r febff0fd3195 -r 63c42cbe3459 examples/src/arm.h
diff -r febff0fd3195 -r 63c42cbe3459 examples/src/dot_util.cpp --- a/examples/src/dot_util.cpp Thu Sep 13 15:32:55 2018 -0500 +++ b/examples/src/dot_util.cpp Mon Feb 24 07:38:20 2020 +0000 @@ -408,8 +408,8 @@ // in some frequency bands we need to wait until another channel is available before transmitting again // wait at least 10s between transmissions uint32_t delay_s = dot->getNextTxMs() / 1000; - if (delay_s < 10) { - delay_s = 10; + if (delay_s < 60) { + delay_s = 60; // min sleep time } #if defined (TARGET_XDOT_L151CC)
diff -r febff0fd3195 -r 63c42cbe3459 examples/src/manual_example.cpp --- a/examples/src/manual_example.cpp Thu Sep 13 15:32:55 2018 -0500 +++ b/examples/src/manual_example.cpp Mon Feb 24 07:38:20 2020 +0000 @@ -1,5 +1,6 @@ #include "dot_util.h" #include "RadioEvent.h" +//#include "SOFBlock.h" #if ACTIVE_EXAMPLE == MANUAL_EXAMPLE @@ -14,6 +15,7 @@ // * https://developer.mbed.org/teams/MultiTech/code/libxDot-dev-mbed5/ // // * https://developer.mbed.org/teams/MultiTech/code/libxDot-mbed5/ // ///////////////////////////////////////////////////////////////////////////// +void testWriteFlash(); ///////////////////////////////////////////////////////////// // * these options must match the settings on your gateway // @@ -58,6 +60,9 @@ #endif mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); + + //@@@@@@@@@@@@@@@@@@@@@@ + testWriteFlash(); #if CHANNEL_PLAN == CP_US915 plan = new lora::ChannelPlan_US915(); @@ -73,6 +78,8 @@ plan = new lora::ChannelPlan_AS923_Japan(); #elif CHANNEL_PLAN == CP_IN865 plan = new lora::ChannelPlan_IN865(); +#elif CHANNEL_PLAN == CP_XX919 + plan = new lora::ChannelPlan_XX919(); #endif assert(plan); @@ -178,4 +185,72 @@ return 0; } -#endif +uint32_t rtc_read_backup_reg(uint32_t BackupRegister) { + RTC_HandleTypeDef RtcHandle; + RtcHandle.Instance = RTC; + return HAL_RTCEx_BKUPRead(&RtcHandle, BackupRegister); +} + +void rtc_write_backup_reg(uint32_t BackupRegister, uint32_t data) { + RTC_HandleTypeDef RtcHandle; + RtcHandle.Instance = RTC; + HAL_PWR_EnableBkUpAccess(); + HAL_RTCEx_BKUPWrite(&RtcHandle, BackupRegister, data); + HAL_PWR_DisableBkUpAccess(); +} + +void testWriteFlash() { + + logError("@@@@@@@@@@@@ HELLO @@@@@@@@@@@@"); + const uint8_t sector_index = 7; + + SOFWriter writer; + SOFReader reader; + + reader.open(sector_index); + uint8_t bootNum; + uint8_t size = reader.get_data_size(); + if (size == 0) { + logTrace("@@@ NO DATA\r\n"); + SOFBlock::format(sector_index); // Erase flash sector 7 and make structure for storage. + logTrace("@@@ FORMAT SECTOR\r\n"); + bootNum = 1; + } + else { + reader.read_byte_data(&bootNum); + if (bootNum == 0) { + logTrace("@@@ data %d bytes of value %d :\r\n", size, bootNum++); + SOFBlock::format(sector_index); // Erase flash sector 7 and make structure for storage. + logTrace("@@@ FORMAT SECTOR\r\n"); + } + else { + logTrace("@@@ data %d bytes at %p :\r\n", size, bootNum++); + } + } +// printf("data %d bytes at %p :\r\n", reader.get_data_size(), reader.get_physical_base_addr()); +// printf("%.*s\r\n", reader.get_data_size(), reader.get_physical_base_addr()); + reader.close(); + + writer.open(sector_index); +// writer.write_data(&bootNum, 1); + writer.close(); + + + // SOF_Statics_t statics; + // if (!SOFBlock(sector_index, statics) || statics.free_size < 11) { // check available byte + // SOFBlock::format(sector_index); + // } + // writer.open(sector_index); + // // Overwrite previous data without erasing flash. + // writer.write_data((uint8_t*)"Second Data", 11); + // writer.close(); + // + // reader.open(sector_index); + // printf("data %d bytes at %p :\r\n", reader.get_data_size(), reader.get_physical_base_addr()); + // printf("%.*s\r\n", reader.get_data_size(), reader.get_physical_base_addr()); + // // "Second Data" printed + // reader.close(); + //} +} + +#endif \ No newline at end of file
diff -r febff0fd3195 -r 63c42cbe3459 examples/src/ota_example.cpp --- a/examples/src/ota_example.cpp Thu Sep 13 15:32:55 2018 -0500 +++ b/examples/src/ota_example.cpp Mon Feb 24 07:38:20 2020 +0000 @@ -22,10 +22,14 @@ // * either the network name and passphrase can be used or // // the network ID (8 bytes) and KEY (16 bytes) // ///////////////////////////////////////////////////////////// -static std::string network_name = "MultiTech"; -static std::string network_passphrase = "MultiTech"; -static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 }; -static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B }; +//static std::string network_name = "MultiTech"; +//static std::string network_passphrase = "MultiTech"; +//static uint8_t network_id[] = { 0x6C, 0x4E, 0xEF, 0x66, 0xF4, 0x79, 0x86, 0xA6 }; +//static uint8_t network_key[] = { 0x1F, 0x33, 0xA1, 0x70, 0xA5, 0xF1, 0xFD, 0xA0, 0xAB, 0x69, 0x7A, 0xAE, 0x2B, 0x95, 0x91, 0x6B }; +static std::string network_name = ""; +static std::string network_passphrase = ""; +static uint8_t network_id[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC }; +static uint8_t network_key[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC }; static uint8_t frequency_sub_band = 0; static lora::NetworkType network_type = lora::PUBLIC_LORAWAN; static uint8_t join_delay = 5; @@ -61,6 +65,7 @@ #endif mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); + logDebug("START..................................... "); #if CHANNEL_PLAN == CP_US915 plan = new lora::ChannelPlan_US915(); @@ -76,6 +81,8 @@ plan = new lora::ChannelPlan_AS923_Japan(); #elif CHANNEL_PLAN == CP_IN865 plan = new lora::ChannelPlan_IN865(); +#elif CHANNEL_PLAN == CP_XX919 + plan = new lora::ChannelPlan_VN919(); #endif assert(plan); @@ -107,8 +114,8 @@ // only one method or the other should be used! // network ID = crc64(network name) // network KEY = cmac(network passphrase) - update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, network_type, ack); - //update_ota_config_id_key(network_id, network_key, frequency_sub_band, network_type, ack); + // update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, network_type, ack); + update_ota_config_id_key(network_id, network_key, frequency_sub_band, network_type, ack); // configure network link checks // network link checks are a good alternative to requiring the gateway to ACK every packet and should allow a single gateway to handle more Dots
diff -r febff0fd3195 -r 63c42cbe3459 libmDot-dev-mbed5.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmDot-dev-mbed5.lib Mon Feb 24 07:38:20 2020 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/teams/MultiTech/code/libmDot-dev-mbed5/#960b4e7df69d
diff -r febff0fd3195 -r 63c42cbe3459 setup.sh