kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
add IPC mesh service for use by Signal
rodzic
593cfa3a7e
commit
9a61af82de
app/src/main
aidl/com/geeksville/meshutil
java/com/geeksville/meshutil
proto
|
@ -49,6 +49,11 @@
|
|||
android:exported="false"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
|
||||
<service
|
||||
android:name=".MeshService"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// com.geeksville.meshutil.IMeshService.aidl
|
||||
package com.geeksville.meshutil;
|
||||
|
||||
// Declare any non-default types here with import statements
|
||||
|
||||
interface IMeshService {
|
||||
/**
|
||||
* Set the ID info for this node
|
||||
*/
|
||||
void setOwner(String myId, String longName, String shortName);
|
||||
|
||||
/*
|
||||
Send an opaque packet to a specified node name
|
||||
*/
|
||||
void sendOpaque(String destId, in byte[] payload);
|
||||
|
||||
/**
|
||||
Get the IDs of everyone on the mesh. You should also subscribe for NODE_CHANGE broadcasts.
|
||||
*/
|
||||
void getOnline(out String[] ids);
|
||||
|
||||
/**
|
||||
Is the packet radio currently connected to the phone?
|
||||
*/
|
||||
boolean isConnected();
|
||||
|
||||
// see com.geeksville.meshutil 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
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.geeksville.meshutil
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
|
||||
class MeshService : Service() {
|
||||
|
||||
override fun onBind(intent: Intent): IBinder {
|
||||
// Return the interface
|
||||
return binder
|
||||
}
|
||||
|
||||
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 sendOpaque(destId: String?, payload: ByteArray?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun getOnline(ids: Array<out String>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun isConnected(): Boolean {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,19 +11,33 @@ MESH RADIO PROTOCOL
|
|||
|
||||
Old TODO notes on the mesh radio protocol, merge into real docs below...
|
||||
|
||||
for each named group we have a preshared key known by all group members and wrapped around the device. you can only be in one group at a time (FIXME?!)
|
||||
To join the group we read a qr code with the preshared key and ParamsCodeEnum. that gets sent via bluetooth to the device. ParamsCodeEnum maps to a set of various radio params (regulatory region, center freq, SF, bandwidth, bitrate, power etc...) so all members of the mesh can have their radios set the same way.
|
||||
for each named group we have a preshared key known by all group members and wrapped around the device.
|
||||
you can only be in one group at a time (FIXME?!)
|
||||
To join the group we read a qr code with the preshared key and ParamsCodeEnum. that gets sent via
|
||||
bluetooth to the device. ParamsCodeEnum maps to a set of various radio params (regulatory region,
|
||||
center freq, SF, bandwidth, bitrate, power etc...) so all members of the mesh can have their radios set the same way.
|
||||
|
||||
once in that group, we can talk between 254 node numbers.
|
||||
to get our node number (and announce our presence in the channel) we pick a random node number and broadcast as that node with WANT-NODENUM(my globally unique name). If anyone on the channel has seen someone _else_ using that name within the last 24 hrs(?) they reply with DENY-NODENUM. Note: we might receive multiple denies. Note: this allows others to speak up for some other node that might be saving battery right now.
|
||||
Any time we hear from another node (for any message type), we add that node number to the unpickable list. To dramatically decrease the odds a node number we request is already used by someone.
|
||||
If no one denies within TBD seconds, we assume that we have that node number. As long as we keep talking to folks at least once every 24 hrs, others should remember we have it.
|
||||
to get our node number (and announce our presence in the channel) we pick a random node number and
|
||||
broadcast as that node with WANT-NODENUM(my globally unique name). If anyone on the channel has
|
||||
seen someone _else_ using that name within the last 24 hrs(?) they reply with DENY-NODENUM.
|
||||
Note: we might receive multiple denies. Note: this allows others to speak up for some other node
|
||||
that might be saving battery right now.
|
||||
Any time we hear from another node (for any message type), we add that node number to the unpickable
|
||||
list. To dramatically decrease the odds a node number we request is already used by someone.
|
||||
If no one denies within TBD seconds, we assume that we have that node number. As long as we keep
|
||||
talking to folks at least once every 24 hrs, others should remember we have it.
|
||||
|
||||
Once we have a node number we can broadcast POSITION-UPDATE(my globally unique name, lat, lon, alt, amt battery remaining). All receivers will use this to a) update the mapping of who is at what node nums, b) the time of last rx, c) position. If we haven't heard from that node in a while we reply to that node (only) with our current POSITION_UPDATE state - so that node (presumably just rejoined the network) can build a map of all participants.
|
||||
Once we have a node number we can broadcast POSITION-UPDATE(my globally unique name, lat, lon, alt,
|
||||
amt battery remaining). All receivers will use this to a) update the mapping of who is at what
|
||||
node nums, b) the time of last rx, c) position. If we haven't heard from that node in a while we
|
||||
reply to that node (only) with our current POSITION_UPDATE state - so that node (presumably just
|
||||
rejoined the network) can build a map of all participants.
|
||||
|
||||
We will periodically broadcast POSITION-UPDATE as needed based on distance moved or a periodic minimum heartbeat.
|
||||
|
||||
If user wants to send a text they can SEND_TEXT(dest user, short text message). Dest user is a node number, or 0xff for broadcast.
|
||||
If user wants to send a text they can SEND_TEXT(dest user, short text message). Dest user is a
|
||||
node number, or 0xff for broadcast.
|
||||
*/
|
||||
|
||||
// a gps position
|
||||
|
@ -160,3 +174,4 @@ message ToRadio {
|
|||
WantNodes want_nodes = 4; // phone wants radio to send full node db to the phone
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue