bluetooth lowenergy - Error code 2 in beacon transmitter for Android Beacon library -
i want send ble advertisement using android beacon library. below code using it.
package com.example.beacon_emitter; import java.util.arrays; import org.altbeacon.beacon.beacon; import org.altbeacon.beacon.beaconparser; import org.altbeacon.beacon.beacontransmitter; import android.support.v7.app.actionbaractivity; import android.app.activity; import android.bluetooth.le.advertisecallback; import android.bluetooth.le.advertisesettings; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.widget.toast; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); 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(); beaconparser beaconparser = new beaconparser() .setbeaconlayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"); beacontransmitter beacontransmitter = new beacontransmitter(getapplicationcontext(), beaconparser); beacontransmitter.startadvertising(beacon,new advertisecallback() { @override public void onstartfailure(int errorcode) { log.e("beacon", "advertisement start failed code: "+errorcode); } @override public void onstartsuccess(advertisesettings settingsineffect) { log.i("beacon", "advertisement start succeeded."); } }); int result = beacontransmitter.checktransmissionsupported(getapplicationcontext()); toast.maketext(this, "device info " + result, toast.length_long).show(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } }
it gives me errorcode 2, advertise_failed_too_many_advertisers. strange thing when checked toast message says device supported beacon transmission. confused.
please help!
thanks in advance.
a few tips:
the
beacontransmitter.checktransmissionsupported()
method checks see if device has bluetooth le , operating system givebluetoothadvertiser
.to see if else has been successful getting device transmit, check see if on list: http://altbeacon.github.io/android-beacon-library/beacon-transmitter-devices.html
the advertise_failed_too_many_advertisers response can indicate app advertising beacon, , advertisement slots used. make sure don't have other apps advertising in background. reboot or uninstall other apps might doing if necessary.
try locate beacon app based on same library, , see if can advertise beacon successfully. eliminate possible problem code.
edit: based on comments below, reasonable conclude firmware intrynsyc eval kit not implement interface between android , bluetooth chip. otherwise either report advertising not available or not return error message when starting advertising. appropriate next step open issue intrynsyc , report these findings.
Comments
Post a Comment