I wanted to start a new thread, since I can't get some basic @SimpleEvents to fire in a new component, is there something more than just adding this example function to the Component class?
@SimpleEvent
public void Info()
EventDispatcher.dispatchEvent(this, "Info");
}
...
{
// place to trigger event
Info()
}
Are there other places you need to define the Events? I already put all the events I want into the OdeMessages and TranslationComponentEvents.java classes, but it hasn't worked..
--
What you have done looks correct and should work. Might be easier to find the problem if you upload you code to GitHub
--
I'm still debugging, but the Events are not triggered anytime they are in the bluetoothGattCallback methods (line 333 for example). They work in other parts of the code, like in the stopLeScan() method.
--
How are you firing this event? There should be some method that will invoke your custom event.
--
I'm looking into your code.
⦁ Are any log messages in LogMessage method outputted?
⦁ In the version that you are running, is mLogEnabled set to true because your event only gets fired when this is set to true.
⦁ In onLeScan method, is the condition "!mLeDevices.contains(device)" satisfied?
⦁ Are any log messages in LogMessage method outputted?
⦁ In the version that you are running, is mLogEnabled set to true because your event only gets fired when this is set to true.
⦁ In onLeScan method, is the condition "!mLeDevices.contains(device)" satisfied?
--
Sorry, I've clean the code up some more, and removed the LogMessage firing. I've boiled it done to this strange behavior.
The FoundDevice() event will fire if the call is from this public function here:
/** | |
* Allows the user to Stop the scan | |
*/ | |
@SimpleFunction(description = "Stops BTLE scanning") | |
public void stopLeScan() { | |
String functionName = "stopLeScan"; | |
if (scanning) { | |
try { | |
bluetoothAdapter.stopLeScan(mLeScanCallback); | |
scanning = false; | |
LogMessage("Stopping LE scan with " + numDevices + " devices", "i"); | |
// fire off event | |
if (numDevices > 0) { | |
FoundDevice(); | |
} | |
} catch (Exception e) { | |
LogMessage("Failed to stop LE scan", "e"); | |
} | |
} | |
} |
But it doesn't trigger if it is called inside a Callback function. Is there something about the embeddedfunction the "new LeScanCallback" method?
/** Device scan callback. */ | |
//private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { | |
private LeScanCallback mLeScanCallback = new LeScanCallback() { | |
@Override | |
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) { | |
// Record the first device you find | |
if (!mLeDevices.contains(device)) { | |
mLeDevices.add(device); | |
numDevices++; | |
LogMessage("Adding a BTLE device " + GetDeviceNameAndAddress(device) + " to scan list, total devices = " + numDevices, "i"); | |
//} else { | |
// LogMessage("Found new BTLE device with rssi = " + rssi + " dBm", "i"); | |
} | |
} | |
}; |
--
댓글 없음:
댓글 쓰기