Here you can find the source of AsciiBTAddressToBytes(String btAddress)
Parameter | Description |
---|---|
btAddress | ASCII version of address |
public static byte[] AsciiBTAddressToBytes(String btAddress)
//package com.java2s; /***************************************************************** BioZen/* w w w . j a va2 s. co m*/ Copyright (C) 2011 The National Center for Telehealth and Technology Eclipse Public License 1.0 (EPL-1.0) This library is free software; you can redistribute it and/or modify it under the terms of the Eclipse Public License as published by the Free Software Foundation, version 1.0 of the License. The Eclipse Public License is a reciprocal license, under Section 3. REQUIREMENTS iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. Post your updates and modifications to our GitHub or email to t2@tee2.org. This library is distributed WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Eclipse Public License 1.0 (EPL-1.0) for more details. You should have received a copy of the Eclipse Public License along with this library; if not, visit http://www.opensource.org/licenses/EPL-1.0 *****************************************************************/ public class Main { /** * Converts a nicely formatted Bluetooth address to string of bytes representing the address * * @param btAddress ASCII version of address * @return Bytes version of address or null of error */ public static byte[] AsciiBTAddressToBytes(String btAddress) { // Make sure the address is of the form xx:xx:xx:xx:xx:xx // If not return null if (btAddress.length() != 17) return null; String[] tokens = btAddress.split(":"); if (tokens.length != 6) return null; byte[] finalResult = new byte[tokens.length]; int i = 0; for (String val : tokens) { finalResult[i++] = Integer.decode("0x" + val).byteValue(); } return finalResult; } }