arm studio build

Dependencies:   libxDot-mbed5

Committer:
alan1974
Date:
Fri Jan 18 18:15:29 2019 +0000
Revision:
14:fc836a5a5d2f
Parent:
13:1f3a8d0be511
Child:
15:ed77b752eaa9
upload of ABP credentials done

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alan1974 12:7944e4dbe853 1 #include "mbed.h"
alan1974 1:0d25d9ddbe9f 2 #include "global.h"
alan1974 0:a91cd1b08360 3 #include "commI2C.h"
alan1974 0:a91cd1b08360 4 #include "dot_util.h"
alan1974 0:a91cd1b08360 5 #include "wbit_util.h"
alan1974 14:fc836a5a5d2f 6 #include "multicast.h"
alan1974 0:a91cd1b08360 7 #include "mDot.h"
alan1974 0:a91cd1b08360 8 #include "RadioEvent.h"
alan1974 0:a91cd1b08360 9 #include "Lora.h"
alan1974 0:a91cd1b08360 10
alan1974 11:77fe4f18a81b 11 bool bRxDone = false; //true if callback function RxDone() triggered
alan1974 11:77fe4f18a81b 12 bool bDownLinkCntrFail = false; //true if callback function RxDone() triggered and bad downlink frame count
alan1974 11:77fe4f18a81b 13
alan1974 1:0d25d9ddbe9f 14 //nvm storage params
alan1974 1:0d25d9ddbe9f 15 nvm nvmData;
alan1974 1:0d25d9ddbe9f 16 nvm *pNvmData = &nvmData;
alan1974 1:0d25d9ddbe9f 17
alan1974 5:abfe25f0de33 18 bool verbose = true;
alan1974 0:a91cd1b08360 19 //=======================================================================================================
alan1974 10:061fab1195e7 20 // enable GPIO for scope trigger
alan1974 0:a91cd1b08360 21 //=======================================================================================================
alan1974 0:a91cd1b08360 22 //#define GPIO_ENABLE
alan1974 0:a91cd1b08360 23 //=======================================================================================================
alan1974 0:a91cd1b08360 24 // configure for either private (test only) or public network (standard)
alan1974 0:a91cd1b08360 25 //=======================================================================================================
alan1974 0:a91cd1b08360 26 //#define MT_PRIVATE_NETWORK //ENABLE THIS FOR PRIVATE NETWORK
alan1974 0:a91cd1b08360 27
alan1974 0:a91cd1b08360 28 //=======================================================================================================
alan1974 0:a91cd1b08360 29 //code api level and version
alan1974 0:a91cd1b08360 30 //api_level: proc code will not run if api level (last two bytess) greater than what it expects
alan1974 0:a91cd1b08360 31 //=======================================================================================================
alan1974 0:a91cd1b08360 32 uint8_t api_level[4] = { 0x00, 0x00, 0x00, 0x03 }; //api-level, determines if xdot code works with proc code
alan1974 12:7944e4dbe853 33 uint8_t ver_level[4] = { 0x00, 0x00, 0x00, 0x09 }; //updated for every code check-in
alan1974 0:a91cd1b08360 34
alan1974 0:a91cd1b08360 35 //=======================================================================================================
alan1974 0:a91cd1b08360 36 //configuring mbed pinsa; https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/io/DigitalInOut/
alan1974 0:a91cd1b08360 37 // * these options must match the settings on your gateway //
alan1974 0:a91cd1b08360 38 // * edit their values to match your configuration //
alan1974 0:a91cd1b08360 39 // * frequency sub band is only relevant for the 915 bands //
alan1974 0:a91cd1b08360 40 // * either the network name and passphrase can be used or //
alan1974 0:a91cd1b08360 41 // the network ID (8 bytes) and KEY (16 bytes) //
alan1974 0:a91cd1b08360 42 //=======================================================================================================
alan1974 1:0d25d9ddbe9f 43 static std::string network_name = "asdfqwer"; //not used
alan1974 1:0d25d9ddbe9f 44 static std::string network_passphrase = "zxcvasdf"; //not used
alan1974 12:7944e4dbe853 45
alan1974 0:a91cd1b08360 46
alan1974 0:a91cd1b08360 47 #ifdef MT_PRIVATE_NETWORK
alan1974 0:a91cd1b08360 48 static uint8_t frequency_sub_band = 4;
alan1974 0:a91cd1b08360 49 static bool public_network = false;
alan1974 0:a91cd1b08360 50 static uint8_t ack = 1; //0;
alan1974 0:a91cd1b08360 51 #else
alan1974 1:0d25d9ddbe9f 52 uint8_t frequency_sub_band = 1;
alan1974 1:0d25d9ddbe9f 53 bool public_network = true; //false
alan1974 1:0d25d9ddbe9f 54 uint8_t ack = 1; //0;
alan1974 1:0d25d9ddbe9f 55 uint8_t link_check_treshold = 100; //5;
alan1974 0:a91cd1b08360 56 #endif
alan1974 0:a91cd1b08360 57
alan1974 1:0d25d9ddbe9f 58 bool adr = false; //set adaptive data rate
alan1974 10:061fab1195e7 59 //=======================================================================================================
alan1974 10:061fab1195e7 60 // -need to add a delay between exiting i2c read->proc and before putting xdot to sleep to allow for final
alan1974 10:061fab1195e7 61 // xfr of bytes in i2c buffer to be xfrd to proc. If log output enabled then it causes enough delay when
alan1974 10:061fab1195e7 62 // it prints status info to make the delay ok. For now add this delay when both log enabled and disabled.
alan1974 10:061fab1195e7 63 int16_t wait_before_sleep_usec = 10000;
alan1974 0:a91cd1b08360 64 //=======================================================================================================
alan1974 0:a91cd1b08360 65 // deepsleep consumes slightly less current than sleep
alan1974 0:a91cd1b08360 66 // in sleep mode, IO state is maintained, RAM is retained, and application will resume after waking up
alan1974 0:a91cd1b08360 67 // in deepsleep mode, IOs float, RAM is lost, and application will start from beginning after waking up
alan1974 0:a91cd1b08360 68 // if deep_sleep == true, device will enter deepsleep mode
alan1974 8:a5316708e51d 69 // asb:
alan1974 8:a5316708e51d 70 // no longer use deepsleep since we want to retain state
alan1974 8:a5316708e51d 71 // sleep uses only 1uA more current than deepsleep
alan1974 0:a91cd1b08360 72 //=======================================================================================================
alan1974 0:a91cd1b08360 73 static bool deep_sleep = false; //false;
alan1974 0:a91cd1b08360 74
alan1974 0:a91cd1b08360 75 uint32_t packets_sent = 0;
alan1974 0:a91cd1b08360 76 uint32_t acks_rcvd = 0;
alan1974 0:a91cd1b08360 77 int8_t rssi =0; //rssi of last rcvd rx1/rx2
alan1974 0:a91cd1b08360 78 std::string eui = " ";
alan1974 0:a91cd1b08360 79 static bool led_enabled = false; //true; //false;
alan1974 0:a91cd1b08360 80 mDot* dot = NULL;
alan1974 0:a91cd1b08360 81 lora::ChannelPlan* plan = NULL;
alan1974 0:a91cd1b08360 82 uint8_t buf_xmt[BUFFER_SIZE_I2C]; //outgoing data
alan1974 0:a91cd1b08360 83 uint8_t buf_rcv[BUFFER_SIZE_I2C]; //incoming data
alan1974 0:a91cd1b08360 84 std::vector<uint8_t> upstream_packet;
alan1974 0:a91cd1b08360 85
alan1974 0:a91cd1b08360 86 #ifdef GPIO_ENABLE
alan1974 0:a91cd1b08360 87 DigitalInOut gpio1(PA_5); //scope debug PA-5 is connected to SW1 pads on Loren v04 and can be used for scope debug
alan1974 0:a91cd1b08360 88 #endif
alan1974 0:a91cd1b08360 89
alan1974 0:a91cd1b08360 90 Serial pc(USBTX, USBRX); //serial port output
alan1974 0:a91cd1b08360 91
alan1974 0:a91cd1b08360 92 //==================================================================================
alan1974 0:a91cd1b08360 93 //chksum
alan1974 0:a91cd1b08360 94 //compute checksum over i2c buffer except for last byte (chksum byte)
alan1974 0:a91cd1b08360 95 //==================================================================================
alan1974 0:a91cd1b08360 96 uint8_t chksum_proc(uint8_t *bfr_xdot){
alan1974 0:a91cd1b08360 97 uint8_t i;
alan1974 0:a91cd1b08360 98 uint8_t chksum = 0;
alan1974 0:a91cd1b08360 99 for (i=0; i < BUFFER_SIZE_I2C-1;i++)chksum += bfr_xdot[i];//good code
alan1974 0:a91cd1b08360 100 return chksum;
alan1974 0:a91cd1b08360 101 }
alan1974 0:a91cd1b08360 102 //=================================================================================================
alan1974 0:a91cd1b08360 103 //cfg_network:
alan1974 0:a91cd1b08360 104 // configure the network public/private and sub-band
alan1974 0:a91cd1b08360 105 // bForceCfg : true => force a network cfg
alan1974 0:a91cd1b08360 106 // false => only change if bPublic or sub_band have changed
alan1974 0:a91cd1b08360 107 // bPublic : true if network is public, else private
alan1974 0:a91cd1b08360 108 // sub_band: sub band number (1..8)
alan1974 0:a91cd1b08360 109
alan1974 0:a91cd1b08360 110 // NOTE: THIS ONLY WORKS WHEN THE XDOT BOOTS UP. IT DOES NOT WORK WHEN TRYING TO CHANGE AFTER.
alan1974 0:a91cd1b08360 111 // NOT SURE WHY...WHEN THE XDOT REJOINS IT SHOULD USE NEW SESSION SETTINGS... asb
alan1974 0:a91cd1b08360 112 //
alan1974 0:a91cd1b08360 113 //asb:dec 2017: try this later and see if it works:mdot.h:
alan1974 0:a91cd1b08360 114 // int32_t setPublicNetwork(const bool& on);
alan1974 0:a91cd1b08360 115 // bool getPublicNetwork();
alan1974 0:a91cd1b08360 116 // int32_t setFrequencySubBand(const uint8_t& band);
alan1974 0:a91cd1b08360 117 //=================================================================================================
alan1974 0:a91cd1b08360 118 bool cfg_network(bool bForceCfg,bool bPublic,uint8_t sub_band){
alan1974 0:a91cd1b08360 119 // if bForceCfg false and network parameters haven't changed then just exit
alan1974 0:a91cd1b08360 120 if (!bForceCfg){
alan1974 5:abfe25f0de33 121 if(verbose)pc.printf("no configuration change needed subband the same");
alan1974 0:a91cd1b08360 122 if ((public_network ==bPublic) && (frequency_sub_band ==sub_band))return true;
alan1974 0:a91cd1b08360 123 }
alan1974 5:abfe25f0de33 124 if(verbose)pc.printf("changing to subband: %d\r\n",sub_band);
alan1974 0:a91cd1b08360 125 // update network settings
alan1974 0:a91cd1b08360 126 public_network = bPublic;
alan1974 0:a91cd1b08360 127 frequency_sub_band =sub_band;
alan1974 0:a91cd1b08360 128 // start from a well-known state
alan1974 11:77fe4f18a81b 129 logInfo("defaulting Dot configuration");
alan1974 0:a91cd1b08360 130 if (dot->getJoinMode() != mDot::OTA) { // update configuration if necessary
alan1974 0:a91cd1b08360 131 logInfo("changing network join mode to OTA");
alan1974 0:a91cd1b08360 132 if (dot->setJoinMode(mDot::OTA) != mDot::MDOT_OK) {
alan1974 0:a91cd1b08360 133 logError("failed to set network join mode to OTA");
alan1974 0:a91cd1b08360 134 return false;
alan1974 0:a91cd1b08360 135 }
alan1974 0:a91cd1b08360 136 }
alan1974 0:a91cd1b08360 137 // in OTA and AUTO_OTA join modes, the credentials can be passed to the library as a name and passphrase or an ID and KEY
alan1974 0:a91cd1b08360 138 // only one method or the other should be used!
alan1974 0:a91cd1b08360 139 if (public_network){
alan1974 12:7944e4dbe853 140 update_ota_config_id_key(nvmData.key_AppEUI,nvmData.key_AppKey, frequency_sub_band, public_network, ack);
alan1974 0:a91cd1b08360 141 logInfo("-------------- network configured for public access -----------------------------");
alan1974 0:a91cd1b08360 142 }
alan1974 0:a91cd1b08360 143 else{
alan1974 0:a91cd1b08360 144 update_ota_config_name_phrase(network_name, network_passphrase, frequency_sub_band, public_network, ack);
alan1974 0:a91cd1b08360 145 logInfo("-------------- network configured for private access -------------------------------");
alan1974 1:0d25d9ddbe9f 146 }
alan1974 1:0d25d9ddbe9f 147 // configure network link check count
alan1974 1:0d25d9ddbe9f 148 // declares the Dot disconnected if no acks received within link_check_treshold transmits
alan1974 1:0d25d9ddbe9f 149 //update_network_link_check_config(3, 5);
alan1974 1:0d25d9ddbe9f 150 dot->setLinkCheckThreshold(link_check_treshold);
alan1974 11:77fe4f18a81b 151 return true;
alan1974 0:a91cd1b08360 152 }
alan1974 0:a91cd1b08360 153 //=================================================================================================
alan1974 0:a91cd1b08360 154 //main()
alan1974 0:a91cd1b08360 155 // main() runs in its own thread in the OS
alan1974 0:a91cd1b08360 156 // (note the calls to wait below for delays)
alan1974 0:a91cd1b08360 157 //=================================================================================================
alan1974 0:a91cd1b08360 158 int main() {
alan1974 1:0d25d9ddbe9f 159 uint8_t i;
alan1974 12:7944e4dbe853 160 RadioEvent events; //class to return info on rx pkts
alan1974 0:a91cd1b08360 161 mDotEvent mdotevent; //used to get ping info????
alan1974 0:a91cd1b08360 162 plan = new lora::ChannelPlan_US915();
alan1974 0:a91cd1b08360 163 #ifdef GPIO_ENABLE
alan1974 0:a91cd1b08360 164 gpio1.output();
alan1974 0:a91cd1b08360 165 gpio1 =0;
alan1974 0:a91cd1b08360 166 #endif
alan1974 0:a91cd1b08360 167 pc.baud(115200);
alan1974 11:77fe4f18a81b 168
alan1974 0:a91cd1b08360 169 pc.printf("\r\n**********************************************************\r\n");
alan1974 0:a91cd1b08360 170 pc.printf("\r\n XDOT BOOT\r\n");
alan1974 0:a91cd1b08360 171 pc.printf("COMM api_level = <HEX> %x.%x.%x.%x\r\n",api_level[0],api_level[1],api_level[2],api_level[3]);
alan1974 0:a91cd1b08360 172 pc.printf("COMM version = %x.%x.%x.%x\r\n",ver_level[0],ver_level[1],ver_level[2],ver_level[3]);
alan1974 1:0d25d9ddbe9f 173 pc.printf("**********************************************************\r\n");
alan1974 0:a91cd1b08360 174 assert(plan);
alan1974 0:a91cd1b08360 175 dot = mDot::getInstance(plan);
alan1974 1:0d25d9ddbe9f 176 assert(dot);
alan1974 1:0d25d9ddbe9f 177
alan1974 5:abfe25f0de33 178 dot->setEvents(&events);
alan1974 1:0d25d9ddbe9f 179 nvmRead(pNvmData);
alan1974 8:a5316708e51d 180
alan1974 5:abfe25f0de33 181 if (pNvmData->bLogOutputOn == 0){
alan1974 5:abfe25f0de33 182 pc.printf("\r\nDISABLING TERMINAL OUTPUT\r\n");
alan1974 10:061fab1195e7 183 dot->setLogLevel(mts::MTSLog::NONE_LEVEL); //doesn't work
alan1974 8:a5316708e51d 184 verbose = false;
alan1974 5:abfe25f0de33 185 }
alan1974 5:abfe25f0de33 186 else{
alan1974 5:abfe25f0de33 187 printNmvData(pNvmData);
alan1974 5:abfe25f0de33 188 dot->setLogLevel((verbose) ? mts::MTSLog::TRACE_LEVEL : mts::MTSLog::TRACE_LEVEL); // TRACE_LEVEL , INFO_LEVEL
alan1974 1:0d25d9ddbe9f 189 }
alan1974 7:fba1e8fc7693 190
alan1974 0:a91cd1b08360 191 // getStandbyFlag() should return the state of the standby flag directly from the processor
alan1974 0:a91cd1b08360 192 // Standby flag: This bit is set by hardware and cleared only by a POR/PDR (power on reset/power down reset) or by setting the CSBF bit in the PWR power control register (PWR_CR)
alan1974 0:a91cd1b08360 193 // 0: Device has not been in Standby mode
alan1974 0:a91cd1b08360 194 // 1: Device has been in Standby mode
alan1974 0:a91cd1b08360 195 // The xDot should enter standby mode when deep sleep in invoked. So you should see the standby flag set if it came out of deep sleep.
alan1974 1:0d25d9ddbe9f 196 if (!dot->getStandbyFlag()) { //if 0 => power-up/reset which should always be the case at this point
alan1974 5:abfe25f0de33 197 logInfo("mbed-os library version: %d", MBED_LIBRARY_VERSION);
alan1974 5:abfe25f0de33 198 frequency_sub_band = dot->getFrequencySubBand();
alan1974 5:abfe25f0de33 199 printRadioCfg();
alan1974 5:abfe25f0de33 200 cfg_network(true,public_network,frequency_sub_band); //force network cfg,
alan1974 0:a91cd1b08360 201 } else {
alan1974 0:a91cd1b08360 202 // restore the saved session (join OTAA info) if the dot woke from deepsleep mode
alan1974 0:a91cd1b08360 203 // useful to use with deepsleep because session info is otherwise lost when the dot enters deepsleep
alan1974 0:a91cd1b08360 204 logInfo("restoring network session from NVM");
alan1974 0:a91cd1b08360 205 dot->restoreNetworkSession();
alan1974 0:a91cd1b08360 206 }
alan1974 0:a91cd1b08360 207 //--------------------------------------------------------------------------------------------------------------------------------------------
alan1974 1:0d25d9ddbe9f 208 // configure network link check count
alan1974 1:0d25d9ddbe9f 209 // declares the Dot disconnected if no acks received within link_check_treshold transmits
alan1974 1:0d25d9ddbe9f 210 //update_network_link_check_config(3, 5);
alan1974 1:0d25d9ddbe9f 211 dot->setLinkCheckThreshold(link_check_treshold);
alan1974 0:a91cd1b08360 212 //----------------------------------------------------------------------------------------------------------------------------------------------
alan1974 0:a91cd1b08360 213
alan1974 0:a91cd1b08360 214 // save changes to configuration
alan1974 0:a91cd1b08360 215 // logInfo("saving configuration");
alan1974 0:a91cd1b08360 216
alan1974 1:0d25d9ddbe9f 217 eui = mts::Text::bin2hexString(dot->getDeviceId()).c_str();
alan1974 5:abfe25f0de33 218 if(verbose)pc.printf("\r\nEUI: %s\r\n",eui);
alan1974 1:0d25d9ddbe9f 219 bool joined = false;
alan1974 8:a5316708e51d 220
alan1974 1:0d25d9ddbe9f 221 i2c_proc_init(); //init i2c comm
alan1974 8:a5316708e51d 222 sleep_wake_interrupt_only(deep_sleep); //wake on rising edge of wake signal from proc
alan1974 0:a91cd1b08360 223 //scope test
alan1974 10:061fab1195e7 224 #ifdef GPIO_ENABLE
alan1974 10:061fab1195e7 225 gpio1 =1;
alan1974 10:061fab1195e7 226 #endif
alan1974 0:a91cd1b08360 227 //==============================================================================
alan1974 0:a91cd1b08360 228 // -loop here forever
alan1974 0:a91cd1b08360 229 // -sleep until LORA_WAKE goes hi => proc ready to send i2c cmd
alan1974 0:a91cd1b08360 230 // -start polling incoming i2c bus for proc cmd
alan1974 0:a91cd1b08360 231 // -execute cmd
alan1974 0:a91cd1b08360 232 // -take control of LORA_WAKE and toggle it hi to signal proc that xdot
alan1974 0:a91cd1b08360 233 // ready to send i2c ack message
alan1974 0:a91cd1b08360 234 // -go back to sleep
alan1974 0:a91cd1b08360 235 //==============================================================================
alan1974 0:a91cd1b08360 236 bool bPulseLoraWake = false;
alan1974 0:a91cd1b08360 237 while(1)
alan1974 0:a91cd1b08360 238 {
alan1974 13:1f3a8d0be511 239 if(verbose)pc.printf("\n\r***************************** ");
alan1974 0:a91cd1b08360 240
alan1974 0:a91cd1b08360 241 switch (i2c_proc_comm()){
alan1974 7:fba1e8fc7693 242 case I2C_WRITE: //xdot ack ->proc
alan1974 5:abfe25f0de33 243 if(verbose)pc.printf("\n\r xdot ack -> proc done,going to sleep\n\r ");
alan1974 0:a91cd1b08360 244 bPulseLoraWake = false;
alan1974 10:061fab1195e7 245 #ifdef GPIO_ENABLE
alan1974 10:061fab1195e7 246 gpio1 =0;
alan1974 10:061fab1195e7 247 #endif
alan1974 10:061fab1195e7 248 wait_us(wait_before_sleep_usec); //wait for i2c to complete data transfer before sleeping
alan1974 8:a5316708e51d 249 sleep_wake_interrupt_only(deep_sleep); ////sleep until rising edge of wake signal from proc
alan1974 10:061fab1195e7 250 #ifdef GPIO_ENABLE
alan1974 10:061fab1195e7 251 gpio1 =1;
alan1974 10:061fab1195e7 252 #endif
alan1974 8:a5316708e51d 253 if(verbose)pc.printf("\n\r lora wake detected -> monitoring i2c bus\n\r ");
alan1974 0:a91cd1b08360 254 break;
alan1974 0:a91cd1b08360 255 case I2C_READ: //xdot <- proc
alan1974 0:a91cd1b08360 256 bPulseLoraWake = true;
alan1974 0:a91cd1b08360 257 switch (buf_rcv[0])
alan1974 0:a91cd1b08360 258 {
alan1974 1:0d25d9ddbe9f 259 case XDOT_CMD_XMIT_PKT:
alan1974 7:fba1e8fc7693 260 pkt_upstrm *pUp= (pkt_upstrm*)&buf_rcv[0];
alan1974 7:fba1e8fc7693 261 for (i=0; i < sizeof(buf_xmt);i++)buf_xmt[i] = 0xff; //bfr fill
alan1974 7:fba1e8fc7693 262 pkt_ack *pAck = (pkt_ack*)&buf_xmt[0];
alan1974 0:a91cd1b08360 263 pAck->ack = I2C_ACK_PROC;
alan1974 5:abfe25f0de33 264 pAck->cmd = XDOT_CMD_XMIT_PKT;
alan1974 7:fba1e8fc7693 265 pAck->dataLen = pUp->dataLen; //data len of xmitted pkt
alan1974 7:fba1e8fc7693 266 if(verbose)pc.printf("\r\npkt to xmit data len: %d\r\n",pAck->dataLen);
alan1974 5:abfe25f0de33 267 uint8_t chksum = chksum_proc(buf_rcv);
alan1974 7:fba1e8fc7693 268 if(verbose)pc.printf("\r\nI2C chksum rcvd/computer: %d/%d ",pUp->chksum,chksum);
alan1974 0:a91cd1b08360 269 pAck->bXmitAttempted = 1;
alan1974 0:a91cd1b08360 270 pAck->chksum_err = 0;
alan1974 0:a91cd1b08360 271 if(pUp->chksum != chksum){
alan1974 7:fba1e8fc7693 272 if(verbose)pc.printf(" chksum err, aborting xmit");
alan1974 0:a91cd1b08360 273 pAck->bXmitAttempted = 0;
alan1974 11:77fe4f18a81b 274 // pAck->mdot_ret = -2048; //wbit rtn code?
alan1974 11:77fe4f18a81b 275 pAck->mdot_ret = XDOT_ERR_I2C_CHKSUM;
alan1974 11:77fe4f18a81b 276 pAck->chksum_err = 1;
alan1974 11:77fe4f18a81b 277 break;
alan1974 0:a91cd1b08360 278 }
alan1974 1:0d25d9ddbe9f 279 //rev 0307 parameters
alan1974 5:abfe25f0de33 280 if(verbose)pc.printf("\n\r setting application port %d ",pUp->appPort); //appPort not used in rev < 0307
alan1974 1:0d25d9ddbe9f 281 dot->setAppPort(pUp->appPort);
alan1974 6:b2039a285d7f 282 uint8_t linkThresholdCnt = pUp->linkThreshCnt;
alan1974 11:77fe4f18a81b 283 if(verbose)pc.printf("\r\n linkThreshCnt %d\r\n",linkThresholdCnt);
alan1974 6:b2039a285d7f 284 dot->setLinkCheckThreshold(linkThresholdCnt);
alan1974 11:77fe4f18a81b 285
alan1974 0:a91cd1b08360 286 if (pUp->dataLen == 0){ //datalen non zero?
alan1974 0:a91cd1b08360 287 pAck->bXmitAttempted = 0;
alan1974 0:a91cd1b08360 288 break;
alan1974 0:a91cd1b08360 289 }
alan1974 0:a91cd1b08360 290 upstream_packet.clear(); //xfr data from incoming bfr to xmit bfr
alan1974 0:a91cd1b08360 291 for (i=0; i< pUp->dataLen;i++) upstream_packet.push_back(pUp->txData[i]);
alan1974 0:a91cd1b08360 292
alan1974 5:abfe25f0de33 293 if(verbose){
alan1974 7:fba1e8fc7693 294 pc.printf("\r\n[TEST],Upstream Packet Received");
alan1974 5:abfe25f0de33 295 for(std::vector<uint8_t>::iterator it = upstream_packet.begin(); it != upstream_packet.end(); ++it)
alan1974 5:abfe25f0de33 296 pc.printf(",0x%x", *it);
alan1974 5:abfe25f0de33 297 pc.printf("\r\n"); // see i told you.
alan1974 5:abfe25f0de33 298 }
alan1974 0:a91cd1b08360 299 joined = dot->getNetworkJoinStatus(); //are we joined to Lorawan?
alan1974 0:a91cd1b08360 300 pAck->joinAttempts = 0; //no attempts made yet to join
alan1974 1:0d25d9ddbe9f 301 pAck->bAck = 0; //won't know if we receive a lorawan ack until after xmit
alan1974 1:0d25d9ddbe9f 302 pAck->bAckdata = 0; //won't know if we receive a lorawan ack downstream data until after xmit
alan1974 7:fba1e8fc7693 303 pAck->rssi = 0; //if not rx1/rx2 then no RSSI value
alan1974 7:fba1e8fc7693 304 pAck->snr = 0; //if not rx1/rx2 then no SNR value
alan1974 1:0d25d9ddbe9f 305 if(!joined) { //if not previously joined, then need to join now
alan1974 0:a91cd1b08360 306 pAck->bJoined = 0;
alan1974 5:abfe25f0de33 307 if(verbose)pc.printf("\r\n----------- NETWORK NOT JOINED YET, WILL TRY TO JOIN %d TIMES\r\n",pUp->joinAttemps);
alan1974 14:fc836a5a5d2f 308 joined = join_network_wbit(pUp->joinAttemps); //try joinAttemps times to join network
alan1974 14:fc836a5a5d2f 309 pAck->joinAttempts = join_network_attempts_wbit(); //# of join attemps made
alan1974 14:fc836a5a5d2f 310 pAck->mdot_ret = dot->send(upstream_packet); //<--------------------------------------- extra xmit ???????????????
alan1974 5:abfe25f0de33 311 if (!joined)
alan1974 5:abfe25f0de33 312 if(verbose)pc.printf("\r\n----------- FAILED TO JOIN...GIVING UP\r\n"); // join network if not joined
alan1974 14:fc836a5a5d2f 313 else {
alan1974 14:fc836a5a5d2f 314 save_OTAA_session_keys();
alan1974 14:fc836a5a5d2f 315 }
alan1974 0:a91cd1b08360 316 }
alan1974 11:77fe4f18a81b 317 if (joined)
alan1974 11:77fe4f18a81b 318 {
alan1974 1:0d25d9ddbe9f 319 pAck->bJoined = 1; //we are joined to the network
alan1974 0:a91cd1b08360 320 packets_sent++;
alan1974 11:77fe4f18a81b 321 bRxDone = false; //true if callback function RxDone() triggered
alan1974 11:77fe4f18a81b 322 bDownLinkCntrFail = false; //true if callback function RxDone() triggered and bad downlink frame count
alan1974 11:77fe4f18a81b 323
alan1974 12:7944e4dbe853 324 //send packet -> return code indicates results, send return code back to proc Dec14,2017
alan1974 5:abfe25f0de33 325 pAck->mdot_ret = dot->send(upstream_packet); //xmit the pkt in blocking mode, return false if no ack
alan1974 7:fba1e8fc7693 326 if (verbose)printf("\n\rdata->send() return code: %d\r\n",pAck->mdot_ret);
alan1974 11:77fe4f18a81b 327 if (pAck->mdot_ret == mDot::MDOT_OK)
alan1974 11:77fe4f18a81b 328 {
alan1974 0:a91cd1b08360 329 acks_rcvd++;
alan1974 0:a91cd1b08360 330 pAck->bAck = 1; //we got a Rx1 or Rx2 ack
alan1974 7:fba1e8fc7693 331 mDot::rssi_stats rssiStats = dot->getRssiStats(); //rssi stat
alan1974 0:a91cd1b08360 332 pAck->rssi = (int8_t)rssiStats.last;
alan1974 7:fba1e8fc7693 333 mDot::snr_stats snrStats = dot->getSnrStats(); //snr stat
alan1974 7:fba1e8fc7693 334 pAck->snr = (int8_t)snrStats.last;
alan1974 7:fba1e8fc7693 335 if (verbose)printf("\n\rdata->send()=true; ack:%d, rssi:%d snr:%d\r\n",pAck->bAck,pAck->rssi,pAck->snr);
alan1974 7:fba1e8fc7693 336 if (events.is_packet_received()){ //downstream data from the Rx1/Rx2 pkt?
alan1974 5:abfe25f0de33 337 if (verbose)printf("\n\revents.is_packet_received = true\r\n");
alan1974 0:a91cd1b08360 338 pAck->bAckdata = 1;
alan1974 0:a91cd1b08360 339 upstream_packet.clear();
alan1974 0:a91cd1b08360 340 upstream_packet = events.get_downstream_packet();
alan1974 12:7944e4dbe853 341 pAck->rxLen = upstream_packet.size();
alan1974 12:7944e4dbe853 342 pAck->appPort = events.port;
alan1974 0:a91cd1b08360 343 if (pAck->rxLen > I2C_MAX_ACK_DATA){
alan1974 5:abfe25f0de33 344 if(verbose)pc.printf("\r\n got ack with pkt data too large.. rejected\r\n");
alan1974 0:a91cd1b08360 345 break;
alan1974 5:abfe25f0de33 346 }
alan1974 5:abfe25f0de33 347 if(verbose){
alan1974 5:abfe25f0de33 348 pc.printf("\r\n pkt data: ");
alan1974 5:abfe25f0de33 349 for (i=0; i< pAck->rxLen;i++) {
alan1974 5:abfe25f0de33 350 pAck->rxData[i]= upstream_packet[i];
alan1974 5:abfe25f0de33 351 pc.printf(" %x",pAck->rxData[i]);
alan1974 5:abfe25f0de33 352 }
alan1974 0:a91cd1b08360 353 }
alan1974 0:a91cd1b08360 354 } //if downstream data rcvd
alan1974 0:a91cd1b08360 355 else{
alan1974 11:77fe4f18a81b 356 if (verbose)printf("\n\r ack rcvd without data\r\n");
alan1974 11:77fe4f18a81b 357 } //else
alan1974 7:fba1e8fc7693 358 } //send()
alan1974 11:77fe4f18a81b 359 //rev 0308 parameters
alan1974 11:77fe4f18a81b 360 else
alan1974 11:77fe4f18a81b 361 {
alan1974 11:77fe4f18a81b 362 if (verbose)printf("\n\r no ack rcvd \r\n"); //could be some other error
alan1974 11:77fe4f18a81b 363 if ((pAck->mdot_ret != 0) && bRxDone) //chk if callback function triggered
alan1974 11:77fe4f18a81b 364 {
alan1974 11:77fe4f18a81b 365 if (bDownLinkCntrFail)pAck->mdot_ret = XDOT_ERR_FRAME_CNT; //bad downlink frame count return err code
alan1974 11:77fe4f18a81b 366 }
alan1974 0:a91cd1b08360 367 }
alan1974 0:a91cd1b08360 368 }//if joined
alan1974 0:a91cd1b08360 369 break;
alan1974 0:a91cd1b08360 370 case XDOT_CMD_SET_RADIO:
alan1974 5:abfe25f0de33 371 if(verbose)pc.printf("\n\r proc cmd: CMD_SET_RADIO");
alan1974 0:a91cd1b08360 372 pkt_setradiodwn *pDwnRadio= (pkt_setradiodwn*)&buf_xmt[0];
alan1974 0:a91cd1b08360 373 pkt_setradioup *pUpRadio = (pkt_setradioup*)&buf_rcv[0];
alan1974 0:a91cd1b08360 374 pDwnRadio->ack = I2C_ACK_PROC;
alan1974 0:a91cd1b08360 375 pDwnRadio->cmd = XDOT_CMD_SET_RADIO;
alan1974 0:a91cd1b08360 376
alan1974 0:a91cd1b08360 377 if (pUpRadio->bSetParams){
alan1974 7:fba1e8fc7693 378 if(verbose)pc.printf("\n\r setting radio params");
alan1974 7:fba1e8fc7693 379 if(verbose)pc.printf("\n\r setting adr to %d ",pUpRadio->params.aDR);
alan1974 7:fba1e8fc7693 380 if (pUpRadio->params.aDR == 1) dot->setAdr(true); //test for adr problem
alan1974 7:fba1e8fc7693 381 else dot->setAdr(false);
alan1974 7:fba1e8fc7693 382 dot->setAdr((uint8_t)pUpRadio->params.aDR); // enable or disable Adaptive Data Rate
alan1974 5:abfe25f0de33 383 if(verbose)pc.printf("\n\r setting subband to %d ",pUpRadio->params.sub_band);
alan1974 2:0af50f386eb2 384 cfg_network(false,true,(uint8_t)pUpRadio->params.sub_band);
alan1974 7:fba1e8fc7693 385
alan1974 7:fba1e8fc7693 386 if(verbose)pc.printf("\n\r setting public/private network to %d ",pUpRadio->params.public_network);
alan1974 7:fba1e8fc7693 387 //public_network = (bool)pUpRadio->params.public_network;
alan1974 7:fba1e8fc7693 388 dot->setPublicNetwork((bool)pUpRadio->params.public_network);
alan1974 7:fba1e8fc7693 389
alan1974 5:abfe25f0de33 390 if(verbose)pc.printf("\n\r setting antenna gain to %d ",pUpRadio->params.antennaGaindBi);
alan1974 2:0af50f386eb2 391 dot->setAntennaGain(pUpRadio->params.antennaGaindBi);
alan1974 10:061fab1195e7 392 if(verbose)pc.printf("\n\r setting radio tx power to %d ",pUpRadio->params.txPower);
alan1974 10:061fab1195e7 393 dot->setTxPower(pUpRadio->params.txPower);
alan1974 5:abfe25f0de33 394 if(verbose)pc.printf("\n\r setting tx datarate to %d ",pUpRadio->params.dataRate);
alan1974 2:0af50f386eb2 395 dot->setTxDataRate(pUpRadio->params.dataRate);
alan1974 5:abfe25f0de33 396 if(verbose)pc.printf("\n\r setting tx inverted to %d ",(bool)pUpRadio->params.txInverted);
alan1974 5:abfe25f0de33 397 dot->setTxInverted((bool)pUpRadio->params.txInverted);
alan1974 5:abfe25f0de33 398 if(verbose)pc.printf("\n\r setting rx inverted to %d ",(bool)pUpRadio->params.rxInverted);
alan1974 5:abfe25f0de33 399 dot->setRxInverted((bool)pUpRadio->params.rxInverted);
alan1974 5:abfe25f0de33 400 if(verbose)pc.printf("\n\r setting rx delay to %d ",pUpRadio->params.rxDelay);
alan1974 5:abfe25f0de33 401 dot->setRxDelay(pUpRadio->params.rxDelay);
alan1974 5:abfe25f0de33 402 if(verbose)pc.printf("\n\r setting join delay to %d ",pUpRadio->params.join_delay);
alan1974 7:fba1e8fc7693 403 dot->setJoinDelay(pUpRadio->params.join_delay);
alan1974 5:abfe25f0de33 404 if(verbose)pc.printf("\n\r saving configuration");
alan1974 0:a91cd1b08360 405 if (!dot->saveConfig())logError("failed to save configuration");
alan1974 7:fba1e8fc7693 406
alan1974 0:a91cd1b08360 407 display_config();
alan1974 0:a91cd1b08360 408 }
alan1974 7:fba1e8fc7693 409 if(verbose)pc.printf("\n\r reading radio params");
alan1974 2:0af50f386eb2 410 pDwnRadio->params.public_network = public_network;
alan1974 2:0af50f386eb2 411 pDwnRadio->params.sub_band = dot->getFrequencySubBand();
alan1974 5:abfe25f0de33 412 pDwnRadio->params.join_delay = dot->getJoinDelay();
alan1974 5:abfe25f0de33 413 pDwnRadio->params.txInverted = dot->getTxInverted();
alan1974 5:abfe25f0de33 414 pDwnRadio->params.rxInverted = dot->getRxInverted();
alan1974 5:abfe25f0de33 415 pDwnRadio->params.rxDelay = dot->getRxDelay();
alan1974 2:0af50f386eb2 416 pDwnRadio->params.maxDataLen = dot->getMaxPacketLength();
alan1974 2:0af50f386eb2 417 pDwnRadio->params.maxTxPowerdBm = dot->getMaxTxPower();
alan1974 2:0af50f386eb2 418 pDwnRadio->params.minTxPowerdBm = dot->getMinTxPower();
alan1974 2:0af50f386eb2 419 pDwnRadio->params.aDR = dot->getAdr();
alan1974 2:0af50f386eb2 420 pDwnRadio->params.antennaGaindBi = dot->getAntennaGain();
alan1974 10:061fab1195e7 421 pDwnRadio->params.txPower = dot->getTxPower(); //programmed tx power (non-adr)
alan1974 10:061fab1195e7 422 pDwnRadio->params.dataRate = dot->getTxDataRate(); //programmed data rate (non-adr)
alan1974 10:061fab1195e7 423 pDwnRadio->params.dataRateCurrent = dot->getSettings()->Session.TxDatarate; //presently used data rate (adr can change this);see Lora.h
alan1974 10:061fab1195e7 424 pDwnRadio->params.txPowerCurrent = dot->getSettings()->Session.TxPower;//presently used tx power (adr can change this);see Lora.h
alan1974 10:061fab1195e7 425 pDwnRadio->params.rx1DelayCurrent = dot->getSettings()->Session.RxDelay;//presently used rx1_delay;see Lora.h
alan1974 10:061fab1195e7 426
alan1974 10:061fab1195e7 427
alan1974 0:a91cd1b08360 428 break;
alan1974 0:a91cd1b08360 429 case XDOT_CMD_GET_EUI: //0307: modified to include radio parameter settings
alan1974 5:abfe25f0de33 430 if(verbose)pc.printf("\n\r proc cmd: get EUI");
alan1974 0:a91cd1b08360 431 pkt_eui *peui = (pkt_eui*)&buf_xmt[0];
alan1974 0:a91cd1b08360 432 peui->ack = I2C_ACK_PROC;
alan1974 0:a91cd1b08360 433 peui->cmd = XDOT_CMD_GET_EUI;
alan1974 0:a91cd1b08360 434 upstream_packet.clear();
alan1974 0:a91cd1b08360 435 upstream_packet = dot->getDeviceId();
alan1974 0:a91cd1b08360 436 peui->dataLen = upstream_packet.size();
alan1974 0:a91cd1b08360 437 for (i=0; i< peui->dataLen;i++) peui->euiData[i] = upstream_packet[i];
alan1974 0:a91cd1b08360 438 for (i=0; i< 4;i++) peui->apiLvlData[i] = api_level[i];
alan1974 0:a91cd1b08360 439 for (i=0; i< 4;i++) peui->verLvlData[i] = ver_level[i];
alan1974 0:a91cd1b08360 440 peui->dataLen = sizeof(pkt_eui)-3; //size of struc minus first 3 bytes
alan1974 9:cc23b2049639 441 if(verbose)pc.printf("\n\r eui data length: %d",peui->dataLen);
alan1974 0:a91cd1b08360 442 break;
alan1974 9:cc23b2049639 443 case XDOT_CMD_NVM:
alan1974 12:7944e4dbe853 444 if(verbose)pc.printf("\n\r proc cmd: NVM OTAA");
alan1974 9:cc23b2049639 445 pkt_setnvmup *pUpNvm = (pkt_setnvmup*)&buf_rcv[0];
alan1974 9:cc23b2049639 446 pkt_setnvmdwn *pDwnNvm= (pkt_setnvmdwn*)&buf_xmt[0];
alan1974 9:cc23b2049639 447 pDwnNvm->ack = I2C_ACK_PROC;
alan1974 9:cc23b2049639 448 pDwnNvm->cmd = XDOT_CMD_NVM;
alan1974 9:cc23b2049639 449 pDwnNvm->dataLen = sizeof(nvm)-2;
alan1974 9:cc23b2049639 450 if (pUpNvm->nvm_option == XDOT_NVM_SET) nvmWrite(&pUpNvm->nvmData);
alan1974 9:cc23b2049639 451 if (pUpNvm->nvm_option == XDOT_NVM_RESTORE) nvmRestore(&pUpNvm->nvmData);
alan1974 9:cc23b2049639 452
alan1974 9:cc23b2049639 453 pDwnNvm->bChkSumOK = 0;
alan1974 9:cc23b2049639 454 if (nvmRead(&pDwnNvm->nvmData))
alan1974 9:cc23b2049639 455 pDwnNvm->bChkSumOK = 1;
alan1974 9:cc23b2049639 456 printNmvData(&pDwnNvm->nvmData);
alan1974 12:7944e4dbe853 457 break;
alan1974 12:7944e4dbe853 458 case XDOT_CMD_NVM_ABP:
alan1974 12:7944e4dbe853 459 if(verbose)pc.printf("\n\r proc cmd: NVM ABP");
alan1974 12:7944e4dbe853 460 pkt_setnvmABPup *pUpNvmABP = (pkt_setnvmABPup*)&buf_rcv[0];
alan1974 12:7944e4dbe853 461 pkt_setnvmABPdwn *pDwnNvmABP= (pkt_setnvmABPdwn*)&buf_xmt[0];
alan1974 12:7944e4dbe853 462 pDwnNvmABP->ack = I2C_ACK_PROC;
alan1974 12:7944e4dbe853 463 pDwnNvmABP->cmd = XDOT_CMD_NVM_ABP;
alan1974 13:1f3a8d0be511 464 pDwnNvmABP->dataLen = sizeof(nvmABP)-2;
alan1974 12:7944e4dbe853 465 if (pUpNvmABP->nvm_option == XDOT_NVM_SET) nvmWriteABP(&pUpNvmABP->nvmData);
alan1974 12:7944e4dbe853 466
alan1974 12:7944e4dbe853 467 pDwnNvmABP->bChkSumOK = 0;
alan1974 12:7944e4dbe853 468 if (nvmReadABP(&pDwnNvmABP->nvmData))
alan1974 12:7944e4dbe853 469 pDwnNvmABP->bChkSumOK = 1;
alan1974 12:7944e4dbe853 470 printNvmABPData(&pDwnNvmABP->nvmData);
alan1974 12:7944e4dbe853 471
alan1974 12:7944e4dbe853 472 break;
alan1974 14:fc836a5a5d2f 473
alan1974 14:fc836a5a5d2f 474 case XDOT_CMD_SET_RADIO_CLASS: //multicast_change_class A or C (change only after a join!)
alan1974 14:fc836a5a5d2f 475 if(verbose)pc.printf("\n\r proc cmd: change radio class\r\n");
alan1974 14:fc836a5a5d2f 476 pkt_setClassUp *pUpSetClass = (pkt_setClassUp*)&buf_rcv[0];
alan1974 14:fc836a5a5d2f 477 pkt_setClassDwn *pDwnSetClass = (pkt_setClassDwn*)&buf_xmt[0];
alan1974 14:fc836a5a5d2f 478 pDwnSetClass->ack = I2C_ACK_PROC;
alan1974 14:fc836a5a5d2f 479 pDwnSetClass->cmd = XDOT_CMD_SET_RADIO_CLASS;
alan1974 14:fc836a5a5d2f 480 pDwnSetClass->dataLen = sizeof(class_switch)-2;
alan1974 14:fc836a5a5d2f 481 bool bOk = multicast_change_class(&pUpSetClass->classData);
alan1974 14:fc836a5a5d2f 482 pDwnSetClass->bSwitched = bOk;
alan1974 14:fc836a5a5d2f 483 break;
alan1974 14:fc836a5a5d2f 484
alan1974 14:fc836a5a5d2f 485
alan1974 14:fc836a5a5d2f 486
alan1974 14:fc836a5a5d2f 487
alan1974 14:fc836a5a5d2f 488
alan1974 14:fc836a5a5d2f 489
alan1974 14:fc836a5a5d2f 490
alan1974 12:7944e4dbe853 491
alan1974 1:0d25d9ddbe9f 492 case XDOT_CMD_SET_NTWKSESS: //read or write network seesion to xdot flash
alan1974 1:0d25d9ddbe9f 493 bool bWriteSession = (bool)buf_rcv[1];
alan1974 1:0d25d9ddbe9f 494 if (bWriteSession){
alan1974 5:abfe25f0de33 495 if(verbose)pc.printf("\n\r proc cmd writing network sesion to flash");
alan1974 1:0d25d9ddbe9f 496 dot->saveNetworkSession();
alan1974 1:0d25d9ddbe9f 497 }
alan1974 1:0d25d9ddbe9f 498 else{
alan1974 5:abfe25f0de33 499 if(verbose)pc.printf("\n\r reading network session from flash");
alan1974 1:0d25d9ddbe9f 500 dot->restoreNetworkSession();
alan1974 1:0d25d9ddbe9f 501 }
alan1974 1:0d25d9ddbe9f 502 pkt_ntwrk *pktwrk = (pkt_ntwrk*)&buf_xmt[0];
alan1974 1:0d25d9ddbe9f 503 pktwrk->ack = I2C_ACK_PROC;
alan1974 1:0d25d9ddbe9f 504 pktwrk->cmd = XDOT_CMD_SET_NTWKSESS;
alan1974 1:0d25d9ddbe9f 505 pktwrk->bSetNetwrk = (uint8_t)bWriteSession;
alan1974 9:cc23b2049639 506 break;
alan1974 0:a91cd1b08360 507 case XDOT_CMD_SET_KEY_X:
alan1974 7:fba1e8fc7693 508 if(verbose)pc.printf("\n\r proc cmd: this command not used\r\n");
alan1974 0:a91cd1b08360 509 wait_ms(I2C_MIN_WAIT_DELAY);
alan1974 0:a91cd1b08360 510 buf_xmt[0] = I2C_ACK_PROC;
alan1974 0:a91cd1b08360 511 buf_xmt[1] = XDOT_CMD_SET_KEY_X;
alan1974 0:a91cd1b08360 512 break;
alan1974 0:a91cd1b08360 513 case XDOT_CMD_GATEWAY_PING:
alan1974 5:abfe25f0de33 514 if(verbose)pc.printf("\n\r proc cmd: xmit gateway ping\r\n");
alan1974 0:a91cd1b08360 515 pkt_ping *pPing = (pkt_ping*)&buf_xmt[0];
alan1974 0:a91cd1b08360 516 pPing->ack = I2C_ACK_PROC;
alan1974 0:a91cd1b08360 517 pPing->cmd = XDOT_CMD_GATEWAY_PING;
alan1974 0:a91cd1b08360 518 pPing->dataLen = 3; //only 3 bytes returned
alan1974 5:abfe25f0de33 519 if(verbose)pc.printf("\r\n----------- SENDING GATEWAY PING \r\n");
alan1974 0:a91cd1b08360 520 mDot::ping_response ping_res;
alan1974 0:a91cd1b08360 521 ping_res = dot->ping();
alan1974 0:a91cd1b08360 522 pPing->status = (int8_t)ping_res.status;
alan1974 0:a91cd1b08360 523 pPing->rssi = (int8_t)ping_res.rssi;
alan1974 0:a91cd1b08360 524 pPing->snr = (int8_t)ping_res.snr;
alan1974 0:a91cd1b08360 525 if (ping_res.status == 0)
alan1974 5:abfe25f0de33 526 if(verbose)pc.printf("\r\n----------- GATEWAY PING SUCCEEDED \r\n");
alan1974 0:a91cd1b08360 527 else
alan1974 5:abfe25f0de33 528 if(verbose)pc.printf("\r\n----------- GATEWAY PING FAIL \r\n");
alan1974 0:a91cd1b08360 529 break;
alan1974 0:a91cd1b08360 530 default:
alan1974 5:abfe25f0de33 531 if(verbose)pc.printf("\n\r proc cmd not recognized:%x",buf_rcv[0]);
alan1974 0:a91cd1b08360 532 wait_ms(I2C_MIN_WAIT_DELAY);
alan1974 0:a91cd1b08360 533 buf_xmt[0] = I2C_ACK_PROC;
alan1974 0:a91cd1b08360 534 buf_xmt[1] = XDOT_CMD_UNDEFINED;
alan1974 0:a91cd1b08360 535 } //switch buf_rcv[0]
alan1974 0:a91cd1b08360 536 //gpio1 =1; //test
alan1974 0:a91cd1b08360 537 if (bPulseLoraWake) i2c_pulse_wake(); //pulse wake-up lo->hi->lo to signal proc that xdot ready to send ack
alan1974 0:a91cd1b08360 538
alan1974 0:a91cd1b08360 539 } //switch i2c_proc_comm
alan1974 0:a91cd1b08360 540 } //while
alan1974 0:a91cd1b08360 541
alan1974 0:a91cd1b08360 542 } //main
alan1974 0:a91cd1b08360 543