OpenBeacon Tag

From OpenBeacon

(Redirected from Tag sputnik)
Jump to: navigation, search


Contents

Programming Work Flow

  • OpenBeacon Tag related firmware source may be found on Subversion server (pic16tag Firmware):
svn co svn co https://openbeacon.svn.sourceforge.net/svnroot/openbeacon/trunk/firmware/pic16/tag/ openbeacon 	

Understanding the tag source code

Spurnik tag as used on the 25C3 CCC congress
PIC16F684 Microcontroller from Microchip on the OpenBeacon Tag running the code shown

That's the main loop from main.c in the tag firmware. The line where the actual packet macro is transmitted to the nRF24L01 chip is highlighted. Basically first the packet is assembled, then the CRC calculated and the data encrypted (shuffle_tx_byteorder is used to adjust byte order to achieve platform independence). As final step RFCMD_Execute() triggers the transmitting process. Interesting feature ot this code is that the packet macro is prepended by a macro that adjust the transmit power on every transmission (g_MacroBeacon.rf_setup).

  while (1)
      {
	g_MacroBeacon.rf_setup = NRF_RFOPTIONS | ((i & 3) << 1);
	g_MacroBeacon.env.pkt.hdr.size = sizeof (TBeaconTracker);
	g_MacroBeacon.env.pkt.hdr.proto = RFBPROTO_BEACONTRACKER;
	g_MacroBeacon.env.pkt.flags = CONFIG_PIN_SENSOR ? 0 : RFBFLAGS_SENSOR;
	g_MacroBeacon.env.pkt.strength = i;
	g_MacroBeacon.env.pkt.seq = htonl (seq);
	g_MacroBeacon.env.pkt.oid = htonl (oid);
	g_MacroBeacon.env.pkt.reserved = 0;
	crc = crc16 (g_MacroBeacon.env.datab,
		     sizeof (g_MacroBeacon.env.pkt) -
		     sizeof (g_MacroBeacon.env.pkt.crc));
	g_MacroBeacon.env.pkt.crc = htons (crc);
 
	// update code_block so on next power up
	// the seq will be higher or equal
	crc = seq >> 16;
	if (crc == 0xFFFF)
	  break;
	if (crc == code_block)
	  store_incremented_codeblock ();
 
	// encrypt my data
	shuffle_tx_byteorder ();
	xxtea_encode ();
	shuffle_tx_byteorder ();
 
	// reset touch sensor pin
	TRISA = CONFIG_CPU_TRISA & ~0x02;
	CONFIG_PIN_SENSOR = 0;
	sleep_jiffies (JIFFIES_PER_MS (10) +
		       (rand () % JIFFIES_PER_MS (180)));
	CONFIG_PIN_SENSOR = 1;
	TRISA = CONFIG_CPU_TRISA;
 
	// send it away
	nRFCMD_Macro ((unsigned char *) &g_MacroBeacon);	status = (i & 0xF) == 0;
 
	if (status)
	  CONFIG_PIN_LED = 1;
	nRFCMD_Execute ();
	if (status)
	  CONFIG_PIN_LED = 0;
 
	if (++i >= 4)
	  {
	    i = 0;
	    seq++;
	  }
      }
round OpenBeacon tag

Hardware

  • The OpenBeacon Tag consists of

Links