kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
commit
dbe1d8065a
|
@ -7,7 +7,30 @@ parcelable NodeInfo;
|
||||||
parcelable MyNodeInfo;
|
parcelable MyNodeInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note - these calls might throw RemoteException to indicate mesh error states
|
This is the public android API for talking to meshtastic radios.
|
||||||
|
|
||||||
|
To connect to meshtastic you should bind to it per https://developer.android.com/guide/components/bound-services
|
||||||
|
|
||||||
|
The intent you use to reach the service should look like this:
|
||||||
|
|
||||||
|
val intent = Intent().apply {
|
||||||
|
setClassName(
|
||||||
|
"com.geeksville.mesh",
|
||||||
|
"com.geeksville.mesh.service.MeshService"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Once you have bound to the service you should register your broadcast receivers per https://developer.android.com/guide/components/broadcasts#context-registered-receivers
|
||||||
|
|
||||||
|
// com.geeksville.com.geeksville.mesh.x broadcast intents, where x is:
|
||||||
|
// RECEIVED_DATA for data received from other nodes. payload will contain a DataPacket
|
||||||
|
// NODE_CHANGE for new IDs appearing or disappearing
|
||||||
|
// CONNECTION_CHANGED for losing/gaining connection to the packet radio
|
||||||
|
// MESSAGE_STATUS_CHANGED for any message status changes (for sent messages only, other messages come via RECEIVED_DATA. payload will contain a message ID and a MessageStatus)
|
||||||
|
|
||||||
|
At the very least you will probably want to receive RECEIVED_DATA.
|
||||||
|
|
||||||
|
Note - these calls might throw RemoteException to indicate mesh error states
|
||||||
*/
|
*/
|
||||||
interface IMeshService {
|
interface IMeshService {
|
||||||
/// Tell the service where to send its broadcasts of received packets
|
/// Tell the service where to send its broadcasts of received packets
|
||||||
|
@ -76,11 +99,4 @@ interface IMeshService {
|
||||||
Return a number 0-100 for progress. -1 for completed and success, -2 for failure
|
Return a number 0-100 for progress. -1 for completed and success, -2 for failure
|
||||||
*/
|
*/
|
||||||
int getUpdateStatus();
|
int getUpdateStatus();
|
||||||
|
|
||||||
// see com.geeksville.com.geeksville.mesh broadcast intents
|
|
||||||
// RECEIVED_DATA for data received from other nodes. payload will contain a DataPacket
|
|
||||||
// NODE_CHANGE for new IDs appearing or disappearing
|
|
||||||
// CONNECTION_CHANGED for losing/gaining connection to the packet radio
|
|
||||||
// MESSAGE_STATUS_CHANGED for any message status changes (for sent messages only, other messages come via RECEIVED_DATA. payload will contain a message ID and a MessageStatus)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,10 @@ class MeshService : Service(), Logging {
|
||||||
*/
|
*/
|
||||||
fun startLater(context: Context) {
|
fun startLater(context: Context) {
|
||||||
// No point in even starting the service if the user doesn't have a device bonded
|
// No point in even starting the service if the user doesn't have a device bonded
|
||||||
info("Received boot complete announcement, starting mesh service in one minute")
|
info("Received boot complete announcement, starting mesh service in two minutes")
|
||||||
val delayRequest = OneTimeWorkRequestBuilder<ServiceStarter>()
|
val delayRequest = OneTimeWorkRequestBuilder<ServiceStarter>()
|
||||||
.setInitialDelay(1, TimeUnit.MINUTES)
|
.setInitialDelay(2, TimeUnit.MINUTES)
|
||||||
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 1, TimeUnit.MINUTES)
|
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 2, TimeUnit.MINUTES)
|
||||||
.addTag("startLater")
|
.addTag("startLater")
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ private fun requestBonding(
|
||||||
device: BluetoothDevice,
|
device: BluetoothDevice,
|
||||||
onComplete: (Int) -> Unit
|
onComplete: (Int) -> Unit
|
||||||
) {
|
) {
|
||||||
SLogging.info("Starting bonding for $device")
|
SLogging.info("Starting bonding for ${device.anonymize}")
|
||||||
|
|
||||||
// We need this receiver to get informed when the bond attempt finished
|
// We need this receiver to get informed when the bond attempt finished
|
||||||
val bondChangedReceiver = object : BroadcastReceiver() {
|
val bondChangedReceiver = object : BroadcastReceiver() {
|
||||||
|
|
Ładowanie…
Reference in New Issue