lib/ble/header/index.js
function process(payload) {
  var addressType = parseInt(payload.substr(0,1),16);
  var typeCode = payload.substr(1,1);
  var length = parseInt(payload.substr(2,2),16) % 64;
  var rxAdd = "public";
  var txAdd = "public";
  if(addressType & 0x8) {
    rxAdd = "random";
  }
  if(addressType & 0x4) {
    txAdd = "random";
  }   
  var type;
  switch(typeCode) {
    case("0"):
      type = TYPE0_NAME;
      break;
    case("1"):
      type = TYPE1_NAME;
      break;
    case("2"):
      type = TYPE2_NAME;
      break;
    case("3"):
      type = TYPE3_NAME;
      break;
    case("4"):
      type = TYPE4_NAME;
      break;
    case("5"):
      type = TYPE5_NAME;
      break;
    case("6"):
      type = TYPE6_NAME;
      break;
    default: 
      type = TYPE_UNDEFINED_NAME;
  }
  return { type: type,
           length: length,
           txAdd: txAdd,
           rxAdd: rxAdd
  };
}
function process(payload) {
  var addressType = parseInt(payload.substr(0,1),16);
  var typeCode = payload.substr(1,1);
  var length = parseInt(payload.substr(2,2),16) % 64;
  var rxAdd = "public";
  var txAdd = "public";
  if(addressType & 0x8) {
    rxAdd = "random";
  }
  if(addressType & 0x4) {
    txAdd = "random";
  }   
  var type;
  switch(typeCode) {
    case("0"):
      type = TYPE0_NAME;
      break;
    case("1"):
      type = TYPE1_NAME;
      break;
    case("2"):
      type = TYPE2_NAME;
      break;
    case("3"):
      type = TYPE3_NAME;
      break;
    case("4"):
      type = TYPE4_NAME;
      break;
    case("5"):
      type = TYPE5_NAME;
      break;
    case("6"):
      type = TYPE6_NAME;
      break;
    default: 
      type = TYPE_UNDEFINED_NAME;
  }
  return { type: type,
           length: length,
           txAdd: txAdd,
           rxAdd: rxAdd
  };
}
function process ( payload ) { var addressType = parseInt ( payload . substr ( 0 , 1 ) , 16 ) ; var typeCode = payload . substr ( 1 , 1 ) ; var length = parseInt ( payload . substr ( 2 , 2 ) , 16 ) % 64 ; var rxAdd = "public" ; var txAdd = "public" ; if ( addressType & 0x8 ) { rxAdd = "random" ; } if ( addressType & 0x4 ) { txAdd = "random" ; } var type ; switch ( typeCode ) { case ( "0" ) : type = TYPE0_NAME ; break ; case ( "1" ) : type = TYPE1_NAME ; break ; case ( "2" ) : type = TYPE2_NAME ; break ; case ( "3" ) : type = TYPE3_NAME ; break ; case ( "4" ) : type = TYPE4_NAME ; break ; case ( "5" ) : type = TYPE5_NAME ; break ; case ( "6" ) : type = TYPE6_NAME ; break ; default : type = TYPE_UNDEFINED_NAME ; } return { type : type , length : length , txAdd : txAdd , rxAdd : rxAdd } ; }
Convert a raw Bluetooth Low Energy advertiser header into its meaningful
parts.
@param {string} payload The raw payload as a hexadecimal-string.
@return {Object} Semantically meaningful advertiser header.
Convert a raw Bluetooth Low Energy advertiser header into its meaningful parts .