Full functions
Dependencies: DHT22 libmDot-mbed5
Fork of mDot_LoRa_Connect_ABPA by
Diff: main.cpp
- Revision:
- 5:6b988a804fcb
- Parent:
- 4:36e214ebfa56
- Child:
- 7:e29228e39982
--- a/main.cpp Wed Sep 30 19:49:02 2015 +0000 +++ b/main.cpp Tue Mar 29 13:41:12 2016 +0000 @@ -7,9 +7,10 @@ // these options must match the settings on your Conduit // uncomment the following lines and edit their values to match your configuration -//static std::string config_network_name = "<lora network id>"; -//static std::string config_network_pass = "<lora network key>"; -//static uint8_t config_frequency_sub_band = 1; +static uint8_t config_network_addr[] = { 0x01, 0x02, 0x03, 0x04 }; +static uint8_t config_network_nskey[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 }; +static uint8_t config_network_dskey[] = { 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04 }; +static uint8_t config_frequency_sub_band = 1; int main() { int32_t ret; @@ -42,13 +43,34 @@ logError("failed to set frequency sub band %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } - logInfo("setting network name"); - if ((ret = dot->setNetworkName(config_network_name)) != mDot::MDOT_OK) { + std::vector<uint8_t> temp; + + for (int i = 0; i < 4; i++) { + temp.push_back(config_network_addr[i]); + } + + logInfo("setting network addr"); + if ((ret = dot->setNetworkAddress(temp)) != mDot::MDOT_OK) { logError("failed to set network name %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); } + temp.clear(); + for (int i = 0; i < 16; i++) { + temp.push_back(config_network_nskey[i]); + } + logInfo("setting network password"); - if ((ret = dot->setNetworkPassphrase(config_network_pass)) != mDot::MDOT_OK) { + if ((ret = dot->setNetworkSessionKey(temp)) != mDot::MDOT_OK) { + logError("failed to set network password %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); + } + + temp.clear(); + for (int i = 0; i < 16; i++) { + temp.push_back(config_network_dskey[i]); + } + + logInfo("setting network password"); + if ((ret = dot->setDataSessionKey(temp)) != mDot::MDOT_OK) { logError("failed to set network password %d:%s", ret, mDot::getReturnCodeString(ret).c_str()); }