Skip to content

Commit

Permalink
Merge pull request #4 from AllanCapistrano/feat/client-tangle-hornet
Browse files Browse the repository at this point in the history
Feat/client tangle hornet
  • Loading branch information
AllanCapistrano authored Oct 9, 2023
2 parents 3e46549 + 30a25bd commit d396861
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 64 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.larsid</groupId>
<artifactId>SOFT-IoT-DLT-Client-Tangle</artifactId>
<groupId>br.uefs.larsid.iot.soft</groupId>
<artifactId>soft-iot-dlt-client-tangle-hornet</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package br.uefs.larsid.iot.soft.enums;
package node.type.enums;

public enum ConductType {
HONEST, MALICIOUS, SELFISH, CORRUPT, DISTURBING
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package br.uefs.larsid.iot.soft.models;
package node.type.models;

import br.uefs.larsid.extended.mapping.devices.services.IDevicePropertiesManager;
import br.uefs.larsid.iot.soft.models.conducts.Conduct;
import br.uefs.larsid.iot.soft.models.conducts.Honest;
import br.uefs.larsid.iot.soft.models.conducts.Malicious;
import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector;
import br.uefs.larsid.iot.soft.mqtt.ListenerDevices;
import br.uefs.larsid.iot.soft.services.NodeTypeService;
import br.uefs.larsid.iot.soft.tasks.CheckDevicesTask;
import br.uefs.larsid.iot.soft.tasks.RequestDataTask;
import br.uefs.larsid.iot.soft.tasks.WaitDeviceResponseTask;
import br.uefs.larsid.iot.soft.utils.MQTTClient;
import br.ufba.dcc.wiser.soft_iot.entities.Device;
import br.ufba.dcc.wiser.soft_iot.entities.Sensor;
import dlt.id.manager.services.IIDManagerService;
import node.type.models.conducts.Conduct;
import node.type.models.conducts.Honest;
import node.type.models.conducts.Malicious;
import node.type.models.tangle.LedgerConnector;
import node.type.mqtt.ListenerDevices;
import node.type.services.NodeTypeService;
import node.type.tasks.CheckDevicesTask;
import node.type.tasks.RequestDataTask;
import node.type.tasks.WaitDeviceResponseTask;
import node.type.utils.MQTTClient;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package br.uefs.larsid.iot.soft.models.conducts;
package node.type.models.conducts;

import br.uefs.larsid.iot.soft.enums.ConductType;
import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector;
import node.type.enums.ConductType;
import node.type.models.tangle.LedgerConnector;

public abstract class Conduct {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package br.uefs.larsid.iot.soft.models.conducts;
package node.type.models.conducts;
// TODO: Corrigir package em todas as classes.

import dlt.client.tangle.hornet.enums.TransactionType;
import dlt.client.tangle.hornet.model.transactions.Evaluation;
import dlt.client.tangle.hornet.model.transactions.Transaction;
import node.type.enums.ConductType;
import node.type.models.tangle.LedgerConnector;

import br.uefs.larsid.iot.soft.enums.ConductType;
import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector;
import dlt.client.tangle.enums.TransactionType;
import dlt.client.tangle.model.transactions.Evaluation;
import dlt.client.tangle.model.transactions.Transaction;
import java.util.logging.Logger;

public class Honest extends Conduct {
Expand All @@ -13,7 +15,7 @@ public class Honest extends Conduct {

/**
* Método construtor.
*
*
* @param ledgerConnector LedgerConnector - Conector para comunicação com a Tangle.
* @param id String - Identificador único do nó.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package br.uefs.larsid.iot.soft.models.conducts;
package node.type.models.conducts;

import dlt.client.tangle.hornet.enums.TransactionType;
import dlt.client.tangle.hornet.model.transactions.Evaluation;
import dlt.client.tangle.hornet.model.transactions.Transaction;
import node.type.enums.ConductType;
import node.type.models.tangle.LedgerConnector;

import br.uefs.larsid.iot.soft.enums.ConductType;
import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector;
import dlt.client.tangle.enums.TransactionType;
import dlt.client.tangle.model.transactions.Evaluation;
import dlt.client.tangle.model.transactions.Transaction;
import java.util.Random;
import java.util.logging.Logger;

Expand All @@ -17,7 +18,7 @@ public class Malicious extends Conduct {

/**
* Método construtor.
*
*
* @param ledgerConnector LedgerConnector - Conector para comunicação com a Tangle.
* @param id String - Identificador único do nó.
* @param honestyRate float - Taxa de honestidade do nó malicioso.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package br.uefs.larsid.iot.soft.models.tangle;
package node.type.models.tangle;

import dlt.client.tangle.model.transactions.Transaction;
import dlt.client.tangle.services.ILedgerReader;
import dlt.client.tangle.services.ILedgerSubscriber;
import dlt.client.tangle.services.ILedgerWriter;
import dlt.client.tangle.hornet.model.transactions.Transaction;
import dlt.client.tangle.hornet.services.ILedgerReader;
import dlt.client.tangle.hornet.services.ILedgerSubscriber;
import dlt.client.tangle.hornet.services.ILedgerWriter;

/**
* @author Allan Capistrano
Expand All @@ -15,7 +15,7 @@ public class LedgerConnector {

/**
* Inscreve em um tópico para escutar as transações que são realizadas.
*
*
* @param topic String - Tópico.
* @param iLedgerSubscriber ILedgerSubscriber - Objeto para inscrição.
*/
Expand All @@ -25,7 +25,7 @@ public void subscribe(String topic, ILedgerSubscriber iLedgerSubscriber) {

/**
* Se desinscreve de um tópico.
*
*
* @param topic String - Tópico.
* @param iLedgerSubscriber ILedgerSubscriber - Objeto para inscrição.
*/
Expand All @@ -35,7 +35,7 @@ public void unsubscribe(String topic, ILedgerSubscriber iLedgerSubscriber) {

/**
* Põe uma transação para ser publicada na Tangle.
*
*
* @param transaction Transaction - Transação que será publicada.
* @throws InterruptedException
*/
Expand All @@ -44,13 +44,13 @@ public void put(Transaction transaction) throws InterruptedException {
}

/**
* Obtém uma transação a partir do hash da mesma.
*
* @param hash String - Hash da transação.
* Obtém uma transação a partir do ID da mesma.
*
* @param id String - ID da transação.
* @return Transaction.
*/
public Transaction getTransactionByHash(String hash) {
return this.ledgerWriter.getTransactionByHash(hash);
public Transaction getTransactionById(String id) {
return this.ledgerReader.getTransactionById(id);
}

public ILedgerWriter getLedgerWriter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package br.uefs.larsid.iot.soft.mqtt;
package node.type.mqtt;

import node.type.models.NodeType;
import node.type.utils.MQTTClient;

import br.uefs.larsid.iot.soft.models.NodeType;
import br.uefs.larsid.iot.soft.utils.MQTTClient;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.logging.Logger;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/node/type/services/NodeTypeService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package node.type.services;

public interface NodeTypeService {

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package br.uefs.larsid.iot.soft.tasks;
package node.type.tasks;

import br.uefs.larsid.iot.soft.models.NodeType;
import java.io.IOException;
import java.util.TimerTask;
import java.util.logging.Logger;

import node.type.models.NodeType;

/**
* Classe responsável pela tarefa de atualizar a lista de dispositivos
* conectados ao nó.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package br.uefs.larsid.iot.soft.tasks;
package node.type.tasks;

import br.uefs.larsid.iot.soft.models.NodeType;
import java.util.TimerTask;
import java.util.logging.Logger;

import node.type.models.NodeType;

/**
* Classe responsável pela tarefa de requisitar dados de um dos sensores de um
* dispositivo aleatório que estão conectado ao nó.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package br.uefs.larsid.iot.soft.tasks;
package node.type.tasks;

import br.uefs.larsid.iot.soft.models.NodeType;
import java.util.TimerTask;
import java.util.logging.Logger;

import node.type.models.NodeType;

/**
* Classe responsável por verificar se houve resposta do dispositivo à
* requisição feita pelo nó.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package br.uefs.larsid.iot.soft.utils;
package node.type.utils;

import java.util.Arrays;
import java.util.logging.Logger;
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/OSGI-INF/blueprint/blueprint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<reference id="deviceManagerService"
interface="br.uefs.larsid.extended.mapping.devices.services.IDevicePropertiesManager" />

<reference id="ledgerWriterService" interface="dlt.client.tangle.services.ILedgerWriter" />
<reference id="ledgerReaderService" interface="dlt.client.tangle.services.ILedgerReader" />
<reference id="ledgerReaderService" interface="dlt.client.tangle.hornet.services.ILedgerReader" />
<reference id="ledgerWriterService" interface="dlt.client.tangle.hornet.services.ILedgerWriter" />
<reference id="idManagerService" interface="dlt.id.manager.services.IIDManagerService"/>

<bean id="mqttClient" class="br.uefs.larsid.iot.soft.utils.MQTTClient"
<bean id="mqttClient" class="node.type.utils.MQTTClient"
init-method="start" destroy-method="stop">
<property name="debugModeValue" value="${debugModeValue}" />
<property name="ip" value="${ip}" />
Expand All @@ -21,12 +21,12 @@
<property name="password" value="${pass}" />
</bean>

<bean id="ledgerConnector" class="br.uefs.larsid.iot.soft.models.tangle.LedgerConnector">
<bean id="ledgerConnector" class="node.type.models.tangle.LedgerConnector">
<property name="ledgerReader" ref="ledgerReaderService" />
<property name="ledgerWriter" ref="ledgerWriterService" />
</bean>

<bean id="nodeType" class="br.uefs.larsid.iot.soft.models.NodeType"
<bean id="nodeType" class="node.type.models.NodeType"
init-method="start" destroy-method="stop">
<property name="MQTTClient" ref="mqttClient" />
<property name="nodeType" value="${nodeType}" />
Expand Down

0 comments on commit d396861

Please sign in to comment.