+
Message
Set Path
+
Share (Zero Hop)
Reset Path
Forget
@@ -149,15 +150,15 @@
this.connection = await SerialConnection.open();
this.connection.on("connected", () => this.onConnected());
this.connection.on("disconnected", () => this.onDisconnected());
- // this.connection.on("tx", (data) => console.log("tx", data));
- // this.connection.on("rx", (data) => console.log("rx", data));
+ this.connection.on("tx", (data) => console.log("tx", data));
+ this.connection.on("rx", (data) => console.log("rx", data));
},
async askForBleDevice() {
this.connection = await BleConnection.open();
this.connection.on("connected", () => this.onConnected());
this.connection.on("disconnected", () => this.onDisconnected());
- // this.connection.on("tx", (data) => console.log("tx", data));
- // this.connection.on("rx", (data) => console.log("rx", data));
+ this.connection.on("tx", (data) => console.log("tx", data));
+ this.connection.on("rx", (data) => console.log("rx", data));
},
async disconnect() {
if(this.connection){
@@ -337,6 +338,9 @@
await this.loadContacts();
},
+ async shareContact(contact) {
+ await this.connection.sendCommandShareContact(contact.publicKey);
+ },
async setPath(contact) {
const newOutPath = [
diff --git a/src/connection/connection.js b/src/connection/connection.js
index bd94102..27f984b 100644
--- a/src/connection/connection.js
+++ b/src/connection/connection.js
@@ -147,6 +147,13 @@ class Connection extends EventEmitter {
await this.sendToRadioFrame(data.toBytes());
}
+ async sendCommandShareContact(pubKey) {
+ const data = new BufferWriter();
+ data.writeByte(Constants.CommandCodes.ShareContact);
+ data.writeBytes(pubKey); // 32 bytes
+ await this.sendToRadioFrame(data.toBytes());
+ }
+
onFrameReceived(frame) {
// emit received frame
diff --git a/src/constants.js b/src/constants.js
index 304160b..28f3b45 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -27,6 +27,7 @@ class Constants {
ResetPath: 13,
SetAdvertLatLon: 14,
RemoveContact: 15,
+ ShareContact: 16,
}
static ResponseCodes = {