void initBitlash(unsigned long baud) { #if defined(TINY_BUILD) beginSerial(9600); #else beginSerial(baud); #endif #if defined(ARM_BUILD) eeinit(); #endif initTaskList(); vinit(); displayBanner(); #if !defined(TINY_BUILD) // Run the script named "startup" if there is one strncpy_P(lbuf, getmsg(M_startup), STRVALLEN); // get the name "startup" in our cmd buf //if (findKey(lbuf) >= 0) doCommand(lbuf); // look it up. exists? call it. if (findscript(lbuf)) doCommand(lbuf); // look it up. exists? call it. #endif initlbuf(); }
void prompt(void) { char buf[IDLEN+1]; // Run the script named "prompt" if there is one else print "> " strncpy_P(buf, getmsg(M_promptid), IDLEN); // get the name "prompt" in our cmd buf if (findscript(buf)) doCommand(buf); else msgp(M_prompt); // else print default prompt }
void prompt(void) { char buf[IDLEN+1]; #if defined(TINY_BUILD) msgp(M_prompt); #else // Run the script named "prompt" if there is one else print "> " strncpy_P(buf, getmsg(M_promptid), IDLEN); // get the name "prompt" in our cmd buf if (findscript(buf)) doCommand(buf); else if (find_user_function(buf)) dofunctioncall(symval); else msgp(M_prompt); // else print default prompt #endif }
// Parse an identifier from the input stream void parseid(void) { char c = *idbuf = tolower(inchar); byte idbuflen = 1; fetchc(); while (isalnum(inchar) || (inchar == '.') || (inchar == '_')) { if (idbuflen >= IDLEN) overflow(M_id); idbuf[idbuflen++] = tolower(inchar); fetchc(); } idbuf[idbuflen] = 0; // do we have a one-char alpha nvar identifier? if ((idbuflen == 1) && isalpha(c)) { sym = s_nvar; symval = c - 'a'; } // a pin identifier 'a'digit* or 'd'digit*? else if ((idbuflen <= 3) && ((c == 'a') || (c == 'd')) && isdigit(idbuf[1]) && ( #if !defined(TINY85) isdigit(idbuf[2]) || #endif (idbuf[2] == 0))) { sym = (c == 'a') ? s_apin : s_dpin; symval = pinnum(idbuf); } // reserved word? else if (findindex(idbuf, (const prog_char *) reservedwords, 1)) { sym = pgm_read_byte(reservedwordtypes + symval); // e.g., s_if or s_while } // function? else if (findindex(idbuf, (const prog_char *) functiondict, 1)) sym = s_nfunct; #ifdef LONG_ALIASES else if (findindex(idbuf, (const prog_char *) aliasdict, 0)) sym = s_nfunct; #endif #ifdef PIN_ALIASES else if (findpinname(idbuf)) {;} // sym and symval are set in findpinname #endif #ifdef USER_FUNCTIONS else if (find_user_function(idbuf)) sym = s_nfunct; #endif else findscript(idbuf); }
static bool fieldAnnouncements(NWK_DataInd_t *ind) { char *data = (char*)ind->data; // be safe if (!ind->options & NWK_IND_OPT_MULTICAST) { return true; } if (hqVerboseOutput) { Serial.print(F("multicast in ")); Serial.println(ind->dstAddr); } if (Scout.isLeadScout()) { leadAnnouncementSend(ind->dstAddr, ind->srcAddr, ConstBuf(data, ind->size-1)); // no null } if (!ind->dstAddr || ind->dstAddr == 0xBEEF || strlen(data) < 3 || data[0] != '[') { return false; } int keys[10]; keyLoad((char*)ind->data, keys, millis()); // run the Bitlash callback function, if defined StringBuffer callback(20); callback.appendSprintf("on.message.group", ind->dstAddr); if (find_user_function(const_cast<char*>(callback.c_str())) || findscript(const_cast<char*>(callback.c_str()))) { StringBuffer buf(64, 16); buf.appendSprintf("on.message.group(%d,%d", ind->dstAddr, ind->srcAddr); for (int i=2; i<=keys[0]; i++) { buf.appendSprintf(",%d", keys[i]); } buf += ")"; doCommand(const_cast<char*>(buf.c_str())); } return true; }
static bool fieldAnnouncements(NWK_DataInd_t *ind) { char callback[32], *data = (char*)ind->data; // be safe if (!ind->options & NWK_IND_OPT_MULTICAST) { return true; } if (hqVerboseOutput) { sp("multicast in "); sp(ind->dstAddr); speol(); } if (Scout.isLeadScout()) { leadAnnouncementSend(ind->dstAddr, ind->srcAddr, data); } if (ind->dstAddr == 0xBEEF || strlen(data) <3 || data[0] != '[') { return false; } int keys[10]; keyLoad((char*)ind->data, keys, millis()); // run the Bitlash callback function, if defined sprintf(callback, "event.group%d", ind->dstAddr); if (findscript(callback)) { char buf[128]; sprintf(buf, "event.group%d(%d", ind->dstAddr, ind->srcAddr); for (int i=2; i<=keys[0]; i++) { sprintf(buf + strlen(buf), ",%d", keys[i]); } sprintf(buf + strlen(buf), ")"); doCommand(buf); } return true; }