I am trying to transmit the major minor id from device making it an iBeacon using library
compile 'org.altbeacon:android-beacon-library:2.9.2#aar'
the code
if (mBeaconTransmitter != null) {
mBeaconTransmitter.stopAdvertising();
}
BeaconParser beaconParser=new BeaconParser();
mBeaconTransmitter = new BeaconTransmitter(getApplicationContext(), new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
int flag= mBeaconTransmitter.checkTransmissionSupported(this);
Log.v("###WWe"," BEacon Test "+flag);
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2(majorID)//Major
.setId3(minorID)//Minor
.setBluetoothName("Vyas Pratik")
.setBeaconTypeCode(533)
.setManufacturer(0x0075) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
.setTxPower(-59)
.setMultiFrameBeacon(true)
.build();
// .setId2(minorID)//Major Try
// .setId3(majorID)//Minor Try
//.setBluetoothAddress(bluetoothManager.getAdapter().getAddress())
// .setDataFields(Arrays.asList(new Long[]{0l}))
mBeaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
super.onStartSuccess(settingsInEffect);
Log.v("###WWe"," Sucess "+settingsInEffect.toString());
}
#Override
public void onStartFailure(int errorCode) {
super.onStartFailure(errorCode);
Log.v("###WWe"," Error "+String.valueOf(errorCode));
}
});
However, my beacon using this code is detected in Locate app but not in beacon tools app /nearby (Google app).please guide me.
Thanks
After several trial and error trick, I got to a solution for this problem, the UUID, and manufacturer id was wrong.
so I changed it to below value and the beacon is now detecting in google near by and beacon tools aswell
Beacon beacon = new Beacon.Builder()
// .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
// .setManufacturer(0x0118) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
.setId1("6d234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setManufacturer(0x4c) // Choose a number of 0x00ff or less as some devices cannot detect beacons with a manufacturer code > 0x00ff
.setId2(majorID)//Major
.setId3(minorID)//Minor
.setBluetoothName("Vyas Pratik")
.setTxPower(-59)
.build();
Related
I have Ibeacon scanning app which use CoreBluetooth. I want to use my real android device as an beacon. I can scan my Ibeacons but can not found my android device.
import Foundation
import CoreBluetooth
public class BeaconScanning: NSObject, BKCentralDelegate{
let central = BKCentral()
override init(){
super.init()
central.delegate = self
do {
let serviceUUID = CBUUID(string: "FF80") // For my used Ibeacon Service Data
let characteristicUUID = CBUUID( )
let configuration = BKConfiguration(dataServiceUUID: serviceUUID, dataServiceCharacteristicUUID: characteristicUUID) // Configration for scanning
try central.startWithConfiguration(configuration)
} catch let error { }
central.scanContinuouslyWithChangeHandler({ changes, discoveries in }, stateHandler: { newState in }, duration: 2, inBetweenDelay: 0.1, beaconHandler: { beacons in
for beacon in beacons! {
// get beacons properties
}
}, errorHandler: { error in })
}
public func central(_ central: BKCentral, remotePeripheralDidDisconnect remotePeripheral: BKRemotePeripheral) {
}
}
I can scan my Ibeacon devices in IOS app. But, it cannot be found when I use my Android device as Ibeacon using AltBeacon.
Beacon beacon = new Beacon.Builder().
.setId1("e2c56db5-dffb-48d2-b060-d0f5a71096e0") //uuid the same my Ibeacon
.setId2("0")
.setId3("0")
.setManufacturer(0x0118)
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[] {0l}))
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"); //altbeacon layout for parser transmitting as a beacon
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon);
Using CoreLocation:
Beacon beacon = new Beacon.Builder()
.setManufacturer(0x004c) // Use Ibeacon Manufacturer
.setId1("e2c56db5-dffb-48d2-b060-d0f5a71096e0")
.setId2("0")
.setId3("0")
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[] {0l}))
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");//BeaconLayout startwith ("m:2-3=0215)
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon);
I am using the Android beacon library with,
version -
compile 'org.altbeacon:android-beacon-library:2.15.1'
I am trying to develop one APK for transmitting multiple beacons from my mobile device.
I need to perform this to test or POC to test, how many beacons a reader can read at a time.
I am using the below code to transmit the BLE messages with Android Beacon Library.
btn_transmit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (isBluetoothEnabled)
{
try
{
String customUuid = "";
for(int i=0;i<=50;i++)
{
if( i < 10){
customUuid = "99999999-b00"+i+"-4807-b747-9aee23508620";
} else if ( i < 999){
customUuid = "99999999-b0"+i+"-4807-b747-9aee23508620";
}
Thread.sleep(5000);
trasmitClick(customUuid);
beaconTransmitter = null;
}
}
catch(Exception e)
{
Toast.makeText(BeaconTransmitterActivity.this, "Something went wronggg", Toast.LENGTH_LONG).show();
}
}
else
Toast.makeText(BeaconTransmitterActivity.this, "Check your bluetooth connection", Toast.LENGTH_LONG).show();
}
});
Here above I am dynamically trying to create 50 new Id's to transmit the beacons.
Method to createBeacon and transmit its advertisements
public void trasmitClick(String customUuid) {
if (beaconTransmitter == null) {
String major, minor, uuid;
uuid = customUuid;
major = etMajorValue.getText().toString().trim();
minor = etMinorValue.getText().toString().trim();
if (TextUtils.isEmpty(uuid))
uuid = customUuid;
if (TextUtils.isEmpty(major))
major = "8";
if (TextUtils.isEmpty(minor))
minor = "2";
currentType=beaconLayout;
currentuuid=uuid;
currentmajorValue=major;
currentminorValue=minor;
beacon = new Beacon.Builder()
.setId1(uuid)
.setId2(major)
.setId3(minor)
//.setManufacturer(0x0118) // It is for AltBeacon. Change this for other beacon layouts
.setManufacturer(0x004C)
.setTxPower(-59)
//.setDataFields(Arrays.asList(new Long[]{6l, 7l})) // Remove this for beacon layouts without d: fields
.build();
// Change the layout below for other beacon types
beaconParser = new BeaconParser()
.setBeaconLayout(parserLayout[beaconLayout]);
beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
super.onStartSuccess(settingsInEffect);
}
#Override
public void onStartFailure(int errorCode) {
super.onStartFailure(errorCode);
}
});
btn_transmit.setText("Stop Advertising");
btn_apply.setEnabled(false);
} else {
beaconTransmitter.startAdvertising();
beaconTransmitter = null;
btn_transmit.setText("Start Advertising");
btn_apply.setEnabled(false);
}
}
I am able to make this code work, but what is the result is I am able to transmit only 4 messages, the rest of the messages are not being visible in the simulator.
I am trying to find if the library has some limitations or I am wrong above.
Well I am novice in Android coding.
Below is the result that I can get in my simulator:
I would like to know how can I transmit 50 messages in one go.
This is most certainly a limitation of the Bluetooth chip on your mobile phone. Different device models have different advertising limits. The Huawei P9 Lite, for example can transmit only one advertisement at a time. The Nexus 5x can advertise 10 or more. It is unlikely that many phone models (if any) support 50 simultaneous advertisements.
There is no way to know the limit programmatically, as the OS provides no API to query this limit -- you just have to try. You can check when you get an error advertising by putting code in the onStartFailure callback.
You might also use the [BeaconScope]((https://play.google.com/store/apps/details?id=com.davidgyoungtech.beaconscanner) app to test this. But remember that transmission limits are device-wide. If one app is advertising a beacon, that takes one advertisement slot away from the next app. And no, there is no way to know if other apps are advertising.
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2("1")
.setId3("2")
.setManufacturer(0x0118)
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[]{0l}))
.build();
beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
#Override
public void onStartFailure(int errorCode) {
Log.e(TAG, "Advertisement start failed with code: " + errorCode);
}
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i(TAG, "Advertisement start succeeded.");
}
});
Run this,The log "Advertisement start succeeded." is shown, is success.
But,mBeaconManager.startMonitoringBeaconsInRegion(region); not find the altBeacon.
You cannot detect a beacon on the same device that is transmitting the packets. This is not a limitation specific tothe Android Beacon Library, it is just how Bluetooth LE works. It is common for radio hardware systems to be designed not to receive their own transmissions.
Beacon beacon = new Beacon.Builder()
.setId1("XYZ MY UUID") // UUID for beacon
.setId2("1") // Major for beacon
.setId3("5") // Minor for beacon
.setManufacturer(0x004C) // Radius Networks.0x0118 Change this for other beacon layouts//0x004C for iPhone
.setTxPower(-56) // Power in dB
.setDataFields(Arrays.asList(new Long[] {0l})) // Remove this for beacon layouts without d: fields
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
#Override
public void onStartFailure(int errorCode) {
Log.e("TAG", "Advertisement start failed with code: " + errorCode);
}
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i("TAG", "Advertisement start succeeded.");
}
});
hello guys, i am using this code in android for transmit beacons and using ios device for detect or receive advertisement. but in my ios device, i am not getting any notification. is there any mistake in my code ? please help... i am using AltBeacon library for that.
Has anybody used Samsung's Bluetooth LE APIs to make a Samsung Android device advertise as an iBeacon? i am using samsung galaxy s4 ( GT- i9500)device for transmitting advertisement using altbeacon library . but my code not working is there any problems please check.
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6") // UUID for beacon
.setId2("1") // Major for beacon
.setId3("5") // Minor for beacon
.setManufacturer(0x004C) // Radius Networks.0x0118 Change this for other beacon layouts//0x004C for iPhone
.setTxPower(-56) // Power in dB
.setDataFields(Arrays.asList(new Long[] {0l})) // Remove this for beacon layouts without d: fields
.build();
BeaconParser beaconParser = new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
#Override
public void onStartFailure(int errorCode) {
Log.e("TAG", "Advertisement start failed with code: " + errorCode);
}
#Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
Log.i("TAG", "Advertisement start succeeded.");
}
});