lib/ble/data/gatt/services/members/google.js
function processEddystone(advertiserData) {
  var data = advertiserData.serviceData.data;
  var eddystone = {};

  var frameType = data.substr(0,2);

  switch(frameType) {

    // UID
    case '00':
      eddystone.type = 'UID';
      eddystone.txPower = pdu.convertTxPower(data.substr(2,2));
      eddystone.uid = {};
      eddystone.uid.namespace = data.substr(4,20);
      eddystone.uid.instance = data.substr(24,12);
      break;

    // URI
    case '10':
      eddystone.type = 'URL';
      eddystone.txPower = pdu.convertTxPower(data.substr(2,2));
      eddystone.url = parseSchemePrefix(data.substr(4,2));
      eddystone.url += parseEncodedUrl(data.substr(6));
      break;

    // TLM
    case '20':
      eddystone.type = 'TLM';
      eddystone.version = data.substr(2,2);
      if(eddystone.version === '00') {
        eddystone.batteryVoltage = parseInt(data.substr(4,4),16) + 'mV';
        // TODO: export 8:8 fixed point representation interpreter to pdu
        eddystone.temperature = parseInt(data.substr(8,4),16);
        if(eddystone.temperature > 0x7fff) {
          eddystone.temperature = 0x7fff - eddystone.temperature;
        }
        eddystone.temperature = (eddystone.temperature / 256) + 'C';
        eddystone.advertisingCount = parseInt(data.substr(12,8),16);
        eddystone.uptime = (parseInt(data.substr(20,8),16) / 10) + 's';
      }
      else if(eddystone.version === '01') {
        eddystone.etlm = data.substr(4,24);
        eddystone.salt = data.substr(28,4);
        eddystone.mic = data.substr(32,4);
      }
      break;

    // EID
    case '30':
      eddystone.type = 'EID';
      eddystone.txPower = pdu.convertTxPower(data.substr(2,2));
      eddystone.eid = data.substr(4,16);
      break;
  }

  advertiserData.serviceData.eddystone = eddystone;
}
function processEddystone(advertiserData) {
  var data = advertiserData.serviceData.data;
  var eddystone = {};

  var frameType = data.substr(0,2);

  switch(frameType) {

    // UID
    case '00':
      eddystone.type = 'UID';
      eddystone.txPower = pdu.convertTxPower(data.substr(2,2));
      eddystone.uid = {};
      eddystone.uid.namespace = data.substr(4,20);
      eddystone.uid.instance = data.substr(24,12);
      break;

    // URI
    case '10':
      eddystone.type = 'URL';
      eddystone.txPower = pdu.convertTxPower(data.substr(2,2));
      eddystone.url = parseSchemePrefix(data.substr(4,2));
      eddystone.url += parseEncodedUrl(data.substr(6));
      break;

    // TLM
    case '20':
      eddystone.type = 'TLM';
      eddystone.version = data.substr(2,2);
      if(eddystone.version === '00') {
        eddystone.batteryVoltage = parseInt(data.substr(4,4),16) + 'mV';
        // TODO: export 8:8 fixed point representation interpreter to pdu
        eddystone.temperature = parseInt(data.substr(8,4),16);
        if(eddystone.temperature > 0x7fff) {
          eddystone.temperature = 0x7fff - eddystone.temperature;
        }
        eddystone.temperature = (eddystone.temperature / 256) + 'C';
        eddystone.advertisingCount = parseInt(data.substr(12,8),16);
        eddystone.uptime = (parseInt(data.substr(20,8),16) / 10) + 's';
      }
      else if(eddystone.version === '01') {
        eddystone.etlm = data.substr(4,24);
        eddystone.salt = data.substr(28,4);
        eddystone.mic = data.substr(32,4);
      }
      break;

    // EID
    case '30':
      eddystone.type = 'EID';
      eddystone.txPower = pdu.convertTxPower(data.substr(2,2));
      eddystone.eid = data.substr(4,16);
      break;
  }

  advertiserData.serviceData.eddystone = eddystone;
}
function processEddystone ( advertiserData ) { var data = advertiserData . serviceData . data ; var eddystone = { } ; var frameType = data . substr ( 0 , 2 ) ; switch ( frameType ) { // UID case '00' : eddystone . type = 'UID' ; eddystone . txPower = pdu . convertTxPower ( data . substr ( 2 , 2 ) ) ; eddystone . uid = { } ; eddystone . uid . namespace = data . substr ( 4 , 20 ) ; eddystone . uid . instance = data . substr ( 24 , 12 ) ; break ; // URI case '10' : eddystone . type = 'URL' ; eddystone . txPower = pdu . convertTxPower ( data . substr ( 2 , 2 ) ) ; eddystone . url = parseSchemePrefix ( data . substr ( 4 , 2 ) ) ; eddystone . url += parseEncodedUrl ( data . substr ( 6 ) ) ; break ; // TLM case '20' : eddystone . type = 'TLM' ; eddystone . version = data . substr ( 2 , 2 ) ; if ( eddystone . version === '00' ) { eddystone . batteryVoltage = parseInt ( data . substr ( 4 , 4 ) , 16 ) + 'mV' ; // TODO: export 8:8 fixed point representation interpreter to pdu eddystone . temperature = parseInt ( data . substr ( 8 , 4 ) , 16 ) ; if ( eddystone . temperature > 0x7fff ) { eddystone . temperature = 0x7fff - eddystone . temperature ; } eddystone . temperature = ( eddystone . temperature / 256 ) + 'C' ; eddystone . advertisingCount = parseInt ( data . substr ( 12 , 8 ) , 16 ) ; eddystone . uptime = ( parseInt ( data . substr ( 20 , 8 ) , 16 ) / 10 ) + 's' ; } else if ( eddystone . version === '01' ) { eddystone . etlm = data . substr ( 4 , 24 ) ; eddystone . salt = data . substr ( 28 , 4 ) ; eddystone . mic = data . substr ( 32 , 4 ) ; } break ; // EID case '30' : eddystone . type = 'EID' ; eddystone . txPower = pdu . convertTxPower ( data . substr ( 2 , 2 ) ) ; eddystone . eid = data . substr ( 4 , 16 ) ; break ; } advertiserData . serviceData . eddystone = eddystone ; }
Parse BLE advertiser Eddystone data.
@param {Object} advertiserData The object containing all parsed data.
Parse BLE advertiser Eddystone data .