code: function _metadataBlock_Ai(packet, i) {
  
      // TODO common code
      var Dir;
      if (packet.getDir() == 'up') {
          Dir = util.bufferFromUInt8(0);
      } else if (packet.getDir() == 'down') {
          Dir = util.bufferFromUInt8(1);
      } else {
          throw new Error(errHdr + "expecting direction to be either 'up' or 'down'");
      }
  
      var Ai_buf = Buffer.concat([
          new Buffer("0100000000", 'hex'), // as spec
          Dir, // direction ('Dir')
          util.reverse(packet.getBuffers().DevAddr),
          util.reverse(packet.getBuffers().FCnt),
          util.bufferFromUInt16LE(0), // upper 2 bytes of FCnt (zeroes)
          util.bufferFromUInt8(0), // 0x00
          util.bufferFromUInt8(i + 1) // block number
      ]);
  
      return Ai_buf;
  }
docs: Encrypt stream mixes in metadata blocks, as Ai = 0x01 0x00 0x00 0x00 0x00 direction-uplink/downlink [1] DevAddr [4] FCnt as 32-bit, lsb first [4] 0x00 counter = i [1]