add my broadcasts

pull/8/head
geeksville 2020-01-22 22:16:30 -08:00
rodzic 3551eedb8a
commit 397bb855d9
3 zmienionych plików z 41 dodań i 10 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
* test reg reading/writing directly via bt to device
* fix bluetooth update
* add broadcasters for use by signal
* add broadcasters for use by signal (node changes and packet received)
* make test implementation of server (doesn't use bluetooth)
* add real messaging code/protobufs
* use https://codelabs.developers.google.com/codelabs/jetpack-compose-basics/#4 to show service state

Wyświetl plik

@ -17,7 +17,7 @@ interface IMeshService {
/**
Get the IDs of everyone on the mesh. You should also subscribe for NODE_CHANGE broadcasts.
*/
void getOnline(out String[] ids);
String[] getOnline();
/**
Is the packet radio currently connected to the phone?

Wyświetl plik

@ -3,8 +3,37 @@ package com.geeksville.mesh
import android.app.Service
import android.content.Intent
import android.os.IBinder
import com.geeksville.android.Logging
class MeshService : Service() {
class MeshService : Service(), Logging {
val prefix = "com.geeksville.mesh"
/*
see com.geeksville.com.geeeksville.mesh broadcast intents
// RECEIVED_OPAQUE for data received from other nodes
// NODE_CHANGE for new IDs appearing or disappearing
// CONNECTION_CHANGED for losing/gaining connection to the packet radio
*/
fun broadcastReceivedOpaque(senderId: String, payload: ByteArray) {
val intent = Intent("$prefix.RECEIVED_OPAQUE")
intent.putExtra("$prefix.Sender", senderId)
intent.putExtra("$prefix.Payload", payload)
sendBroadcast(intent)
}
fun broadcastNodeChange(nodeId: String, isOnline: Boolean) {
val intent = Intent("$prefix.NODE_CHANGE")
intent.putExtra("$prefix.Id", nodeId)
intent.putExtra("$prefix.Online", isOnline)
sendBroadcast(intent)
}
fun broadcastConnectionChanged(isConnected: Boolean) {
val intent = Intent("$prefix.CONNECTION_CHANGED")
intent.putExtra("$prefix.Connected", isConnected)
sendBroadcast(intent)
}
override fun onBind(intent: Intent): IBinder {
// Return the interface
@ -12,20 +41,22 @@ class MeshService : Service() {
}
private val binder = object : IMeshService.Stub() {
override fun setOwner(myId: String?, longName: String?, shortName: String?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
override fun setOwner(myId: String, longName: String, shortName: String) {
error("TODO setOwner $myId : $longName : $shortName")
}
override fun sendOpaque(destId: String?, payload: ByteArray?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
override fun sendOpaque(destId: String, payload: ByteArray) {
error("TODO sendOpaque $destId <- ${payload.size}")
}
override fun getOnline(ids: Array<out String>?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
override fun getOnline(): Array<String> {
error("TODO getOnline")
return arrayOf("+16508675309")
}
override fun isConnected(): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
error("TODO isConnected")
return true
}
}
}