voidsetup() {auto&& set =the_twelite.settings.use<STG_STD>();auto&& nwk =the_twelite.network.use<NWK_SIMPLE>(); /*** INTERACTIE MODE */ // settings: configure items set << SETTINGS::appname("WirelessUART"); set << SETTINGS::appid_default(DEFAULT_APP_ID); // set default appID set << SETTINGS::ch_default(DEFAULT_CHANNEL); // set default channel set << SETTINGS::lid_default(DEFAULT_LID); // set default lid set.hide_items(E_STGSTD_SETID::OPT_DWORD2, E_STGSTD_SETID::OPT_DWORD3, E_STGSTD_SETID::OPT_DWORD4, E_STGSTD_SETID::ENC_KEY_STRING, E_STGSTD_SETID::ENC_MODE);
set.reload(); // load from EEPROM. /*** SETUP section */ // the twelite main class the_twelite<< set // from iteractive mode (APPID/CH/POWER)<< TWENET::rx_when_idle(); // open receive circuit (if not set, it can't listen packts from others) // Register Network nwk << set; // from interactive mode (LID/REPEAT) /*** BEGIN section */SerialParser.begin(PARSER::ASCII,128); // Initialize the serial parserthe_twelite.begin(); // start twelite! /*** INIT message */ Serial <<"--- WirelessUart (id="<<int(nwk.get_config().u8Lid) <<") ---"<< mwx::crlf;}
while(Serial.available()) {if (SerialParser.parse(Serial.read())) { Serial <<".."<< SerialParser;constuint8_t* b =SerialParser.get_buf().begin();uint8_t addr =*b; ++b; // the first byte is destination address.transmit(addr, b,SerialParser.get_buf().end()); }}