Exemplo n.º 1
0
void
write_eeprom(char *in)
{
  uint8_t hb[6], d = 0;

#ifdef HAS_ETHERNET
  if(in[1] == 'i') {
    uint8_t *addr = 0;
           if(in[2] == 'm') { d=6; fromhex(in+3,hb,6); addr=EE_MAC_ADDR;
    } else if(in[2] == 'd') { d=1; fromdec(in+3,hb);   addr=EE_USE_DHCP;
    } else if(in[2] == 'a') { d=4; fromip (in+3,hb,4); addr=EE_IP4_ADDR;
    } else if(in[2] == 'n') { d=4; fromip (in+3,hb,4); addr=EE_IP4_NETMASK;
    } else if(in[2] == 'g') { d=4; fromip (in+3,hb,4); addr=EE_IP4_GATEWAY;
    } else if(in[2] == 'p') { d=2; fromdec(in+3,hb);   addr=EE_IP4_TCPLINK_PORT;
    } else if(in[2] == 'N') { d=4; fromip (in+3,hb,4); addr=EE_IP4_NTPSERVER;
    } else if(in[2] == 'o') { d=1; fromhex(in+3,hb,1); addr=EE_IP4_NTPOFFSET;
#ifdef HAS_NTP
      extern int8_t ntp_gmtoff;
      ntp_gmtoff = hb[0];
#endif
    }
    for(uint8_t i = 0; i < d; i++)
      ewb(addr++, hb[i]);

  } else 
#endif
  {
    uint16_t addr;
    d = fromhex(in+1, hb, 3);
    if(d < 2)
      return;
    if(d == 2)
      addr = hb[0];
    else
      addr = (hb[0] << 8) | hb[1];
      
    ewb((uint8_t*)addr, hb[d-1]);

    if (addr == 15 || addr == 16 || addr == 17)
      checkFrequency();

    // If there are still bytes left, then write them too
    in += (2*d+1);
    while(in[0]) {
      addr++;
      if(!fromhex(in, hb, 1))
        return;
      ewb((uint8_t*)addr++, hb[0]);
      in += 2;
    }
  }
}
Exemplo n.º 2
0
void native_func(char *in) {
  uint8_t mode = 0;

  if(in[1] == 'r') {                // Reception on
    
    // "Er<x>" - where <x> is mode
    if (in[2])
      fromdec(in+2, &mode);

    if (!mode || mode>MAX_MODES) {
      DS_P(PSTR("specify valid mode number\r\n"));
      return;
    }
    
    native_init(mode);

  } else if(in[1] == 'x') {        // Reception off

    if (native_on)
      ccStrobe( CC1100_SIDLE );
    
    native_on = 0;

  }

  DH2(native_on);
  DNL();
  
}
Exemplo n.º 3
0
/*
 * Match a keyword.
 */
static void match_kw(token * tok)
{
  /*
   * FIXME. The ids are explicit in here so as to allow long-name
   * equivalents to the various very short keywords.
   *
   * This list must be sorted, it's searched using binary search.
   */
  static const struct {
    char const *name;
    int id;
  } keywords[] = {
    {
    "#", c__comment}
    ,                           /* comment command (\#) */
    {
    "-", c__escaped}
    ,                           /* nonbreaking hyphen */
    {
    "A", c_A}
    ,                           /* appendix heading */
    {
    "B", c_B}
    ,                           /* bibliography entry */
    {
    "BR", c_BR}
    ,                           /* bibliography rewrite */
    {
    "C", c_C}
    ,                           /* chapter heading */
    {
    "H", c_H}
    ,                           /* heading */
    {
    "I", c_I}
    ,                           /* invisible index mark */
    {
    "IM", c_IM}
    ,                           /* index merge/rewrite */
    {
    "K", c_K}
    ,                           /* capitalised cross-reference */
    {
    "L", c_L}
    ,                           /* Relative/local hyperlink */
    {
    "R", c_R}
    ,                           /* free text cross-reference */
    {
    "U", c_U}
    ,                           /* unnumbered-chapter heading */
    {
    "W", c_W}
    ,                           /* Web hyperlink */
    {
    "\\", c__escaped}
    ,                           /* escaped backslash (\\) */
    {
    "_", c__nbsp}
    ,                           /* nonbreaking space (\_) */
    {
    "b", c_b}
    ,                           /* bulletted list */
    {
    "c", c_c}
    ,                           /* code */
    {
    "cfg", c_cfg}
    ,                           /* configuration directive */
    {
    "copyright", c_copyright}
    ,                           /* copyright statement */
    {
    "cw", c_cw}
    ,                           /* weak code */
    {
    "date", c_date}
    ,                           /* document processing date */
    {
    "define", c_define}
    ,                           /* macro definition */
    {
    "e", c_e}
    ,                           /* emphasis */
    {
    "i", c_i}
    ,                           /* visible index mark */
    {
    "ii", c_ii}
    ,                           /* uncapitalised visible index mark */
    {
    "k", c_k}
    ,                           /* uncapitalised cross-reference */
    {
    "n", c_n}
    ,                           /* numbered list */
    {
    "nocite", c_nocite}
    ,                           /* bibliography trickery */
    {
    "preamble", c_preamble}
    ,                           /* document preamble text */
    {
    "q", c_q}
    ,                           /* quote marks */
    {
    "rule", c_rule}
    ,                           /* horizontal rule */
    {
    "title", c_title}
    ,                           /* document title */
    {
    "versionid", c_versionid}
    ,                           /* document RCS id */
    {
    "{", c__escaped}
    ,                           /* escaped lbrace (\{) */
    {
    "}", c__escaped}
    ,                           /* escaped rbrace (\}) */
  };
  int i, j, k, c;

  /*
   * Special cases: \S{0,1,2,...} and \uABCD. If the syntax
   * doesn't match correctly, we just fall through to the
   * binary-search phase.
   */
  if (tok->text[0] == 'S')
  {
    /* We expect numeric characters thereafter. */
    wchar_t *p = tok->text + 1;
    int n;
    if (!*p)
      n = 1;
    else
    {
      n = 0;
      while (*p && isdec(*p))
      {
        n = 10 * n + fromdec(*p);
        p++;
      }
    }
    if (!*p)
    {
      tok->cmd = c_S;
      tok->aux = n;
      return;
    }
  } else if (tok->text[0] == 'u')
  {
    /* We expect hex characters thereafter. */
    wchar_t *p = tok->text + 1;
    int n = 0;
    while (*p && ishex(*p))
    {
      n = 16 * n + fromhex(*p);
      p++;
    }
    if (!*p)
    {
      tok->cmd = c_u;
      tok->aux = n;
      return;
    }
  }

  i = -1;
  j = sizeof(keywords) / sizeof(*keywords);
  while (j - i > 1)
  {
    k = (i + j) / 2;
    c = kwcmp(tok->text, keywords[k].name);
    if (c < 0)
      j = k;
    else if (c > 0)
      i = k;
    else
    {                           /* c == 0 */

      tok->cmd = keywords[k].id;
      return;
    }
  }

  tok->cmd = c__invalid;
}
Exemplo n.º 4
0
void
it_func(char *in)
{
	if (in[1] == 't') {
			fromdec (in+2, (uint8_t *)&it_interval);
			DU(it_interval,0); DNL();
	} else if (in[1] == 's') {
			if (in[2] == 'r') {		// Modify Repetition-counter
				fromdec (in+3, (uint8_t *)&it_repetition);
				DU(it_repetition,0); DNL();
#ifdef HAS_HOMEEASY
      } else if (in[2] == 'h') {		// HomeEasy
        it_send (in, DATATYPE_HE);	
      } else if (in[2] == 'e') {		// HomeEasy EU
        it_send (in, DATATYPE_HEEU);	
#endif	
			} else {
				it_send (in, DATATYPE_IT);				// Sending real data
		} //sending real data
	} else if (in[1] == 'r') { // Start of "Set Frequency" (f)
		#ifdef HAS_ASKSIN
			if (asksin_on) {
				restore_asksin = 1;
				asksin_on = 0;
			}
		#endif
		#ifdef HAS_MORITZ
			if (moritz_on) {
				restore_moritz = 1;
				moritz_on = 0;
			}
		#endif
		it_tunein ();
		intertechno_on = 1;
	} else if (in[1] == 'f') { // Set Frequency
		  if (in[2] == '0' ) {
		  	it_frequency[0] = 0x10;
		  	it_frequency[1] = 0xb0;
		  	it_frequency[2] = 0x71;
		  } else {
				fromhex (in+2, it_frequency, 3);
			}
			DC('i');DC('f');DC(':');
		  DH2(it_frequency[0]);
		  DH2(it_frequency[1]);
		  DH2(it_frequency[2]);
		  DNL();
	} else if (in[1] == 'x') { 		                    // Reset Frequency back to Eeprom value
		if(0) { ;
		#ifdef HAS_ASKSIN
		} else if (restore_asksin) {
			restore_asksin = 0;
			rf_asksin_init();
			asksin_on = 1;
			ccRX();
		#endif
		#ifdef HAS_MORITZ
		} else if (restore_moritz) {
			restore_moritz = 0;
			rf_moritz_init();
		#endif
		} else {
			ccInitChip(EE_CC1100_CFG);										// Set back to Eeprom Values
			if(tx_report) {                               // Enable RX
				ccRX();
			} else {
				ccStrobe(CC1100_SIDLE);
			}
		}
		intertechno_on = 0;
	}
}