Test program for FF1705.

Dependencies:   libxDot-dev-mbed5-deprecated ISL29011

Committer:
jernej_vrscaj
Date:
Thu Nov 09 07:18:24 2017 +0000
Revision:
2:9b44950b84af
Parent:
0:d96e7e513c16
Small correction in printf message.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jernej_vrscaj 0:d96e7e513c16 1 #include "dot_util.h"
jernej_vrscaj 0:d96e7e513c16 2 #if defined(TARGET_XDOT_L151CC)
jernej_vrscaj 0:d96e7e513c16 3 #include "xdot_low_power.h"
jernej_vrscaj 0:d96e7e513c16 4 #endif
jernej_vrscaj 0:d96e7e513c16 5
jernej_vrscaj 0:d96e7e513c16 6 #if defined(TARGET_MTS_MDOT_F411RE)
jernej_vrscaj 0:d96e7e513c16 7 uint32_t portA[6];
jernej_vrscaj 0:d96e7e513c16 8 uint32_t portB[6];
jernej_vrscaj 0:d96e7e513c16 9 uint32_t portC[6];
jernej_vrscaj 0:d96e7e513c16 10 uint32_t portD[6];
jernej_vrscaj 0:d96e7e513c16 11 uint32_t portH[6];
jernej_vrscaj 0:d96e7e513c16 12 #endif
jernej_vrscaj 0:d96e7e513c16 13
jernej_vrscaj 0:d96e7e513c16 14
jernej_vrscaj 0:d96e7e513c16 15 void display_config() {
jernej_vrscaj 0:d96e7e513c16 16 // display configuration and library version information
jernej_vrscaj 0:d96e7e513c16 17 logInfo("=====================");
jernej_vrscaj 0:d96e7e513c16 18 logInfo("general configuration");
jernej_vrscaj 0:d96e7e513c16 19 logInfo("=====================");
jernej_vrscaj 0:d96e7e513c16 20 logInfo("version ------------------ %s", dot->getId().c_str());
jernej_vrscaj 0:d96e7e513c16 21 logInfo("device ID/EUI ------------ %s", mts::Text::bin2hexString(dot->getDeviceId()).c_str());
jernej_vrscaj 0:d96e7e513c16 22 logInfo("default channel plan ----- %s", mDot::FrequencyBandStr(dot->getDefaultFrequencyBand()).c_str());
jernej_vrscaj 0:d96e7e513c16 23 logInfo("current channel plan ----- %s", mDot::FrequencyBandStr(dot->getFrequencyBand()).c_str());
jernej_vrscaj 0:d96e7e513c16 24 if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) {
jernej_vrscaj 0:d96e7e513c16 25 logInfo("frequency sub band ------- %u", dot->getFrequencySubBand());
jernej_vrscaj 0:d96e7e513c16 26 }
jernej_vrscaj 0:d96e7e513c16 27 logInfo("public network ----------- %s", dot->getPublicNetwork() ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 28 logInfo("=========================");
jernej_vrscaj 0:d96e7e513c16 29 logInfo("credentials configuration");
jernej_vrscaj 0:d96e7e513c16 30 logInfo("=========================");
jernej_vrscaj 0:d96e7e513c16 31 logInfo("device class ------------- %s", dot->getClass().c_str());
jernej_vrscaj 0:d96e7e513c16 32 logInfo("network join mode -------- %s", mDot::JoinModeStr(dot->getJoinMode()).c_str());
jernej_vrscaj 0:d96e7e513c16 33 if (dot->getJoinMode() == mDot::MANUAL || dot->getJoinMode() == mDot::PEER_TO_PEER) {
jernej_vrscaj 0:d96e7e513c16 34 logInfo("network address ---------- %s", mts::Text::bin2hexString(dot->getNetworkAddress()).c_str());
jernej_vrscaj 0:d96e7e513c16 35 logInfo("network session key------- %s", mts::Text::bin2hexString(dot->getNetworkSessionKey()).c_str());
jernej_vrscaj 0:d96e7e513c16 36 logInfo("data session key---------- %s", mts::Text::bin2hexString(dot->getDataSessionKey()).c_str());
jernej_vrscaj 0:d96e7e513c16 37 } else {
jernej_vrscaj 0:d96e7e513c16 38 logInfo("network name ------------- %s", dot->getNetworkName().c_str());
jernej_vrscaj 0:d96e7e513c16 39 logInfo("network phrase ----------- %s", dot->getNetworkPassphrase().c_str());
jernej_vrscaj 0:d96e7e513c16 40 logInfo("network EUI -------------- %s", mts::Text::bin2hexString(dot->getNetworkId()).c_str());
jernej_vrscaj 0:d96e7e513c16 41 logInfo("network KEY -------------- %s", mts::Text::bin2hexString(dot->getNetworkKey()).c_str());
jernej_vrscaj 0:d96e7e513c16 42 }
jernej_vrscaj 0:d96e7e513c16 43 logInfo("========================");
jernej_vrscaj 0:d96e7e513c16 44 logInfo("communication parameters");
jernej_vrscaj 0:d96e7e513c16 45 logInfo("========================");
jernej_vrscaj 0:d96e7e513c16 46 if (dot->getJoinMode() == mDot::PEER_TO_PEER) {
jernej_vrscaj 0:d96e7e513c16 47 logInfo("TX frequency ------------- %lu", dot->getTxFrequency());
jernej_vrscaj 0:d96e7e513c16 48 } else {
jernej_vrscaj 0:d96e7e513c16 49 logInfo("acks --------------------- %s, %u attempts", dot->getAck() > 0 ? "on" : "off", dot->getAck());
jernej_vrscaj 0:d96e7e513c16 50 }
jernej_vrscaj 0:d96e7e513c16 51 logInfo("TX datarate -------------- %s", mDot::DataRateStr(dot->getTxDataRate()).c_str());
jernej_vrscaj 0:d96e7e513c16 52 logInfo("TX power ----------------- %lu dBm", dot->getTxPower());
jernej_vrscaj 0:d96e7e513c16 53 logInfo("antenna gain ------------- %u dBm", dot->getAntennaGain());
jernej_vrscaj 0:d96e7e513c16 54 logInfo("LBT ---------------------- %s", dot->getLbtTimeUs() ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 55 if (dot->getLbtTimeUs()) {
jernej_vrscaj 0:d96e7e513c16 56 logInfo("LBT time ----------------- %lu us", dot->getLbtTimeUs());
jernej_vrscaj 0:d96e7e513c16 57 logInfo("LBT threshold ------------ %d dBm", dot->getLbtThreshold());
jernej_vrscaj 0:d96e7e513c16 58 }
jernej_vrscaj 0:d96e7e513c16 59 }
jernej_vrscaj 0:d96e7e513c16 60
jernej_vrscaj 0:d96e7e513c16 61 void update_ota_config_name_phrase(std::string network_name, std::string network_passphrase, uint8_t frequency_sub_band, bool public_network, uint8_t ack) {
jernej_vrscaj 0:d96e7e513c16 62 std::string current_network_name = dot->getNetworkName();
jernej_vrscaj 0:d96e7e513c16 63 std::string current_network_passphrase = dot->getNetworkPassphrase();
jernej_vrscaj 0:d96e7e513c16 64 uint8_t current_frequency_sub_band = dot->getFrequencySubBand();
jernej_vrscaj 0:d96e7e513c16 65 bool current_public_network = dot->getPublicNetwork();
jernej_vrscaj 0:d96e7e513c16 66 uint8_t current_ack = dot->getAck();
jernej_vrscaj 0:d96e7e513c16 67
jernej_vrscaj 0:d96e7e513c16 68 if (current_network_name != network_name) {
jernej_vrscaj 0:d96e7e513c16 69 logInfo("changing network name from \"%s\" to \"%s\"", current_network_name.c_str(), network_name.c_str());
jernej_vrscaj 0:d96e7e513c16 70 if (dot->setNetworkName(network_name) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 71 logError("failed to set network name to \"%s\"", network_name.c_str());
jernej_vrscaj 0:d96e7e513c16 72 }
jernej_vrscaj 0:d96e7e513c16 73 }
jernej_vrscaj 0:d96e7e513c16 74
jernej_vrscaj 0:d96e7e513c16 75 if (current_network_passphrase != network_passphrase) {
jernej_vrscaj 0:d96e7e513c16 76 logInfo("changing network passphrase from \"%s\" to \"%s\"", current_network_passphrase.c_str(), network_passphrase.c_str());
jernej_vrscaj 0:d96e7e513c16 77 if (dot->setNetworkPassphrase(network_passphrase) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 78 logError("failed to set network passphrase to \"%s\"", network_passphrase.c_str());
jernej_vrscaj 0:d96e7e513c16 79 }
jernej_vrscaj 0:d96e7e513c16 80 }
jernej_vrscaj 0:d96e7e513c16 81
jernej_vrscaj 0:d96e7e513c16 82 if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) {
jernej_vrscaj 0:d96e7e513c16 83 if (current_frequency_sub_band != frequency_sub_band) {
jernej_vrscaj 0:d96e7e513c16 84 logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band);
jernej_vrscaj 0:d96e7e513c16 85 if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 86 logError("failed to set frequency sub band to %u", frequency_sub_band);
jernej_vrscaj 0:d96e7e513c16 87 }
jernej_vrscaj 0:d96e7e513c16 88 }
jernej_vrscaj 0:d96e7e513c16 89 }
jernej_vrscaj 0:d96e7e513c16 90
jernej_vrscaj 0:d96e7e513c16 91 if (current_public_network != public_network) {
jernej_vrscaj 0:d96e7e513c16 92 logInfo("changing public network from %s to %s", current_public_network ? "on" : "off", public_network ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 93 if (dot->setPublicNetwork(public_network) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 94 logError("failed to set public network to %s", public_network ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 95 }
jernej_vrscaj 0:d96e7e513c16 96 }
jernej_vrscaj 0:d96e7e513c16 97
jernej_vrscaj 0:d96e7e513c16 98 if (current_ack != ack) {
jernej_vrscaj 0:d96e7e513c16 99 logInfo("changing acks from %u to %u", current_ack, ack);
jernej_vrscaj 0:d96e7e513c16 100 if (dot->setAck(ack) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 101 logError("failed to set acks to %u", ack);
jernej_vrscaj 0:d96e7e513c16 102 }
jernej_vrscaj 0:d96e7e513c16 103 }
jernej_vrscaj 0:d96e7e513c16 104 }
jernej_vrscaj 0:d96e7e513c16 105
jernej_vrscaj 0:d96e7e513c16 106 void update_ota_config_id_key(uint8_t *network_id, uint8_t *network_key, uint8_t frequency_sub_band, bool public_network, uint8_t ack) {
jernej_vrscaj 0:d96e7e513c16 107 std::vector<uint8_t> current_network_id = dot->getNetworkId();
jernej_vrscaj 0:d96e7e513c16 108 std::vector<uint8_t> current_network_key = dot->getNetworkKey();
jernej_vrscaj 0:d96e7e513c16 109 uint8_t current_frequency_sub_band = dot->getFrequencySubBand();
jernej_vrscaj 0:d96e7e513c16 110 bool current_public_network = dot->getPublicNetwork();
jernej_vrscaj 0:d96e7e513c16 111 uint8_t current_ack = dot->getAck();
jernej_vrscaj 0:d96e7e513c16 112
jernej_vrscaj 0:d96e7e513c16 113 std::vector<uint8_t> network_id_vector(network_id, network_id + 8);
jernej_vrscaj 0:d96e7e513c16 114 std::vector<uint8_t> network_key_vector(network_key, network_key + 16);
jernej_vrscaj 0:d96e7e513c16 115
jernej_vrscaj 0:d96e7e513c16 116 if (current_network_id != network_id_vector) {
jernej_vrscaj 0:d96e7e513c16 117 logInfo("changing network ID from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_network_id).c_str(), mts::Text::bin2hexString(network_id_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 118 if (dot->setNetworkId(network_id_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 119 logError("failed to set network ID to \"%s\"", mts::Text::bin2hexString(network_id_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 120 }
jernej_vrscaj 0:d96e7e513c16 121 }
jernej_vrscaj 0:d96e7e513c16 122
jernej_vrscaj 0:d96e7e513c16 123 if (current_network_key != network_key_vector) {
jernej_vrscaj 0:d96e7e513c16 124 logInfo("changing network KEY from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_network_key).c_str(), mts::Text::bin2hexString(network_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 125 if (dot->setNetworkKey(network_key_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 126 logError("failed to set network KEY to \"%s\"", mts::Text::bin2hexString(network_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 127 }
jernej_vrscaj 0:d96e7e513c16 128 }
jernej_vrscaj 0:d96e7e513c16 129
jernej_vrscaj 0:d96e7e513c16 130 if (lora::ChannelPlan::IsPlanFixed(dot->getFrequencyBand())) {
jernej_vrscaj 0:d96e7e513c16 131 if (current_frequency_sub_band != frequency_sub_band) {
jernej_vrscaj 0:d96e7e513c16 132 logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band);
jernej_vrscaj 0:d96e7e513c16 133 if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 134 logError("failed to set frequency sub band to %u", frequency_sub_band);
jernej_vrscaj 0:d96e7e513c16 135 }
jernej_vrscaj 0:d96e7e513c16 136 }
jernej_vrscaj 0:d96e7e513c16 137 }
jernej_vrscaj 0:d96e7e513c16 138
jernej_vrscaj 0:d96e7e513c16 139 if (current_public_network != public_network) {
jernej_vrscaj 0:d96e7e513c16 140 logInfo("changing public network from %s to %s", current_public_network ? "on" : "off", public_network ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 141 if (dot->setPublicNetwork(public_network) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 142 logError("failed to set public network to %s", public_network ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 143 }
jernej_vrscaj 0:d96e7e513c16 144 }
jernej_vrscaj 0:d96e7e513c16 145
jernej_vrscaj 0:d96e7e513c16 146 if (current_ack != ack) {
jernej_vrscaj 0:d96e7e513c16 147 logInfo("changing acks from %u to %u", current_ack, ack);
jernej_vrscaj 0:d96e7e513c16 148 if (dot->setAck(ack) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 149 logError("failed to set acks to %u", ack);
jernej_vrscaj 0:d96e7e513c16 150 }
jernej_vrscaj 0:d96e7e513c16 151 }
jernej_vrscaj 0:d96e7e513c16 152 }
jernej_vrscaj 0:d96e7e513c16 153
jernej_vrscaj 0:d96e7e513c16 154 void update_manual_config(uint8_t *network_address, uint8_t *network_session_key, uint8_t *data_session_key, uint8_t frequency_sub_band, bool public_network, uint8_t ack) {
jernej_vrscaj 0:d96e7e513c16 155 std::vector<uint8_t> current_network_address = dot->getNetworkAddress();
jernej_vrscaj 0:d96e7e513c16 156 std::vector<uint8_t> current_network_session_key = dot->getNetworkSessionKey();
jernej_vrscaj 0:d96e7e513c16 157 std::vector<uint8_t> current_data_session_key = dot->getDataSessionKey();
jernej_vrscaj 0:d96e7e513c16 158 uint8_t current_frequency_sub_band = dot->getFrequencySubBand();
jernej_vrscaj 0:d96e7e513c16 159 bool current_public_network = dot->getPublicNetwork();
jernej_vrscaj 0:d96e7e513c16 160 uint8_t current_ack = dot->getAck();
jernej_vrscaj 0:d96e7e513c16 161
jernej_vrscaj 0:d96e7e513c16 162 std::vector<uint8_t> network_address_vector(network_address, network_address + 4);
jernej_vrscaj 0:d96e7e513c16 163 std::vector<uint8_t> network_session_key_vector(network_session_key, network_session_key + 16);
jernej_vrscaj 0:d96e7e513c16 164 std::vector<uint8_t> data_session_key_vector(data_session_key, data_session_key + 16);
jernej_vrscaj 0:d96e7e513c16 165
jernej_vrscaj 0:d96e7e513c16 166 if (current_network_address != network_address_vector) {
jernej_vrscaj 0:d96e7e513c16 167 logInfo("changing network address from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_network_address).c_str(), mts::Text::bin2hexString(network_address_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 168 if (dot->setNetworkAddress(network_address_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 169 logError("failed to set network address to \"%s\"", mts::Text::bin2hexString(network_address_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 170 }
jernej_vrscaj 0:d96e7e513c16 171 }
jernej_vrscaj 0:d96e7e513c16 172
jernej_vrscaj 0:d96e7e513c16 173 if (current_network_session_key != network_session_key_vector) {
jernej_vrscaj 0:d96e7e513c16 174 logInfo("changing network session key from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_network_session_key).c_str(), mts::Text::bin2hexString(network_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 175 if (dot->setNetworkSessionKey(network_session_key_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 176 logError("failed to set network session key to \"%s\"", mts::Text::bin2hexString(network_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 177 }
jernej_vrscaj 0:d96e7e513c16 178 }
jernej_vrscaj 0:d96e7e513c16 179
jernej_vrscaj 0:d96e7e513c16 180 if (current_data_session_key != data_session_key_vector) {
jernej_vrscaj 0:d96e7e513c16 181 logInfo("changing data session key from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_data_session_key).c_str(), mts::Text::bin2hexString(data_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 182 if (dot->setDataSessionKey(data_session_key_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 183 logError("failed to set data session key to \"%s\"", mts::Text::bin2hexString(data_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 184 }
jernej_vrscaj 0:d96e7e513c16 185 }
jernej_vrscaj 0:d96e7e513c16 186
jernej_vrscaj 0:d96e7e513c16 187 if (current_frequency_sub_band != frequency_sub_band) {
jernej_vrscaj 0:d96e7e513c16 188 logInfo("changing frequency sub band from %u to %u", current_frequency_sub_band, frequency_sub_band);
jernej_vrscaj 0:d96e7e513c16 189 if (dot->setFrequencySubBand(frequency_sub_band) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 190 logError("failed to set frequency sub band to %u", frequency_sub_band);
jernej_vrscaj 0:d96e7e513c16 191 }
jernej_vrscaj 0:d96e7e513c16 192 }
jernej_vrscaj 0:d96e7e513c16 193
jernej_vrscaj 0:d96e7e513c16 194 if (current_public_network != public_network) {
jernej_vrscaj 0:d96e7e513c16 195 logInfo("changing public network from %s to %s", current_public_network ? "on" : "off", public_network ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 196 if (dot->setPublicNetwork(public_network) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 197 logError("failed to set public network to %s", public_network ? "on" : "off");
jernej_vrscaj 0:d96e7e513c16 198 }
jernej_vrscaj 0:d96e7e513c16 199 }
jernej_vrscaj 0:d96e7e513c16 200
jernej_vrscaj 0:d96e7e513c16 201 if (current_ack != ack) {
jernej_vrscaj 0:d96e7e513c16 202 logInfo("changing acks from %u to %u", current_ack, ack);
jernej_vrscaj 0:d96e7e513c16 203 if (dot->setAck(ack) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 204 logError("failed to set acks to %u", ack);
jernej_vrscaj 0:d96e7e513c16 205 }
jernej_vrscaj 0:d96e7e513c16 206 }
jernej_vrscaj 0:d96e7e513c16 207 }
jernej_vrscaj 0:d96e7e513c16 208
jernej_vrscaj 0:d96e7e513c16 209 void update_peer_to_peer_config(uint8_t *network_address, uint8_t *network_session_key, uint8_t *data_session_key, uint32_t tx_frequency, uint8_t tx_datarate, uint8_t tx_power) {
jernej_vrscaj 0:d96e7e513c16 210 std::vector<uint8_t> current_network_address = dot->getNetworkAddress();
jernej_vrscaj 0:d96e7e513c16 211 std::vector<uint8_t> current_network_session_key = dot->getNetworkSessionKey();
jernej_vrscaj 0:d96e7e513c16 212 std::vector<uint8_t> current_data_session_key = dot->getDataSessionKey();
jernej_vrscaj 0:d96e7e513c16 213 uint32_t current_tx_frequency = dot->getTxFrequency();
jernej_vrscaj 0:d96e7e513c16 214 uint8_t current_tx_datarate = dot->getTxDataRate();
jernej_vrscaj 0:d96e7e513c16 215 uint8_t current_tx_power = dot->getTxPower();
jernej_vrscaj 0:d96e7e513c16 216
jernej_vrscaj 0:d96e7e513c16 217 std::vector<uint8_t> network_address_vector(network_address, network_address + 4);
jernej_vrscaj 0:d96e7e513c16 218 std::vector<uint8_t> network_session_key_vector(network_session_key, network_session_key + 16);
jernej_vrscaj 0:d96e7e513c16 219 std::vector<uint8_t> data_session_key_vector(data_session_key, data_session_key + 16);
jernej_vrscaj 0:d96e7e513c16 220
jernej_vrscaj 0:d96e7e513c16 221 if (current_network_address != network_address_vector) {
jernej_vrscaj 0:d96e7e513c16 222 logInfo("changing network address from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_network_address).c_str(), mts::Text::bin2hexString(network_address_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 223 if (dot->setNetworkAddress(network_address_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 224 logError("failed to set network address to \"%s\"", mts::Text::bin2hexString(network_address_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 225 }
jernej_vrscaj 0:d96e7e513c16 226 }
jernej_vrscaj 0:d96e7e513c16 227
jernej_vrscaj 0:d96e7e513c16 228 if (current_network_session_key != network_session_key_vector) {
jernej_vrscaj 0:d96e7e513c16 229 logInfo("changing network session key from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_network_session_key).c_str(), mts::Text::bin2hexString(network_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 230 if (dot->setNetworkSessionKey(network_session_key_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 231 logError("failed to set network session key to \"%s\"", mts::Text::bin2hexString(network_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 232 }
jernej_vrscaj 0:d96e7e513c16 233 }
jernej_vrscaj 0:d96e7e513c16 234
jernej_vrscaj 0:d96e7e513c16 235 if (current_data_session_key != data_session_key_vector) {
jernej_vrscaj 0:d96e7e513c16 236 logInfo("changing data session key from \"%s\" to \"%s\"", mts::Text::bin2hexString(current_data_session_key).c_str(), mts::Text::bin2hexString(data_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 237 if (dot->setDataSessionKey(data_session_key_vector) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 238 logError("failed to set data session key to \"%s\"", mts::Text::bin2hexString(data_session_key_vector).c_str());
jernej_vrscaj 0:d96e7e513c16 239 }
jernej_vrscaj 0:d96e7e513c16 240 }
jernej_vrscaj 0:d96e7e513c16 241
jernej_vrscaj 0:d96e7e513c16 242 if (current_tx_frequency != tx_frequency) {
jernej_vrscaj 0:d96e7e513c16 243 logInfo("changing TX frequency from %lu to %lu", current_tx_frequency, tx_frequency);
jernej_vrscaj 0:d96e7e513c16 244 if (dot->setTxFrequency(tx_frequency) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 245 logError("failed to set TX frequency to %lu", tx_frequency);
jernej_vrscaj 0:d96e7e513c16 246 }
jernej_vrscaj 0:d96e7e513c16 247 }
jernej_vrscaj 0:d96e7e513c16 248
jernej_vrscaj 0:d96e7e513c16 249 if (current_tx_datarate != tx_datarate) {
jernej_vrscaj 0:d96e7e513c16 250 logInfo("changing TX datarate from %u to %u", current_tx_datarate, tx_datarate);
jernej_vrscaj 0:d96e7e513c16 251 if (dot->setTxDataRate(tx_datarate) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 252 logError("failed to set TX datarate to %u", tx_datarate);
jernej_vrscaj 0:d96e7e513c16 253 }
jernej_vrscaj 0:d96e7e513c16 254 }
jernej_vrscaj 0:d96e7e513c16 255
jernej_vrscaj 0:d96e7e513c16 256 if (current_tx_power != tx_power) {
jernej_vrscaj 0:d96e7e513c16 257 logInfo("changing TX power from %u to %u", current_tx_power, tx_power);
jernej_vrscaj 0:d96e7e513c16 258 if (dot->setTxPower(tx_power) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 259 logError("failed to set TX power to %u", tx_power);
jernej_vrscaj 0:d96e7e513c16 260 }
jernej_vrscaj 0:d96e7e513c16 261 }
jernej_vrscaj 0:d96e7e513c16 262 }
jernej_vrscaj 0:d96e7e513c16 263
jernej_vrscaj 0:d96e7e513c16 264 void update_network_link_check_config(uint8_t link_check_count, uint8_t link_check_threshold) {
jernej_vrscaj 0:d96e7e513c16 265 uint8_t current_link_check_count = dot->getLinkCheckCount();
jernej_vrscaj 0:d96e7e513c16 266 uint8_t current_link_check_threshold = dot->getLinkCheckThreshold();
jernej_vrscaj 0:d96e7e513c16 267
jernej_vrscaj 0:d96e7e513c16 268 if (current_link_check_count != link_check_count) {
jernej_vrscaj 0:d96e7e513c16 269 logInfo("changing link check count from %u to %u", current_link_check_count, link_check_count);
jernej_vrscaj 0:d96e7e513c16 270 if (dot->setLinkCheckCount(link_check_count) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 271 logError("failed to set link check count to %u", link_check_count);
jernej_vrscaj 0:d96e7e513c16 272 }
jernej_vrscaj 0:d96e7e513c16 273 }
jernej_vrscaj 0:d96e7e513c16 274
jernej_vrscaj 0:d96e7e513c16 275 if (current_link_check_threshold != link_check_threshold) {
jernej_vrscaj 0:d96e7e513c16 276 logInfo("changing link check threshold from %u to %u", current_link_check_threshold, link_check_threshold);
jernej_vrscaj 0:d96e7e513c16 277 if (dot->setLinkCheckThreshold(link_check_threshold) != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 278 logError("failed to set link check threshold to %u", link_check_threshold);
jernej_vrscaj 0:d96e7e513c16 279 }
jernej_vrscaj 0:d96e7e513c16 280 }
jernej_vrscaj 0:d96e7e513c16 281 }
jernej_vrscaj 0:d96e7e513c16 282
jernej_vrscaj 0:d96e7e513c16 283 void join_network() {
jernej_vrscaj 0:d96e7e513c16 284 int32_t j_attempts = 0;
jernej_vrscaj 0:d96e7e513c16 285 int32_t ret = mDot::MDOT_ERROR;
jernej_vrscaj 0:d96e7e513c16 286
jernej_vrscaj 0:d96e7e513c16 287 // attempt to join the network
jernej_vrscaj 0:d96e7e513c16 288 while (ret != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 289 logInfo("attempt %d to join network", ++j_attempts);
jernej_vrscaj 0:d96e7e513c16 290 ret = dot->joinNetwork();
jernej_vrscaj 0:d96e7e513c16 291 if (ret != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 292 logError("failed to join network %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
jernej_vrscaj 0:d96e7e513c16 293 // in some frequency bands we need to wait until another channel is available before transmitting again
jernej_vrscaj 0:d96e7e513c16 294 uint32_t delay_s = (dot->getNextTxMs() / 1000) + 1;
jernej_vrscaj 0:d96e7e513c16 295 if (delay_s < 2) {
jernej_vrscaj 0:d96e7e513c16 296 logInfo("waiting %lu s until next free channel", delay_s);
jernej_vrscaj 0:d96e7e513c16 297 wait(delay_s);
jernej_vrscaj 0:d96e7e513c16 298 } else {
jernej_vrscaj 0:d96e7e513c16 299 logInfo("sleeping %lu s until next free channel", delay_s);
jernej_vrscaj 0:d96e7e513c16 300 dot->sleep(delay_s, mDot::RTC_ALARM, false);
jernej_vrscaj 0:d96e7e513c16 301 }
jernej_vrscaj 0:d96e7e513c16 302 }
jernej_vrscaj 0:d96e7e513c16 303 }
jernej_vrscaj 0:d96e7e513c16 304 }
jernej_vrscaj 0:d96e7e513c16 305
jernej_vrscaj 0:d96e7e513c16 306 void sleep_wake_rtc_only(bool deepsleep) {
jernej_vrscaj 0:d96e7e513c16 307 // in some frequency bands we need to wait until another channel is available before transmitting again
jernej_vrscaj 0:d96e7e513c16 308 // wait at least 10s between transmissions
jernej_vrscaj 0:d96e7e513c16 309 uint32_t delay_s = dot->getNextTxMs() / 1000;
jernej_vrscaj 0:d96e7e513c16 310 if (delay_s < 10) {
jernej_vrscaj 0:d96e7e513c16 311 delay_s = 10;
jernej_vrscaj 0:d96e7e513c16 312 }
jernej_vrscaj 0:d96e7e513c16 313
jernej_vrscaj 0:d96e7e513c16 314 logInfo("%ssleeping %lus", deepsleep ? "deep" : "", delay_s);
jernej_vrscaj 0:d96e7e513c16 315 logInfo("application will %s after waking up", deepsleep ? "execute from beginning" : "resume");
jernej_vrscaj 0:d96e7e513c16 316
jernej_vrscaj 0:d96e7e513c16 317 // lowest current consumption in sleep mode can only be achieved by configuring IOs as analog inputs with no pull resistors
jernej_vrscaj 0:d96e7e513c16 318 // the library handles all internal IOs automatically, but the external IOs are the application's responsibility
jernej_vrscaj 0:d96e7e513c16 319 // certain IOs may require internal pullup or pulldown resistors because leaving them floating would cause extra current consumption
jernej_vrscaj 0:d96e7e513c16 320 // for xDot: UART_*, I2C_*, SPI_*, GPIO*, WAKE
jernej_vrscaj 0:d96e7e513c16 321 // for mDot: XBEE_*, USBTX, USBRX, PB_0, PB_1
jernej_vrscaj 0:d96e7e513c16 322 // steps are:
jernej_vrscaj 0:d96e7e513c16 323 // * save IO configuration
jernej_vrscaj 0:d96e7e513c16 324 // * configure IOs to reduce current consumption
jernej_vrscaj 0:d96e7e513c16 325 // * sleep
jernej_vrscaj 0:d96e7e513c16 326 // * restore IO configuration
jernej_vrscaj 0:d96e7e513c16 327 if (! deepsleep) {
jernej_vrscaj 0:d96e7e513c16 328 // save the GPIO state.
jernej_vrscaj 0:d96e7e513c16 329 sleep_save_io();
jernej_vrscaj 0:d96e7e513c16 330
jernej_vrscaj 0:d96e7e513c16 331 // configure GPIOs for lowest current
jernej_vrscaj 0:d96e7e513c16 332 sleep_configure_io();
jernej_vrscaj 0:d96e7e513c16 333 }
jernej_vrscaj 0:d96e7e513c16 334
jernej_vrscaj 0:d96e7e513c16 335 // go to sleep/deepsleep for delay_s seconds and wake using the RTC alarm
jernej_vrscaj 0:d96e7e513c16 336 dot->sleep(delay_s, mDot::RTC_ALARM, deepsleep);
jernej_vrscaj 0:d96e7e513c16 337
jernej_vrscaj 0:d96e7e513c16 338 if (! deepsleep) {
jernej_vrscaj 0:d96e7e513c16 339 // restore the GPIO state.
jernej_vrscaj 0:d96e7e513c16 340 sleep_restore_io();
jernej_vrscaj 0:d96e7e513c16 341 }
jernej_vrscaj 0:d96e7e513c16 342 }
jernej_vrscaj 0:d96e7e513c16 343
jernej_vrscaj 0:d96e7e513c16 344 void sleep_wake_interrupt_only(bool deepsleep) {
jernej_vrscaj 0:d96e7e513c16 345 #if defined (TARGET_XDOT_L151CC)
jernej_vrscaj 0:d96e7e513c16 346 if (deepsleep) {
jernej_vrscaj 0:d96e7e513c16 347 // for xDot, WAKE pin (connected to S2 on xDot-DK) is the only pin that can wake the processor from deepsleep
jernej_vrscaj 0:d96e7e513c16 348 // it is automatically configured when INTERRUPT or RTC_ALARM_OR_INTERRUPT is the wakeup source and deepsleep is true in the mDot::sleep call
jernej_vrscaj 0:d96e7e513c16 349 } else {
jernej_vrscaj 0:d96e7e513c16 350 // configure WAKE pin (connected to S2 on xDot-DK) as the pin that will wake the xDot from low power modes
jernej_vrscaj 0:d96e7e513c16 351 // other pins can be confgured instead: GPIO0-3 or UART_RX
jernej_vrscaj 0:d96e7e513c16 352 dot->setWakePin(WAKE);
jernej_vrscaj 0:d96e7e513c16 353 }
jernej_vrscaj 0:d96e7e513c16 354
jernej_vrscaj 0:d96e7e513c16 355 logInfo("%ssleeping until interrupt on %s pin", deepsleep ? "deep" : "", deepsleep ? "WAKE" : mDot::pinName2Str(dot->getWakePin()).c_str());
jernej_vrscaj 0:d96e7e513c16 356 #else
jernej_vrscaj 0:d96e7e513c16 357
jernej_vrscaj 0:d96e7e513c16 358 if (deepsleep) {
jernej_vrscaj 0:d96e7e513c16 359 // for mDot, XBEE_DIO7 pin is the only pin that can wake the processor from deepsleep
jernej_vrscaj 0:d96e7e513c16 360 // it is automatically configured when INTERRUPT or RTC_ALARM_OR_INTERRUPT is the wakeup source and deepsleep is true in the mDot::sleep call
jernej_vrscaj 0:d96e7e513c16 361 } else {
jernej_vrscaj 0:d96e7e513c16 362 // configure XBEE_DIO7 pin as the pin that will wake the mDot from low power modes
jernej_vrscaj 0:d96e7e513c16 363 // other pins can be confgured instead: XBEE_DIO2-6, XBEE_DI8, XBEE_DIN
jernej_vrscaj 0:d96e7e513c16 364 dot->setWakePin(XBEE_DIO7);
jernej_vrscaj 0:d96e7e513c16 365 }
jernej_vrscaj 0:d96e7e513c16 366
jernej_vrscaj 0:d96e7e513c16 367 logInfo("%ssleeping until interrupt on %s pin", deepsleep ? "deep" : "", deepsleep ? "DIO7" : mDot::pinName2Str(dot->getWakePin()).c_str());
jernej_vrscaj 0:d96e7e513c16 368 #endif
jernej_vrscaj 0:d96e7e513c16 369
jernej_vrscaj 0:d96e7e513c16 370 logInfo("application will %s after waking up", deepsleep ? "execute from beginning" : "resume");
jernej_vrscaj 0:d96e7e513c16 371
jernej_vrscaj 0:d96e7e513c16 372 // lowest current consumption in sleep mode can only be achieved by configuring IOs as analog inputs with no pull resistors
jernej_vrscaj 0:d96e7e513c16 373 // the library handles all internal IOs automatically, but the external IOs are the application's responsibility
jernej_vrscaj 0:d96e7e513c16 374 // certain IOs may require internal pullup or pulldown resistors because leaving them floating would cause extra current consumption
jernej_vrscaj 0:d96e7e513c16 375 // for xDot: UART_*, I2C_*, SPI_*, GPIO*, WAKE
jernej_vrscaj 0:d96e7e513c16 376 // for mDot: XBEE_*, USBTX, USBRX, PB_0, PB_1
jernej_vrscaj 0:d96e7e513c16 377 // steps are:
jernej_vrscaj 0:d96e7e513c16 378 // * save IO configuration
jernej_vrscaj 0:d96e7e513c16 379 // * configure IOs to reduce current consumption
jernej_vrscaj 0:d96e7e513c16 380 // * sleep
jernej_vrscaj 0:d96e7e513c16 381 // * restore IO configuration
jernej_vrscaj 0:d96e7e513c16 382 if (! deepsleep) {
jernej_vrscaj 0:d96e7e513c16 383 // save the GPIO state.
jernej_vrscaj 0:d96e7e513c16 384 sleep_save_io();
jernej_vrscaj 0:d96e7e513c16 385
jernej_vrscaj 0:d96e7e513c16 386 // configure GPIOs for lowest current
jernej_vrscaj 0:d96e7e513c16 387 sleep_configure_io();
jernej_vrscaj 0:d96e7e513c16 388 }
jernej_vrscaj 0:d96e7e513c16 389
jernej_vrscaj 0:d96e7e513c16 390 // go to sleep/deepsleep and wake on rising edge of configured wake pin (only the WAKE pin in deepsleep)
jernej_vrscaj 0:d96e7e513c16 391 // since we're not waking on the RTC alarm, the interval is ignored
jernej_vrscaj 0:d96e7e513c16 392 dot->sleep(0, mDot::INTERRUPT, deepsleep);
jernej_vrscaj 0:d96e7e513c16 393
jernej_vrscaj 0:d96e7e513c16 394 if (! deepsleep) {
jernej_vrscaj 0:d96e7e513c16 395 // restore the GPIO state.
jernej_vrscaj 0:d96e7e513c16 396 sleep_restore_io();
jernej_vrscaj 0:d96e7e513c16 397 }
jernej_vrscaj 0:d96e7e513c16 398 }
jernej_vrscaj 0:d96e7e513c16 399
jernej_vrscaj 0:d96e7e513c16 400 void sleep_wake_rtc_or_interrupt(bool deepsleep) {
jernej_vrscaj 0:d96e7e513c16 401 // in some frequency bands we need to wait until another channel is available before transmitting again
jernej_vrscaj 0:d96e7e513c16 402 // wait at least 10s between transmissions
jernej_vrscaj 0:d96e7e513c16 403 uint32_t delay_s = dot->getNextTxMs() / 1000;
jernej_vrscaj 0:d96e7e513c16 404 if (delay_s < 10) {
jernej_vrscaj 0:d96e7e513c16 405 delay_s = 10;
jernej_vrscaj 0:d96e7e513c16 406 }
jernej_vrscaj 0:d96e7e513c16 407
jernej_vrscaj 0:d96e7e513c16 408 #if defined (TARGET_XDOT_L151CC)
jernej_vrscaj 0:d96e7e513c16 409 if (deepsleep) {
jernej_vrscaj 0:d96e7e513c16 410 // for xDot, WAKE pin (connected to S2 on xDot-DK) is the only pin that can wake the processor from deepsleep
jernej_vrscaj 0:d96e7e513c16 411 // it is automatically configured when INTERRUPT or RTC_ALARM_OR_INTERRUPT is the wakeup source and deepsleep is true in the mDot::sleep call
jernej_vrscaj 0:d96e7e513c16 412 } else {
jernej_vrscaj 0:d96e7e513c16 413 // configure WAKE pin (connected to S2 on xDot-DK) as the pin that will wake the xDot from low power modes
jernej_vrscaj 0:d96e7e513c16 414 // other pins can be confgured instead: GPIO0-3 or UART_RX
jernej_vrscaj 0:d96e7e513c16 415 dot->setWakePin(WAKE);
jernej_vrscaj 0:d96e7e513c16 416 }
jernej_vrscaj 0:d96e7e513c16 417
jernej_vrscaj 0:d96e7e513c16 418 logInfo("%ssleeping %lus or until interrupt on %s pin", deepsleep ? "deep" : "", delay_s, deepsleep ? "WAKE" : mDot::pinName2Str(dot->getWakePin()).c_str());
jernej_vrscaj 0:d96e7e513c16 419 #else
jernej_vrscaj 0:d96e7e513c16 420 if (deepsleep) {
jernej_vrscaj 0:d96e7e513c16 421 // for mDot, XBEE_DIO7 pin is the only pin that can wake the processor from deepsleep
jernej_vrscaj 0:d96e7e513c16 422 // it is automatically configured when INTERRUPT or RTC_ALARM_OR_INTERRUPT is the wakeup source and deepsleep is true in the mDot::sleep call
jernej_vrscaj 0:d96e7e513c16 423 } else {
jernej_vrscaj 0:d96e7e513c16 424 // configure XBEE_DIO7 pin as the pin that will wake the mDot from low power modes
jernej_vrscaj 0:d96e7e513c16 425 // other pins can be confgured instead: XBEE_DIO2-6, XBEE_DI8, XBEE_DIN
jernej_vrscaj 0:d96e7e513c16 426 dot->setWakePin(XBEE_DIO7);
jernej_vrscaj 0:d96e7e513c16 427 }
jernej_vrscaj 0:d96e7e513c16 428
jernej_vrscaj 0:d96e7e513c16 429 logInfo("%ssleeping %lus or until interrupt on %s pin", deepsleep ? "deep" : "", delay_s, deepsleep ? "DIO7" : mDot::pinName2Str(dot->getWakePin()).c_str());
jernej_vrscaj 0:d96e7e513c16 430 #endif
jernej_vrscaj 0:d96e7e513c16 431
jernej_vrscaj 0:d96e7e513c16 432 logInfo("application will %s after waking up", deepsleep ? "execute from beginning" : "resume");
jernej_vrscaj 0:d96e7e513c16 433
jernej_vrscaj 0:d96e7e513c16 434 // lowest current consumption in sleep mode can only be achieved by configuring IOs as analog inputs with no pull resistors
jernej_vrscaj 0:d96e7e513c16 435 // the library handles all internal IOs automatically, but the external IOs are the application's responsibility
jernej_vrscaj 0:d96e7e513c16 436 // certain IOs may require internal pullup or pulldown resistors because leaving them floating would cause extra current consumption
jernej_vrscaj 0:d96e7e513c16 437 // for xDot: UART_*, I2C_*, SPI_*, GPIO*, WAKE
jernej_vrscaj 0:d96e7e513c16 438 // for mDot: XBEE_*, USBTX, USBRX, PB_0, PB_1
jernej_vrscaj 0:d96e7e513c16 439 // steps are:
jernej_vrscaj 0:d96e7e513c16 440 // * save IO configuration
jernej_vrscaj 0:d96e7e513c16 441 // * configure IOs to reduce current consumption
jernej_vrscaj 0:d96e7e513c16 442 // * sleep
jernej_vrscaj 0:d96e7e513c16 443 // * restore IO configuration
jernej_vrscaj 0:d96e7e513c16 444 if (! deepsleep) {
jernej_vrscaj 0:d96e7e513c16 445 // save the GPIO state.
jernej_vrscaj 0:d96e7e513c16 446 sleep_save_io();
jernej_vrscaj 0:d96e7e513c16 447
jernej_vrscaj 0:d96e7e513c16 448 // configure GPIOs for lowest current
jernej_vrscaj 0:d96e7e513c16 449 sleep_configure_io();
jernej_vrscaj 0:d96e7e513c16 450 }
jernej_vrscaj 0:d96e7e513c16 451
jernej_vrscaj 0:d96e7e513c16 452 // go to sleep/deepsleep and wake using the RTC alarm after delay_s seconds or rising edge of configured wake pin (only the WAKE pin in deepsleep)
jernej_vrscaj 0:d96e7e513c16 453 // whichever comes first will wake the xDot
jernej_vrscaj 0:d96e7e513c16 454 dot->sleep(delay_s, mDot::RTC_ALARM_OR_INTERRUPT, deepsleep);
jernej_vrscaj 0:d96e7e513c16 455
jernej_vrscaj 0:d96e7e513c16 456 if (! deepsleep) {
jernej_vrscaj 0:d96e7e513c16 457 // restore the GPIO state.
jernej_vrscaj 0:d96e7e513c16 458 sleep_restore_io();
jernej_vrscaj 0:d96e7e513c16 459 }
jernej_vrscaj 0:d96e7e513c16 460 }
jernej_vrscaj 0:d96e7e513c16 461
jernej_vrscaj 0:d96e7e513c16 462 void sleep_save_io() {
jernej_vrscaj 0:d96e7e513c16 463 #if defined(TARGET_XDOT_L151CC)
jernej_vrscaj 0:d96e7e513c16 464 xdot_save_gpio_state();
jernej_vrscaj 0:d96e7e513c16 465 #else
jernej_vrscaj 0:d96e7e513c16 466 portA[0] = GPIOA->MODER;
jernej_vrscaj 0:d96e7e513c16 467 portA[1] = GPIOA->OTYPER;
jernej_vrscaj 0:d96e7e513c16 468 portA[2] = GPIOA->OSPEEDR;
jernej_vrscaj 0:d96e7e513c16 469 portA[3] = GPIOA->PUPDR;
jernej_vrscaj 0:d96e7e513c16 470 portA[4] = GPIOA->AFR[0];
jernej_vrscaj 0:d96e7e513c16 471 portA[5] = GPIOA->AFR[1];
jernej_vrscaj 0:d96e7e513c16 472
jernej_vrscaj 0:d96e7e513c16 473 portB[0] = GPIOB->MODER;
jernej_vrscaj 0:d96e7e513c16 474 portB[1] = GPIOB->OTYPER;
jernej_vrscaj 0:d96e7e513c16 475 portB[2] = GPIOB->OSPEEDR;
jernej_vrscaj 0:d96e7e513c16 476 portB[3] = GPIOB->PUPDR;
jernej_vrscaj 0:d96e7e513c16 477 portB[4] = GPIOB->AFR[0];
jernej_vrscaj 0:d96e7e513c16 478 portB[5] = GPIOB->AFR[1];
jernej_vrscaj 0:d96e7e513c16 479
jernej_vrscaj 0:d96e7e513c16 480 portC[0] = GPIOC->MODER;
jernej_vrscaj 0:d96e7e513c16 481 portC[1] = GPIOC->OTYPER;
jernej_vrscaj 0:d96e7e513c16 482 portC[2] = GPIOC->OSPEEDR;
jernej_vrscaj 0:d96e7e513c16 483 portC[3] = GPIOC->PUPDR;
jernej_vrscaj 0:d96e7e513c16 484 portC[4] = GPIOC->AFR[0];
jernej_vrscaj 0:d96e7e513c16 485 portC[5] = GPIOC->AFR[1];
jernej_vrscaj 0:d96e7e513c16 486
jernej_vrscaj 0:d96e7e513c16 487 portD[0] = GPIOD->MODER;
jernej_vrscaj 0:d96e7e513c16 488 portD[1] = GPIOD->OTYPER;
jernej_vrscaj 0:d96e7e513c16 489 portD[2] = GPIOD->OSPEEDR;
jernej_vrscaj 0:d96e7e513c16 490 portD[3] = GPIOD->PUPDR;
jernej_vrscaj 0:d96e7e513c16 491 portD[4] = GPIOD->AFR[0];
jernej_vrscaj 0:d96e7e513c16 492 portD[5] = GPIOD->AFR[1];
jernej_vrscaj 0:d96e7e513c16 493
jernej_vrscaj 0:d96e7e513c16 494 portH[0] = GPIOH->MODER;
jernej_vrscaj 0:d96e7e513c16 495 portH[1] = GPIOH->OTYPER;
jernej_vrscaj 0:d96e7e513c16 496 portH[2] = GPIOH->OSPEEDR;
jernej_vrscaj 0:d96e7e513c16 497 portH[3] = GPIOH->PUPDR;
jernej_vrscaj 0:d96e7e513c16 498 portH[4] = GPIOH->AFR[0];
jernej_vrscaj 0:d96e7e513c16 499 portH[5] = GPIOH->AFR[1];
jernej_vrscaj 0:d96e7e513c16 500 #endif
jernej_vrscaj 0:d96e7e513c16 501 }
jernej_vrscaj 0:d96e7e513c16 502
jernej_vrscaj 0:d96e7e513c16 503 void sleep_configure_io() {
jernej_vrscaj 0:d96e7e513c16 504 #if defined(TARGET_XDOT_L151CC)
jernej_vrscaj 0:d96e7e513c16 505 // GPIO Ports Clock Enable
jernej_vrscaj 0:d96e7e513c16 506 __GPIOA_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 507 __GPIOB_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 508 __GPIOC_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 509 __GPIOH_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 510
jernej_vrscaj 0:d96e7e513c16 511 GPIO_InitTypeDef GPIO_InitStruct;
jernej_vrscaj 0:d96e7e513c16 512
jernej_vrscaj 0:d96e7e513c16 513 // UART1_TX, UART1_RTS & UART1_CTS to analog nopull - RX could be a wakeup source
jernej_vrscaj 0:d96e7e513c16 514 GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_11 | GPIO_PIN_12;
jernej_vrscaj 0:d96e7e513c16 515 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 516 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 517 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 518
jernej_vrscaj 0:d96e7e513c16 519 // I2C_SDA & I2C_SCL to analog nopull
jernej_vrscaj 0:d96e7e513c16 520 GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
jernej_vrscaj 0:d96e7e513c16 521 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 522 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 523 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 524
jernej_vrscaj 0:d96e7e513c16 525 // SPI_MOSI, SPI_MISO, SPI_SCK, & SPI_NSS to analog nopull
jernej_vrscaj 0:d96e7e513c16 526 GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
jernej_vrscaj 0:d96e7e513c16 527 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 528 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 529 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 530
jernej_vrscaj 0:d96e7e513c16 531 // iterate through potential wake pins - leave the configured wake pin alone if one is needed
jernej_vrscaj 0:d96e7e513c16 532 if (dot->getWakePin() != WAKE || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 533 GPIO_InitStruct.Pin = GPIO_PIN_0;
jernej_vrscaj 0:d96e7e513c16 534 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 535 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 536 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 537 }
jernej_vrscaj 0:d96e7e513c16 538 if (dot->getWakePin() != GPIO0 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 539 GPIO_InitStruct.Pin = GPIO_PIN_4;
jernej_vrscaj 0:d96e7e513c16 540 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 541 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 542 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 543 }
jernej_vrscaj 0:d96e7e513c16 544 if (dot->getWakePin() != GPIO1 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 545 GPIO_InitStruct.Pin = GPIO_PIN_5;
jernej_vrscaj 0:d96e7e513c16 546 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 547 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 548 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 549 }
jernej_vrscaj 0:d96e7e513c16 550 if (dot->getWakePin() != GPIO2 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 551 GPIO_InitStruct.Pin = GPIO_PIN_0;
jernej_vrscaj 0:d96e7e513c16 552 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 553 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 554 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 555 }
jernej_vrscaj 0:d96e7e513c16 556 if (dot->getWakePin() != GPIO3 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 557 GPIO_InitStruct.Pin = GPIO_PIN_2;
jernej_vrscaj 0:d96e7e513c16 558 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 559 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 560 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 561 }
jernej_vrscaj 0:d96e7e513c16 562 if (dot->getWakePin() != UART1_RX || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 563 GPIO_InitStruct.Pin = GPIO_PIN_10;
jernej_vrscaj 0:d96e7e513c16 564 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 565 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 566 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 567 }
jernej_vrscaj 0:d96e7e513c16 568 #else
jernej_vrscaj 0:d96e7e513c16 569 /* GPIO Ports Clock Enable */
jernej_vrscaj 0:d96e7e513c16 570 __GPIOA_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 571 __GPIOB_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 572 __GPIOC_CLK_ENABLE();
jernej_vrscaj 0:d96e7e513c16 573
jernej_vrscaj 0:d96e7e513c16 574 GPIO_InitTypeDef GPIO_InitStruct;
jernej_vrscaj 0:d96e7e513c16 575
jernej_vrscaj 0:d96e7e513c16 576 // XBEE_DOUT, XBEE_DIN, XBEE_DO8, XBEE_RSSI, USBTX, USBRX, PA_12, PA_13, PA_14 & PA_15 to analog nopull
jernej_vrscaj 0:d96e7e513c16 577 GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_6 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10
jernej_vrscaj 0:d96e7e513c16 578 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
jernej_vrscaj 0:d96e7e513c16 579 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 580 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 581 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 582
jernej_vrscaj 0:d96e7e513c16 583 // PB_0, PB_1, PB_3 & PB_4 to analog nopull
jernej_vrscaj 0:d96e7e513c16 584 GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4;
jernej_vrscaj 0:d96e7e513c16 585 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 586 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 587 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 588
jernej_vrscaj 0:d96e7e513c16 589 // PC_9 & PC_13 to analog nopull
jernej_vrscaj 0:d96e7e513c16 590 GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_13;
jernej_vrscaj 0:d96e7e513c16 591 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 592 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 593 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 594
jernej_vrscaj 0:d96e7e513c16 595 // iterate through potential wake pins - leave the configured wake pin alone if one is needed
jernej_vrscaj 0:d96e7e513c16 596 // XBEE_DIN - PA3
jernej_vrscaj 0:d96e7e513c16 597 // XBEE_DIO2 - PA5
jernej_vrscaj 0:d96e7e513c16 598 // XBEE_DIO3 - PA4
jernej_vrscaj 0:d96e7e513c16 599 // XBEE_DIO4 - PA7
jernej_vrscaj 0:d96e7e513c16 600 // XBEE_DIO5 - PC1
jernej_vrscaj 0:d96e7e513c16 601 // XBEE_DIO6 - PA1
jernej_vrscaj 0:d96e7e513c16 602 // XBEE_DIO7 - PA0
jernej_vrscaj 0:d96e7e513c16 603 // XBEE_SLEEPRQ - PA11
jernej_vrscaj 0:d96e7e513c16 604
jernej_vrscaj 0:d96e7e513c16 605 if (dot->getWakePin() != XBEE_DIN || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 606 GPIO_InitStruct.Pin = GPIO_PIN_3;
jernej_vrscaj 0:d96e7e513c16 607 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 608 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 609 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 610 }
jernej_vrscaj 0:d96e7e513c16 611
jernej_vrscaj 0:d96e7e513c16 612 if (dot->getWakePin() != XBEE_DIO2 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 613 GPIO_InitStruct.Pin = GPIO_PIN_5;
jernej_vrscaj 0:d96e7e513c16 614 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 615 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 616 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 617 }
jernej_vrscaj 0:d96e7e513c16 618
jernej_vrscaj 0:d96e7e513c16 619 if (dot->getWakePin() != XBEE_DIO3 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 620 GPIO_InitStruct.Pin = GPIO_PIN_4;
jernej_vrscaj 0:d96e7e513c16 621 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 622 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 623 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 624 }
jernej_vrscaj 0:d96e7e513c16 625
jernej_vrscaj 0:d96e7e513c16 626 if (dot->getWakePin() != XBEE_DIO4 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 627 GPIO_InitStruct.Pin = GPIO_PIN_7;
jernej_vrscaj 0:d96e7e513c16 628 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 629 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 630 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 631 }
jernej_vrscaj 0:d96e7e513c16 632
jernej_vrscaj 0:d96e7e513c16 633 if (dot->getWakePin() != XBEE_DIO5 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 634 GPIO_InitStruct.Pin = GPIO_PIN_1;
jernej_vrscaj 0:d96e7e513c16 635 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 636 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 637 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 638 }
jernej_vrscaj 0:d96e7e513c16 639
jernej_vrscaj 0:d96e7e513c16 640 if (dot->getWakePin() != XBEE_DIO6 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 641 GPIO_InitStruct.Pin = GPIO_PIN_1;
jernej_vrscaj 0:d96e7e513c16 642 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 643 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 644 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 645 }
jernej_vrscaj 0:d96e7e513c16 646
jernej_vrscaj 0:d96e7e513c16 647 if (dot->getWakePin() != XBEE_DIO7 || dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 648 GPIO_InitStruct.Pin = GPIO_PIN_0;
jernej_vrscaj 0:d96e7e513c16 649 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 650 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 651 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 652 }
jernej_vrscaj 0:d96e7e513c16 653
jernej_vrscaj 0:d96e7e513c16 654 if (dot->getWakePin() != XBEE_SLEEPRQ|| dot->getWakeMode() == mDot::RTC_ALARM) {
jernej_vrscaj 0:d96e7e513c16 655 GPIO_InitStruct.Pin = GPIO_PIN_11;
jernej_vrscaj 0:d96e7e513c16 656 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
jernej_vrscaj 0:d96e7e513c16 657 GPIO_InitStruct.Pull = GPIO_NOPULL;
jernej_vrscaj 0:d96e7e513c16 658 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
jernej_vrscaj 0:d96e7e513c16 659 }
jernej_vrscaj 0:d96e7e513c16 660 #endif
jernej_vrscaj 0:d96e7e513c16 661 }
jernej_vrscaj 0:d96e7e513c16 662
jernej_vrscaj 0:d96e7e513c16 663 void sleep_restore_io() {
jernej_vrscaj 0:d96e7e513c16 664 #if defined(TARGET_XDOT_L151CC)
jernej_vrscaj 0:d96e7e513c16 665 xdot_restore_gpio_state();
jernej_vrscaj 0:d96e7e513c16 666 #else
jernej_vrscaj 0:d96e7e513c16 667 GPIOA->MODER = portA[0];
jernej_vrscaj 0:d96e7e513c16 668 GPIOA->OTYPER = portA[1];
jernej_vrscaj 0:d96e7e513c16 669 GPIOA->OSPEEDR = portA[2];
jernej_vrscaj 0:d96e7e513c16 670 GPIOA->PUPDR = portA[3];
jernej_vrscaj 0:d96e7e513c16 671 GPIOA->AFR[0] = portA[4];
jernej_vrscaj 0:d96e7e513c16 672 GPIOA->AFR[1] = portA[5];
jernej_vrscaj 0:d96e7e513c16 673
jernej_vrscaj 0:d96e7e513c16 674 GPIOB->MODER = portB[0];
jernej_vrscaj 0:d96e7e513c16 675 GPIOB->OTYPER = portB[1];
jernej_vrscaj 0:d96e7e513c16 676 GPIOB->OSPEEDR = portB[2];
jernej_vrscaj 0:d96e7e513c16 677 GPIOB->PUPDR = portB[3];
jernej_vrscaj 0:d96e7e513c16 678 GPIOB->AFR[0] = portB[4];
jernej_vrscaj 0:d96e7e513c16 679 GPIOB->AFR[1] = portB[5];
jernej_vrscaj 0:d96e7e513c16 680
jernej_vrscaj 0:d96e7e513c16 681 GPIOC->MODER = portC[0];
jernej_vrscaj 0:d96e7e513c16 682 GPIOC->OTYPER = portC[1];
jernej_vrscaj 0:d96e7e513c16 683 GPIOC->OSPEEDR = portC[2];
jernej_vrscaj 0:d96e7e513c16 684 GPIOC->PUPDR = portC[3];
jernej_vrscaj 0:d96e7e513c16 685 GPIOC->AFR[0] = portC[4];
jernej_vrscaj 0:d96e7e513c16 686 GPIOC->AFR[1] = portC[5];
jernej_vrscaj 0:d96e7e513c16 687
jernej_vrscaj 0:d96e7e513c16 688 GPIOD->MODER = portD[0];
jernej_vrscaj 0:d96e7e513c16 689 GPIOD->OTYPER = portD[1];
jernej_vrscaj 0:d96e7e513c16 690 GPIOD->OSPEEDR = portD[2];
jernej_vrscaj 0:d96e7e513c16 691 GPIOD->PUPDR = portD[3];
jernej_vrscaj 0:d96e7e513c16 692 GPIOD->AFR[0] = portD[4];
jernej_vrscaj 0:d96e7e513c16 693 GPIOD->AFR[1] = portD[5];
jernej_vrscaj 0:d96e7e513c16 694
jernej_vrscaj 0:d96e7e513c16 695 GPIOH->MODER = portH[0];
jernej_vrscaj 0:d96e7e513c16 696 GPIOH->OTYPER = portH[1];
jernej_vrscaj 0:d96e7e513c16 697 GPIOH->OSPEEDR = portH[2];
jernej_vrscaj 0:d96e7e513c16 698 GPIOH->PUPDR = portH[3];
jernej_vrscaj 0:d96e7e513c16 699 GPIOH->AFR[0] = portH[4];
jernej_vrscaj 0:d96e7e513c16 700 GPIOH->AFR[1] = portH[5];
jernej_vrscaj 0:d96e7e513c16 701 #endif
jernej_vrscaj 0:d96e7e513c16 702 }
jernej_vrscaj 0:d96e7e513c16 703
jernej_vrscaj 0:d96e7e513c16 704 void send_data(std::vector<uint8_t> data) {
jernej_vrscaj 0:d96e7e513c16 705 int32_t ret;
jernej_vrscaj 0:d96e7e513c16 706
jernej_vrscaj 0:d96e7e513c16 707 ret = dot->send(data);
jernej_vrscaj 0:d96e7e513c16 708 if (ret != mDot::MDOT_OK) {
jernej_vrscaj 0:d96e7e513c16 709 logError("failed to send data to %s [%d][%s]", dot->getJoinMode() == mDot::PEER_TO_PEER ? "peer" : "gateway", ret, mDot::getReturnCodeString(ret).c_str());
jernej_vrscaj 0:d96e7e513c16 710 } else {
jernej_vrscaj 0:d96e7e513c16 711 logInfo("successfully sent data to %s", dot->getJoinMode() == mDot::PEER_TO_PEER ? "peer" : "gateway");
jernej_vrscaj 0:d96e7e513c16 712 }
jernej_vrscaj 0:d96e7e513c16 713 }
jernej_vrscaj 0:d96e7e513c16 714
jernej_vrscaj 0:d96e7e513c16 715