Skip to content
Commits on Source (2)
...@@ -17,27 +17,32 @@ import org.exolab.castor.xml.ValidationException; ...@@ -17,27 +17,32 @@ import org.exolab.castor.xml.ValidationException;
/** /**
* *
* <b>Description : This class allows to load and save data on a XML file. The castor API is used for the data binding. * <b>Description : This class allows to load and sav data on a XML file. The
* The default name for the file is the name of the class with ".xml" for the extension</b> * castor API is used for the data binding. The default name for the file is the
* name of the class with ".xml" for the extension</b> <br>
* need a specific library : org.exolab.castor.xml <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox <br>
* The aim of the project is to create a set of tools for amateur satellite
* purpose. All this tools could be used together to create specific software.
* <br> * <b>JOSAST</b> project is managed by AVMDTI
* need a specific library : org.exolab.castor.xml * (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) <br>
* <br> * This software is an open source software. Please read the <b><i>JOSAST
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox * licence</b></i><BR>
* <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software. * (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) * <p>
* <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) * for more information contact
* <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p> * <a href="mailto:josast@avmdti.org">josast@avmdti.org</a>
* </p>
*
* @author <a href="mailto:mercier.josast@avmdti.org">mercier</a> * @author <a href="mailto:mercier.josast@avmdti.org">mercier</a>
* @version 1.0 * @version 1.0
* <p><b><i> Source Update </b></i></p> * <p>
* <br> Version : date : name : comments * <b><i> Source Update </b></i>
* <br> V1 : 3 mars 2004 : C. Mercier : create file * </p>
* <br> V2 : 01 mai 2019 : C. Mercier : Change log system * <br>
* Version : date : name : comments <br>
* V1 : 3 mars 2004 : C. Mercier : create file <br>
* V2 : 01 mai 2019 : C. Mercier : Change log system
* <p> * <p>
*/ */
public abstract class AbstractDataBinding implements Serializable { public abstract class AbstractDataBinding implements Serializable {
...@@ -46,7 +51,7 @@ public abstract class AbstractDataBinding implements Serializable { ...@@ -46,7 +51,7 @@ public abstract class AbstractDataBinding implements Serializable {
* *
*/ */
private static final long serialVersionUID = 8410353753997330889L; private static final long serialVersionUID = 8410353753997330889L;
transient private String folder =".\\"; private transient String folder = ".\\";
private Logger log = Logger.getLogger("AmsatLogger"); private Logger log = Logger.getLogger("AmsatLogger");
...@@ -62,8 +67,7 @@ public abstract class AbstractDataBinding implements Serializable { ...@@ -62,8 +67,7 @@ public abstract class AbstractDataBinding implements Serializable {
Object o = null; Object o = null;
Reader reader = null; Reader reader = null;
File f = new File(fileName); File f = new File(fileName);
if (f.exists() ) if (f.exists()) {
{
try { try {
reader = new FileReader(fileName); reader = new FileReader(fileName);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
...@@ -82,16 +86,13 @@ public abstract class AbstractDataBinding implements Serializable { ...@@ -82,16 +86,13 @@ public abstract class AbstractDataBinding implements Serializable {
e.printStackTrace(); e.printStackTrace();
} }
} } else {
else
{
log.warning("file not found"); log.warning("file not found");
} }
return o; return o;
} }
/** /**
* This method save all parameters of the class in an XML file. * This method save all parameters of the class in an XML file.
*/ */
...@@ -121,7 +122,6 @@ public abstract class AbstractDataBinding implements Serializable { ...@@ -121,7 +122,6 @@ public abstract class AbstractDataBinding implements Serializable {
/** /**
* This method returns true if a configuration file already exist. * This method returns true if a configuration file already exist.
*
* @return true if the configuration file exist. * @return true if the configuration file exist.
*/ */
public boolean isExist() { public boolean isExist() {
...@@ -130,28 +130,27 @@ public abstract class AbstractDataBinding implements Serializable { ...@@ -130,28 +130,27 @@ public abstract class AbstractDataBinding implements Serializable {
return f.exists(); return f.exists();
} }
/** /**
* return the folder where the configuration file is read or save * return the folder where the configuration file is read or save
*
* @return * @return
*/ */
public String getFolder() { public String getFolder() {
return folder; return folder;
} }
/** /**
* set the folder where the configuration file is read or save. * set the folder where the configuration file is read or save. If the
* If the folder do not exist, the folder is created. * folder do not exist, the folder is created.
*
* @param folder * @param folder
* @return true if the folder exist else folder is not accessible * @return true if the folder exist else folder is not accessible
*/ */
public boolean setFolder(String folder) { public boolean setFolder(final String folder) {
this.folder = folder; this.folder = folder;
File f = new File(folder); File f = new File(folder);
boolean value = true; boolean value = true;
if (!f.exists()) if (!f.exists()) {
{
value = f.mkdir(); value = f.mkdir();
} }
return value; return value;
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
* <b>Description : used for demonstration to the config package. * <b>Description : used for demonstration to the config package.
* see main to understand how to used the AbstactDataBinding. </b> * see main to understand how to used the AbstactDataBinding. </b>
* <br> * <br>
*
*
* <p>Projet : JOSAST <BR> * <p>Projet : JOSAST <BR>
*
* <br> * <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox * <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox
* <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software. * <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
...@@ -28,9 +25,7 @@ import java.util.Vector; ...@@ -28,9 +25,7 @@ import java.util.Vector;
/** /**
* *
* <b>Description : </b> * <b>Description : </b>
* * <p>Projet : JOSAST <br>
*
* <p>Projet : JOSAST <BR>
* *
* <br> * <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox * <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox
...@@ -56,10 +51,7 @@ public class ConfigurationdataBindingDemo extends AbstractDataBinding { ...@@ -56,10 +51,7 @@ public class ConfigurationdataBindingDemo extends AbstractDataBinding {
private Vector<String> V = new Vector<String>(); private Vector<String> V = new Vector<String>();
private String directory = new String("C:\\temp"); private String directory = new String("C:\\temp");
private ConfigurationdataBindingDemo() {
private ConfigurationdataBindingDemo()
{
} }
/** /**
...@@ -68,21 +60,18 @@ public class ConfigurationdataBindingDemo extends AbstractDataBinding { ...@@ -68,21 +60,18 @@ public class ConfigurationdataBindingDemo extends AbstractDataBinding {
* else the function return a default object. * else the function return a default object.
* @return an instance of the class. * @return an instance of the class.
*/ */
public static ConfigurationdataBindingDemo getInstance() public static ConfigurationdataBindingDemo getInstance() {
{
// create a default object // create a default object
ConfigurationdataBindingDemo t = new ConfigurationdataBindingDemo(); ConfigurationdataBindingDemo t = new ConfigurationdataBindingDemo();
// test if the file exist // test if the file exist
// TODO : A REVOIR // TODO : A REVOIR
File f = new File(t.getDirectory()); File f = new File(t.getDirectory());
if (!f.exists()) if (!f.exists()) {
{
f.mkdir(); f.mkdir();
} }
t.setFolder(t.getDirectory()); t.setFolder(t.getDirectory());
if (t.isExist()) if (t.isExist()) {
{
// load the object // load the object
t = (ConfigurationdataBindingDemo) t.load(); t = (ConfigurationdataBindingDemo) t.load();
} }
...@@ -90,18 +79,14 @@ public static ConfigurationdataBindingDemo getInstance() ...@@ -90,18 +79,14 @@ public static ConfigurationdataBindingDemo getInstance()
return t; return t;
} }
/** /**
* display Vector data and also name of the class and version. <br> * display Vector data and also name of the class and version. <br>
*
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
public String toString() public String toString() {
{
return this.V.toString() + name + version; return this.V.toString() + name + version;
} }
/** /**
* @return field name. * @return field name.
*/ */
...@@ -125,10 +110,9 @@ public static ConfigurationdataBindingDemo getInstance() ...@@ -125,10 +110,9 @@ public static ConfigurationdataBindingDemo getInstance()
/** /**
* set field name. * set field name.
*
* @param string * @param string
*/ */
public void setName(String string) { public void setName(final String string) {
name = string; name = string;
} }
...@@ -137,7 +121,7 @@ public static ConfigurationdataBindingDemo getInstance() ...@@ -137,7 +121,7 @@ public static ConfigurationdataBindingDemo getInstance()
* *
* @param vector * @param vector
*/ */
public void setV(Vector<String> vector) { public void setV(final Vector<String> vector) {
V = vector; V = vector;
} }
...@@ -146,14 +130,13 @@ public static ConfigurationdataBindingDemo getInstance() ...@@ -146,14 +130,13 @@ public static ConfigurationdataBindingDemo getInstance()
* *
* @param d * @param d
*/ */
public void setVersion(double d) { public void setVersion(final double d) {
version = d; version = d;
} }
public void setDirectory(final String directory) {
public void setDirectory(String directory) {
this.directory = directory; this.directory = directory;
} }
...@@ -168,18 +151,14 @@ public static ConfigurationdataBindingDemo getInstance() ...@@ -168,18 +151,14 @@ public static ConfigurationdataBindingDemo getInstance()
* - modification des param�tres de l'objet * - modification des param�tres de l'objet
* - sauvegarde * - sauvegarde
* - lecture * - lecture
* * @param messages non utilis�
*
* @param Strings non utilis�
*/ */
public static void main(String[] Strings) public static void main(String[] arg) {
{
Vector<String> v = new Vector<String>(); Vector<String> v = new Vector<String>();
v.add("�lement 1"); v.add("�lement 1");
v.add("�l�ment 2"); v.add("�l�ment 2");
v.add("�l�ment 3"); v.add("�l�ment 3");
ConfigurationdataBindingDemo t = getInstance(); ConfigurationdataBindingDemo t = getInstance();
System.out.println("First Load" + t); System.out.println("First Load" + t);
t.setName("d�monstration du fichier"); t.setName("d�monstration du fichier");
t.setVersion(1.3); t.setVersion(1.3);
......
...@@ -8,30 +8,39 @@ import java.io.IOException; ...@@ -8,30 +8,39 @@ import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* *
* <b>Description : This class allows to save data in a configuration file.</b> * <b>Description : This class allows to save data in a configuration file.</b>
* <br> * <br>
* for the JOSAST project the org.josast.config.databinding is prefered to this package for storing data. * for the JOSAST project the org.josast.config.databinding is prefered to this
* package for storing data.
* *
* * <p>
* <p>Projet : JOSAST <BR> * Projet : JOSAST <BR>
* *
* <br> * <br>
* <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox * <b>JOSAST</b> : Java Open Source Amateur Satellite Toolbox <br>
* <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software. * The aim of the project is to create a set of tools for amateur satellite
* <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) * purpose. All this tools could be used together to create specific software.
* <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) * <b>JOSAST</b> project is managed by AVMDTI
* <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p> * (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> ) <br>
* This software is an open source software. Please read the <b><i>JOSAST
* licence</b></i><BR>
* (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
* <p>
* for more information contact
* <a href="mailto:josast@avmdti.org">josast@avmdti.org</a>
* </p>
*
* @author <a href="mailto:mercier.josast@avmdti.org">mercier</a> * @author <a href="mailto:mercier.josast@avmdti.org">mercier</a>
* @version 1.0 * @version 1.0
* <p><b><i> Source Update </b></i></p> * <p>
* <br> Version : date : name : comments * <b><i> Source Update </b></i>
* <br> V1 : 3 mars 2004 : C. Mercier : create file * </p>
* <br> V2 : 01 mai 2019 : C. Mercier : Change log system * <br>
* Version : date : name : comments <br>
* V1 : 3 mars 2004 : C. Mercier : create file <br>
* V2 : 01 mai 2019 : C. Mercier : Change log system
* <p> * <p>
*/ */
public class CONFIG { public class CONFIG {
...@@ -41,20 +50,16 @@ public class CONFIG { ...@@ -41,20 +50,16 @@ public class CONFIG {
private String fileName = "configuration.ini"; private String fileName = "configuration.ini";
/** Constructeur priv� */ /** Constructeur priv� */
private CONFIG() private CONFIG() {
{} }
private String getName() private String getName() {
{
String path = System.getProperty("user.dir") + "/config"; String path = System.getProperty("user.dir") + "/config";
File apath = new File(path); File apath = new File(path);
if (!apath.exists()) if (!apath.exists()) {
{
boolean res = apath.mkdir(); boolean res = apath.mkdir();
if (!res) if (!res) {
{
log.severe("fail to create " + path); log.severe("fail to create " + path);
} }
...@@ -62,28 +67,20 @@ public class CONFIG { ...@@ -62,28 +67,20 @@ public class CONFIG {
return path + "/" + fileName; return path + "/" + fileName;
} }
/** Holder */ /** Holder */
private static class SingletonHolder private static class SingletonHolder {
{
/** Instance unique non pr�initialis�e */ /** Instance unique non pr�initialis�e */
private final static CONFIG instance = new CONFIG(); private static final CONFIG instance = new CONFIG();
} }
/** Point d'acc�s pour l'instance unique du singleton */ /** Point d'acc�s pour l'instance unique du singleton */
public static CONFIG getInstance() public static CONFIG getInstance() {
{
return SingletonHolder.instance; return SingletonHolder.instance;
} }
public String GetProperty(final String Item) {
if (P == null) {
public String GetProperty(String Item) {
if (P==null)
{
try { try {
P = new Properties(); P = new Properties();
FileInputStream in = new FileInputStream(getName()); FileInputStream in = new FileInputStream(getName());
...@@ -95,12 +92,9 @@ public class CONFIG { ...@@ -95,12 +92,9 @@ public class CONFIG {
} }
} }
String S = P.getProperty(Item); String S = P.getProperty(Item);
if (S == null) if (S == null) {
{
return null; return null;
} } else {
else
{
return S.trim(); // $NON-NLS-1$ return S.trim(); // $NON-NLS-1$
} }
} }
...@@ -113,21 +107,17 @@ public class CONFIG { ...@@ -113,21 +107,17 @@ public class CONFIG {
* @param Valeur value to store * @param Valeur value to store
* *
*/ */
public void SetProperty(String Item, String Valeur) { public void SetProperty(final String Item, final String Valeur) {
if (P==null)
{
if (P == null) {
P = new Properties(); P = new Properties();
try { try {
FileInputStream in = new FileInputStream(getName()); FileInputStream in = new FileInputStream(getName());
P.load(in); P.load(in);
in.close(); in.close();
} } catch (Exception e2) {
catch (Exception e2) {
log.severe("Erreur de ouverture du fichier de configuration"); //$NON-NLS-1$ log.severe("Erreur de ouverture du fichier de configuration"); //$NON-NLS-1$
e2.printStackTrace(); e2.printStackTrace();
} }
...@@ -159,6 +149,7 @@ public class CONFIG { ...@@ -159,6 +149,7 @@ public class CONFIG {
/** /**
* Returns the nomFichier. * Returns the nomFichier.
*
* @return String * @return String
*/ */
public String getFileName() { public String getFileName() {
...@@ -167,9 +158,10 @@ public class CONFIG { ...@@ -167,9 +158,10 @@ public class CONFIG {
/** /**
* Sets the nomFichier. * Sets the nomFichier.
* @param fileName The nomFichier to set *
* @param nomfichier The nomFichier to set
*/ */
public void setFileName(String nomfichier) { public void setFileName(final String nomfichier) {
fileName = nomfichier; fileName = nomfichier;
} }
......
...@@ -15,26 +15,20 @@ public abstract class ConfigObject { ...@@ -15,26 +15,20 @@ public abstract class ConfigObject {
private Logger log = Logger.getLogger("AmsatLogger"); private Logger log = Logger.getLogger("AmsatLogger");
private String ConfigFilename = null; private String ConfigFilename = null;
private String fullConfigFilename = null; private String fullConfigFilename = null;
protected CONFIG ConfigFile = CONFIG.getInstance(); protected CONFIG ConfigFile = CONFIG.getInstance();
public ConfigObject () public ConfigObject() {
{
} }
public String getFulFileName() public String getFulFileName() {
{
fullConfigFilename = System.getProperty("user.dir") + "/config"; fullConfigFilename = System.getProperty("user.dir") + "/config";
File apath = new File(fullConfigFilename); File apath = new File(fullConfigFilename);
if (!apath.exists()) if (!apath.exists()) {
{
boolean res = apath.mkdir(); boolean res = apath.mkdir();
if (!res) if (!res) {
{
log.severe("fail to create " + fullConfigFilename); log.severe("fail to create " + fullConfigFilename);
} }
} }
return fullConfigFilename; return fullConfigFilename;
...@@ -45,7 +39,7 @@ public abstract class ConfigObject { ...@@ -45,7 +39,7 @@ public abstract class ConfigObject {
/** /**
* @param configFilename Configuration file name * @param configFilename Configuration file name
*/ */
public ConfigObject(String configFilename) { public ConfigObject(final String configFilename) {
super(); super();
ConfigFilename = configFilename; ConfigFilename = configFilename;
ConfigFile.setFileName(configFilename); ConfigFile.setFileName(configFilename);
...@@ -60,7 +54,4 @@ public abstract class ConfigObject { ...@@ -60,7 +54,4 @@ public abstract class ConfigObject {
return ConfigFilename; return ConfigFilename;
} }
} }
...@@ -29,13 +29,12 @@ public class ConfigHttp { ...@@ -29,13 +29,12 @@ public class ConfigHttp {
/** /**
* @param url URL of the properties file to read * @param url URL of the properties file to read
*/ */
public ConfigHttp(String url) { public ConfigHttp(final String url) {
super(); super();
this.url = url; this.url = url;
try { try {
loadProperties(); loadProperties();
} catch (Exception e) } catch (Exception e) {
{
log.severe(e.getMessage()); log.severe(e.getMessage());
} }
} }
...@@ -54,7 +53,8 @@ public class ConfigHttp { ...@@ -54,7 +53,8 @@ public class ConfigHttp {
try { try {
response = client.execute(request); response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
props.load(rd); props.load(rd);
connected = true; connected = true;
...@@ -73,16 +73,13 @@ public class ConfigHttp { ...@@ -73,16 +73,13 @@ public class ConfigHttp {
* @param Item property name * @param Item property name
* @return property value, null if property not found * @return property value, null if property not found
*/ */
public String GetProperty(String Item) { public String GetProperty(final String Item) {
if (props != null) { if (props != null) {
String S = props.getProperty(Item); String S = props.getProperty(Item);
if (S == null) if (S == null) {
{
return null; return null;
} } else {
else
{
return S.trim(); // $NON-NLS-1$ return S.trim(); // $NON-NLS-1$
} }
} }
...@@ -97,13 +94,10 @@ public class ConfigHttp { ...@@ -97,13 +94,10 @@ public class ConfigHttp {
return connected; return connected;
} }
public static void main(String[] args) { public static void main(String[] args) {
ConfigHttp c = new ConfigHttp("http://site.amsat-f.org/download/117168/"); ConfigHttp c = new ConfigHttp(
"http://site.amsat-f.org/download/117168/");
System.out.println(c.GetProperty("EntrySatVersion")); System.out.println(c.GetProperty("EntrySatVersion"));
} }
} }
...@@ -28,10 +28,9 @@ import org.josast.config.databinding.AbstractDataBinding; ...@@ -28,10 +28,9 @@ import org.josast.config.databinding.AbstractDataBinding;
public class test extends AbstractDataBinding { public class test extends AbstractDataBinding {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
int toto; private int toto;
Vector<String> V = new Vector<String>(); private Vector<String> V = new Vector<String>();
public test() public test() {
{
V.add("essai"); V.add("essai");
V.add("test"); V.add("test");
} }
...@@ -46,12 +45,11 @@ public class test extends AbstractDataBinding { ...@@ -46,12 +45,11 @@ public class test extends AbstractDataBinding {
/** /**
* @param i * @param i
*/ */
public void setToto(int i) { public void setToto(final int i) {
toto = i; toto = i;
} }
/** /**
* @return * @return
*/ */
...@@ -62,18 +60,14 @@ public class test extends AbstractDataBinding { ...@@ -62,18 +60,14 @@ public class test extends AbstractDataBinding {
/** /**
* @param vector * @param vector
*/ */
public void setV(Vector<String> vector) { public void setV(final Vector<String> vector) {
V = vector; V = vector;
} }
public static void main(String[] strings) {
public static void main(String[] strings)
{
test t = new test(); test t = new test();
t.setFolder("D:\\temps2"); t.setFolder("D:\\temps2");
t.setToto(4); t.setToto(4);
t.save(); t.save();
} }
......
...@@ -33,7 +33,7 @@ import org.apache.http.ssl.TrustStrategy; ...@@ -33,7 +33,7 @@ import org.apache.http.ssl.TrustStrategy;
*/ */
public class HttpPostSIDS { public class HttpPostSIDS {
private static Logger logger = Logger.getLogger("AmsatLogger"); private static Logger logger = Logger.getLogger("AmsatLogger");
private static String USER_AGENT = "Mozilla/5.0"; private static String USERAGENT = "Mozilla/5.0";
private CloseableHttpClient client = null; private CloseableHttpClient client = null;
private HttpPost post = null; private HttpPost post = null;
private StringBuffer result = null; private StringBuffer result = null;
...@@ -45,11 +45,11 @@ public class HttpPostSIDS { ...@@ -45,11 +45,11 @@ public class HttpPostSIDS {
* *
* @param url Database http or https adress * @param url Database http or https adress
*/ */
public HttpPostSIDS(String url) { public HttpPostSIDS(final String url) {
client = getCloseableHttpClient(); client = getCloseableHttpClient();
post = new HttpPost(url); post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT); post.setHeader("User-Agent", USERAGENT);
} }
...@@ -59,16 +59,16 @@ public class HttpPostSIDS { ...@@ -59,16 +59,16 @@ public class HttpPostSIDS {
* @param url * @param url
* @param token provided by satnogs if * @param token provided by satnogs if
*/ */
public HttpPostSIDS(String url, String token) { public HttpPostSIDS(final String url, final String token) {
client = getCloseableHttpClient(); client = getCloseableHttpClient();
post = new HttpPost(url); post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT); post.setHeader("User-Agent", USERAGENT);
addSatnogsToken(token); addSatnogsToken(token);
} }
public void addSatnogsToken(String token) { public void addSatnogsToken(final String token) {
post.addHeader("Authorization", "Token " + token); post.addHeader("Authorization", "Token " + token);
} }
...@@ -76,18 +76,29 @@ public class HttpPostSIDS { ...@@ -76,18 +76,29 @@ public class HttpPostSIDS {
private CloseableHttpClient getCloseableHttpClient() { private CloseableHttpClient getCloseableHttpClient() {
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
try { try {
httpClient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) httpClient = HttpClients.custom()
.setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { .setSSLContext(new SSLContextBuilder()
.loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(
final X509Certificate[] arg0,
final String arg1)
throws CertificateException {
return true; return true;
} }
}).build()).build(); }).build())
.build();
} catch (KeyManagementException e) { } catch (KeyManagementException e) {
logger.severe("KeyManagementException in creating http client instance " + e.toString()); logger.severe(
"KeyManagementException in creating http client instance "
+ e.toString());
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
logger.severe("NoSuchAlgorithmException in creating http client instance " + e.toString()); logger.severe(
"NoSuchAlgorithmException in creating http client instance "
+ e.toString());
} catch (KeyStoreException e) { } catch (KeyStoreException e) {
logger.severe("KeyStoreException in creating http client instance " + e.toString()); logger.severe("KeyStoreException in creating http client instance "
+ e.toString());
} }
return httpClient; return httpClient;
} }
...@@ -96,20 +107,24 @@ public class HttpPostSIDS { ...@@ -96,20 +107,24 @@ public class HttpPostSIDS {
* @param sids * @param sids
* @return * @return
*/ */
public int SendSIDSBasic(SIDSData sids) { public int SendSIDSBasic(final SIDSData sids) {
// Data preparation // Data preparation
int resultat = 0; int resultat = 0;
HttpResponse response = null; HttpResponse response = null;
BufferedReader rd = null; BufferedReader rd = null;
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>(); List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("noradID", "" + sids.getNoradID())); urlParameters
.add(new BasicNameValuePair("noradID", "" + sids.getNoradID()));
urlParameters.add(new BasicNameValuePair("source", sids.getSource())); urlParameters.add(new BasicNameValuePair("source", sids.getSource()));
urlParameters.add(new BasicNameValuePair("timestamp", sids.getTimestamp())); urlParameters
.add(new BasicNameValuePair("timestamp", sids.getTimestamp()));
urlParameters.add(new BasicNameValuePair("frame", sids.getFrame())); urlParameters.add(new BasicNameValuePair("frame", sids.getFrame()));
urlParameters.add(new BasicNameValuePair("locator", sids.getLocator())); urlParameters.add(new BasicNameValuePair("locator", sids.getLocator()));
urlParameters.add(new BasicNameValuePair("longitude", "" + sids.getLongitude())); urlParameters.add(
urlParameters.add(new BasicNameValuePair("latitude", "" + sids.getLatitude())); new BasicNameValuePair("longitude", "" + sids.getLongitude()));
urlParameters.add(
new BasicNameValuePair("latitude", "" + sids.getLatitude()));
urlParameters.add(new BasicNameValuePair("version", "2.0.2")); urlParameters.add(new BasicNameValuePair("version", "2.0.2"));
try { try {
...@@ -127,12 +142,11 @@ public class HttpPostSIDS { ...@@ -127,12 +142,11 @@ public class HttpPostSIDS {
logger.severe("Cient executon error" + e.toString()); logger.severe("Cient executon error" + e.toString());
} }
if (response != null) if (response != null) {
{
try { try {
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
} catch (UnsupportedOperationException | IOException e) { } catch (UnsupportedOperationException | IOException e) {
logger.severe("Buffer reader Exception " + e.toString()); logger.severe("Buffer reader Exception " + e.toString());
} }
...@@ -144,7 +158,8 @@ public class HttpPostSIDS { ...@@ -144,7 +158,8 @@ public class HttpPostSIDS {
result.append(line); result.append(line);
} }
} catch (IOException e) { } catch (IOException e) {
logger.severe("Error reading line from server " + e.toString()); logger.severe(
"Error reading line from server " + e.toString());
} }
} }
return resultat; return resultat;
......
...@@ -4,7 +4,6 @@ import java.text.SimpleDateFormat; ...@@ -4,7 +4,6 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.TimeZone; import java.util.TimeZone;
/** /**
* SIDSdate is a simple class used to store SIDS data information * SIDSdate is a simple class used to store SIDS data information
* *
...@@ -14,56 +13,56 @@ import java.util.TimeZone; ...@@ -14,56 +13,56 @@ import java.util.TimeZone;
public class SIDSData { public class SIDSData {
private final SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat(
final private SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); "yyyy-MM-dd'T'HH:mm:ss'Z'");
private int noradID; // Norad ID of the spacecraft private int noradID; // Norad ID of the spacecraft
private String source = ""; // Callsign or user name of the receiver private String source = ""; // Callsign or user name of the receiver
private String timestamp; // UTC timestamp (see ISO 8601) 2018-01-24T23:42:46Z private String timestamp; // UTC timestamp (see ISO 8601)
// 2018-01-24T23:42:46Z
private String frame; // The received data, in hexadecimal string (AX.25 packet with or without KISS 'C0 00 .. C0'. Whitespaces optional. C0 00 A9 05 DE ...
final private String locator = "longLat"; //Type of the given receiver's location. Currently, only 'longLat' is supported. longLat
private String longitude=null; // Longitude of the receiver (WGS84) 8.95564E private String frame; // The received data, in hexadecimal string (AX.25
// packet with or without KISS 'C0 00 .. C0'.
// Whitespaces optional. C0 00 A9 05 DE ...
private String latitude=null; //Latitude of the receiver (WGS84) 49.73145N private final String locator = "longLat"; // Type of the given receiver's
// location. Currently, only
// 'longLat' is supported. longLat
private int tncPort = 0; // Optional as per SiDS standard specification, but not used in PicSat SiDS system 0 private String longitude = null; // Longitude of the receiver (WGS84)
// 8.95564E
private double azimuth = 0.0; // azimuth degree of directionnal antenna (if avaiblable) 10.5 private String latitude = null; // Latitude of the receiver (WGS84)
// 49.73145N
private double elevation= 0.0; // elevation degree of directionnal antenna (if avaiblable) 85.0 private int tncPort = 0; // Optional as per SiDS standard specification, but
// not used in PicSat SiDS system 0
private long fDown = 0; // Frequency of the receiver's downlink channel during reception (with Doppler), in Hz 435525000 private double azimuth = 0.0; // azimuth degree of directionnal antenna (if
// avaiblable) 10.5
final private String version = "2.0.1"; private double elevation = 0.0; // elevation degree of directionnal antenna
// (if avaiblable) 85.0
private long fDown = 0; // Frequency of the receiver's downlink channel
// during reception (with Doppler), in Hz 435525000
private final String version = "2.0.1";
public SIDSData() {
public SIDSData ( )
{
} }
/** /**
* addTelemetryData is used for adding telemetry data with associated TimeStamp. * addTelemetryData is used for adding telemetry data with associated
* The timestamp is formated in correct date format. * TimeStamp. The timestamp is formated in correct date format.
* *
* @param date Date in local time * @param date Date in local time
* @param inputframe telemetry data * @param inputframe telemetry data
*/ */
public void setTelemetryData ( Date date, String inputframe) public void setTelemetryData(final Date date, final String inputframe) {
{
ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
timestamp = ISO8601DATEFORMAT.format(date); timestamp = ISO8601DATEFORMAT.format(date);
...@@ -71,13 +70,11 @@ public class SIDSData { ...@@ -71,13 +70,11 @@ public class SIDSData {
} }
public String getLongitude() { public String getLongitude() {
return longitude; return longitude;
} }
public void setLongitude(String longitude) { public void setLongitude(final String longitude) {
this.longitude = longitude; this.longitude = longitude;
} }
...@@ -85,15 +82,15 @@ public class SIDSData { ...@@ -85,15 +82,15 @@ public class SIDSData {
return latitude; return latitude;
} }
public void setLatitude(String latitude) { public void setLatitude(final String latitudein) {
this.latitude = latitude; this.latitude = latitudein;
} }
public int getNoradID() { public int getNoradID() {
return noradID; return noradID;
} }
public void setNoradID(int noradID) { public void setNoradID(final int noradID) {
this.noradID = noradID; this.noradID = noradID;
} }
...@@ -101,7 +98,7 @@ public class SIDSData { ...@@ -101,7 +98,7 @@ public class SIDSData {
return source; return source;
} }
public void setSource(String source) { public void setSource(final String source) {
this.source = source; this.source = source;
} }
...@@ -109,7 +106,7 @@ public class SIDSData { ...@@ -109,7 +106,7 @@ public class SIDSData {
return timestamp; return timestamp;
} }
public void setTimestamp(String timestamp) { public void setTimestamp(final String timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
...@@ -117,7 +114,7 @@ public class SIDSData { ...@@ -117,7 +114,7 @@ public class SIDSData {
return frame; return frame;
} }
public void setFrame(String frame) { public void setFrame(final String frame) {
this.frame = frame; this.frame = frame;
} }
...@@ -125,7 +122,7 @@ public class SIDSData { ...@@ -125,7 +122,7 @@ public class SIDSData {
return tncPort; return tncPort;
} }
public void setTncPort(int tncPort) { public void setTncPort(final int tncPort) {
this.tncPort = tncPort; this.tncPort = tncPort;
} }
...@@ -133,7 +130,7 @@ public class SIDSData { ...@@ -133,7 +130,7 @@ public class SIDSData {
return azimuth; return azimuth;
} }
public void setAzimuth(double azimuth) { public void setAzimuth(final double azimuth) {
this.azimuth = azimuth; this.azimuth = azimuth;
} }
...@@ -141,7 +138,7 @@ public class SIDSData { ...@@ -141,7 +138,7 @@ public class SIDSData {
return elevation; return elevation;
} }
public void setElevation(double elevation) { public void setElevation(final double elevation) {
this.elevation = elevation; this.elevation = elevation;
} }
...@@ -149,20 +146,16 @@ public class SIDSData { ...@@ -149,20 +146,16 @@ public class SIDSData {
return fDown; return fDown;
} }
public void setfDown(long fDown) { public void setfDown(final long fDown) {
this.fDown = fDown; this.fDown = fDown;
} }
/** /**
* Set Station information. Fill source, longitude & latitude information. * Set Station information. Fill source, longitude & latitude information.
*
* @param station * @param station
*/ */
public void setStation(Station station) public void setStation(final Station station) {
{
source = station.getCallsign(); source = station.getCallsign();
...@@ -177,9 +170,7 @@ public class SIDSData { ...@@ -177,9 +170,7 @@ public class SIDSData {
return locator; return locator;
} }
public String toStringBasic() {
public String toStringBasic()
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("noradID="); sb.append("noradID=");
sb.append(noradID); sb.append(noradID);
...@@ -198,14 +189,8 @@ public class SIDSData { ...@@ -198,14 +189,8 @@ public class SIDSData {
sb.append("&version="); sb.append("&version=");
sb.append(version); sb.append(version);
return sb.toString(); return sb.toString();
} }
} }
...@@ -5,12 +5,10 @@ import java.util.regex.Pattern; ...@@ -5,12 +5,10 @@ import java.util.regex.Pattern;
public class Station { public class Station {
private String callsign = "XtopheSwl"; private String callsign = "XtopheSwl";
private String longitude = "1.47E"; private String longitude = "1.47E";
private String latitude = "43.56N"; private String latitude = "43.56N";
public Station(final String callsign, final String longitude, final String latitude) {
public Station(String callsign, String longitude, String latitude) {
super(); super();
this.callsign = callsign; this.callsign = callsign;
this.longitude = longitude; this.longitude = longitude;
...@@ -24,32 +22,30 @@ public class Station { ...@@ -24,32 +22,30 @@ public class Station {
public String getCallsign() { public String getCallsign() {
return callsign; return callsign;
} }
public void setCallsign(String callsign) { public void setCallsign(final String callsign) {
this.callsign = callsign; this.callsign = callsign;
} }
public String getLongitude() { public String getLongitude() {
return longitude; return longitude;
} }
public void setLongitude(String longitude) { public void setLongitude(final String longitude) {
this.longitude = longitude; this.longitude = longitude;
} }
public String getLatitude() { public String getLatitude() {
return latitude; return latitude;
} }
public void setLatitude(String latitude) { public void setLatitude(final String latitude) {
this.latitude = latitude; this.latitude = latitude;
} }
public boolean checkLatitude (String latitude) public boolean checkLatitude(final String latitude) {
{
Pattern p = Pattern.compile("[\\d]*\\.[\\d]*[N,S]"); Pattern p = Pattern.compile("[\\d]*\\.[\\d]*[N,S]");
Matcher m = p.matcher(latitude); Matcher m = p.matcher(latitude);
return m.matches(); return m.matches();
} }
public boolean checkLongitude (String longitude) public boolean checkLongitude(final String longitude) {
{
Pattern p = Pattern.compile("[\\d]*\\.[\\d]*[E,W]"); Pattern p = Pattern.compile("[\\d]*\\.[\\d]*[E,W]");
Matcher m = p.matcher(longitude); Matcher m = p.matcher(longitude);
...@@ -59,5 +55,4 @@ public class Station { ...@@ -59,5 +55,4 @@ public class Station {
} }
...@@ -14,56 +14,47 @@ import org.josast.SIDS.Station; ...@@ -14,56 +14,47 @@ import org.josast.SIDS.Station;
public class SendFile { public class SendFile {
SIDSData sids = new SIDSData(); private SIDSData sids = new SIDSData();
BufferedReader lecteurAvecBuffer = null; private BufferedReader lecteurAvecBuffer = null;
String ligne; private String ligne;
public void initSIDS () public void initSIDS() {
{
sids.setStation(new Station()); sids.setStation(new Station());
sids.setNoradID(99990); sids.setNoradID(99990);
} }
public void OpenFile(String file) public void openFile(final String file) {
{ try {
try
{
lecteurAvecBuffer = new BufferedReader(new FileReader(file)); lecteurAvecBuffer = new BufferedReader(new FileReader(file));
} } catch (FileNotFoundException exc) {
catch(FileNotFoundException exc)
{
System.out.println("Erreur d'ouverture"); System.out.println("Erreur d'ouverture");
} }
} }
public void readFile() {
public void readFile ()
{
boolean first = false; boolean first = false;
Date dateref = null; Date dateref = null;
try { try {
while ((ligne = lecteurAvecBuffer.readLine()) != null) while ((ligne = lecteurAvecBuffer.readLine()) != null) {
{
String[] result1 = ligne.split("="); String[] result1 = ligne.split("=");
String[] date = result1[1].split("]"); String[] date = result1[1].split("]");
String[] trame = result1[2].split("]"); String[] trame = result1[2].split("]");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy",Locale.ENGLISH); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
"E MMM dd hh:mm:ss z yyyy", Locale.ENGLISH);
System.out.println("date : "+date[0]+" - Trame "+trame[0]); System.out
.println("date : " + date[0] + " - Trame " + trame[0]);
Date date2 = simpleDateFormat.parse(date[0]); Date date2 = simpleDateFormat.parse(date[0]);
if (first==false) if (first == false) {
{
dateref = date2; dateref = date2;
first = true; first = true;
} else {
System.out.println(
(date2.getTime() - dateref.getTime()) / 1000);
} }
else
{
System.out.println((date2.getTime() - dateref.getTime())/1000);
}
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -76,8 +67,7 @@ public class SendFile { ...@@ -76,8 +67,7 @@ public class SendFile {
} }
public void closeFile() public void closeFile() {
{
try { try {
lecteurAvecBuffer.close(); lecteurAvecBuffer.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -86,20 +76,14 @@ public class SendFile { ...@@ -86,20 +76,14 @@ public class SendFile {
} }
} }
public static void main(String[] argv) throws IOException public static void main(String[] argv) throws IOException {
{
SendFile sf = new SendFile(); SendFile sf = new SendFile();
sf.OpenFile(argv[0]); sf.openFile(argv[0]);
sf.initSIDS(); sf.initSIDS();
sf.readFile(); sf.readFile();
sf.closeFile(); sf.closeFile();
} }
} }
...@@ -18,37 +18,30 @@ public class TestSIDS { ...@@ -18,37 +18,30 @@ public class TestSIDS {
private HttpPostSIDS client = null; private HttpPostSIDS client = null;
public TestSIDS(final String url) {
public TestSIDS(String url) {
super(); super();
client = new HttpPostSIDS(url); client = new HttpPostSIDS(url);
} }
public void send(final SIDSData sids) {
public void Send(SIDSData sids)
{
int result = client.SendSIDSBasic(sids); int result = client.SendSIDSBasic(sids);
System.out.println("resutats = " + result); System.out.println("resutats = " + result);
System.out.println("resutats = " + client.getResult()); System.out.println("resutats = " + client.getResult());
} }
/** /**
* @param args * @param args
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
// String url = "https://db.satnogs.org/api/telemetry/"; // String url = "https://db.satnogs.org/api/telemetry/";
// String url = "https://db-dev.satnogs.org/api/telemetry/"; // String url = "https://db-dev.satnogs.org/api/telemetry/";
// String url = "http://127.0.0.1:9000/echoPost"; // String url = "http://127.0.0.1:9000/echoPost";
// String url = "https://amsat.electrolab.fr/SIDS"; // String url = "https://amsat.electrolab.fr/SIDS";
String url = "http:/127.0.0.1:8080/SIDS"; String url = "http:/127.0.0.1:8080/SIDS";
TestSIDS test = new TestSIDS(url); TestSIDS test = new TestSIDS(url);
// initialise SIDS data // initialise SIDS data
SIDSData sids = new SIDSData(); SIDSData sids = new SIDSData();
...@@ -57,7 +50,7 @@ public class TestSIDS { ...@@ -57,7 +50,7 @@ public class TestSIDS {
sids.setTelemetryData(GregorianCalendar.getInstance().getTime(), sids.setTelemetryData(GregorianCalendar.getInstance().getTime(),
"8c6c96a88240e09e9c60648ca46103f0000000000801ca5c0012100319240a0d4b5f0600ff2800002822443e6fb0870d0a24c0"); "8c6c96a88240e09e9c60648ca46103f0000000000801ca5c0012100319240a0d4b5f0600ff2800002822443e6fb0870d0a24c0");
System.out.println(sids.toStringBasic()); System.out.println(sids.toStringBasic());
test.Send(sids); test.send(sids);
} }
......
...@@ -11,18 +11,17 @@ ...@@ -11,18 +11,17 @@
<artifactId>ModuleSoundModem</artifactId> <artifactId>ModuleSoundModem</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> -->
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<plugin.compiler.version>2.3.2</plugin.compiler.version> <plugin.compiler.version>2.3.2</plugin.compiler.version>
<commons-cli.version>1.4 </commons-cli.version>
<kaitai-struct-runtime.version>0.9</kaitai-struct-runtime.version>
</properties> </properties>
...@@ -34,11 +33,10 @@ ...@@ -34,11 +33,10 @@
<artifactId>ModuleConfig</artifactId> <artifactId>ModuleConfig</artifactId>
<version>${josast.version}</version> <version>${josast.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-cli</groupId> <groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId> <artifactId>commons-cli</artifactId>
<version>1.4</version> <version>${commons-cli.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
...@@ -46,18 +44,11 @@ ...@@ -46,18 +44,11 @@
<version>5.5.2</version> <version>5.5.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/name.valery1707.kaitai/kaitai-maven-plugin -->
<!-- <dependency> -->
<!-- <groupId>name.valery1707.kaitai</groupId> -->
<!-- <artifactId>kaitai-maven-plugin</artifactId> -->
<!-- <version>${kaitai-maven-plugin-version}</version> -->
<!-- </dependency> -->
<!-- https://mvnrepository.com/artifact/io.kaitai/kaitai-struct-runtime --> <!-- https://mvnrepository.com/artifact/io.kaitai/kaitai-struct-runtime -->
<dependency> <dependency>
<groupId>io.kaitai</groupId> <groupId>io.kaitai</groupId>
<artifactId>kaitai-struct-runtime</artifactId> <artifactId>kaitai-struct-runtime</artifactId>
<version>0.8</version> <version>${kaitai-struct-runtime.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
...@@ -75,7 +66,6 @@ ...@@ -75,7 +66,6 @@
<goal>single</goal> <goal>single</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<archive> <archive>
...@@ -89,8 +79,6 @@ ...@@ -89,8 +79,6 @@
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </descriptorRefs>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
......
...@@ -75,8 +75,7 @@ public void decodeAX25Frame (byte[] frame , int lenght) ...@@ -75,8 +75,7 @@ public void decodeAX25Frame (byte[] frame , int lenght)
Callsign calsign = new Callsign(); Callsign calsign = new Callsign();
char [] val =new char[6]; char [] val =new char[6];
for (int i=0;i<6;i++) for (int i=0;i<6;i++){
{
char c= (char) ((arg0[i+offset] & 0xFF) >>1 & 0x7F); char c= (char) ((arg0[i+offset] & 0xFF) >>1 & 0x7F);
...@@ -88,8 +87,7 @@ public void decodeAX25Frame (byte[] frame , int lenght) ...@@ -88,8 +87,7 @@ public void decodeAX25Frame (byte[] frame , int lenght)
} }
@Deprecated @Deprecated
public Callsign getFromClassign () public Callsign getFromClassign() {
{
return from; return from;
} }
@Deprecated @Deprecated
......
...@@ -2,6 +2,7 @@ package org.josast.AX25; ...@@ -2,6 +2,7 @@ package org.josast.AX25;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@Deprecated @Deprecated
public class KissFrame { public class KissFrame {
...@@ -26,38 +27,46 @@ public class KissFrame { ...@@ -26,38 +27,46 @@ public class KissFrame {
public void setType(byte ax252) { public void setType(byte ax252) {
type = ax252; type = ax252;
} }
@Deprecated @Deprecated
public byte DecodeKissType(byte val) { public byte DecodeKissType(final byte val) {
switch (val) { switch (val) {
case 0x00: type = AX25; case 0x00:
type = AX25;
log.log(Level.INFO, "AX25 type"); log.log(Level.INFO, "AX25 type");
break; break;
case 0x01: type = TXDELAY; case 0x01:
type = TXDELAY;
break; break;
case 0x02: type = P; case 0x02:
type = P;
break; break;
case 0x03: type = SlotTime; case 0x03:
type = SlotTime;
break; break;
case 0x04: type = TXtail; case 0x04:
type = TXtail;
break; break;
case 0x05: type = Fullduplex; case 0x05:
type = Fullduplex;
break; break;
case 0x07: type = SetHardware; case 0x07:
type = SetHardware;
break; break;
case (byte) 0xFF: type = (byte) Exit; case (byte) 0xFF:
type = (byte) Exit;
break; break;
default : type = unknow; default:
type = unknow;
log.log(Level.INFO, "unknow type"); log.log(Level.INFO, "unknow type");
} }
return type; return type;
} }
@Deprecated @Deprecated
public KissData extactMessage(byte[] frame, int nb ) public KissData extactMessage(byte[] frame, int nb) {
{
KissData kissData; KissData kissData;
type = unknow; type = unknow;
...@@ -68,14 +77,11 @@ public class KissFrame { ...@@ -68,14 +77,11 @@ public class KissFrame {
cptcontents = 0; cptcontents = 0;
// detect start frame // detect start frame
while (!startFrame ) while (!startFrame) {
{ if (((byte) frame[cpt++] & 0xFF) == 0xC0) {
if (((byte)frame[cpt++] & 0xFF)== 0xC0)
{
startFrame = true; startFrame = true;
} }
if (cpt==nb) if (cpt == nb) {
{
startFrame = true; startFrame = true;
endFrame = true; endFrame = true;
} }
...@@ -84,26 +90,21 @@ public class KissFrame { ...@@ -84,26 +90,21 @@ public class KissFrame {
type = DecodeKissType((byte) (frame[cpt++] & 0xFF)); type = DecodeKissType((byte) (frame[cpt++] & 0xFF));
// Extract data // Extract data
while (!endFrame ) while (!endFrame) {
{
if (((int)frame[cpt] & 0xFF)== 0xDB) if (((int) frame[cpt] & 0xFF) == 0xDB) {
{
cpt++; cpt++;
} }
if (((int)frame[cpt] & 0xFF)== 0xDD) if (((int) frame[cpt] & 0xFF) == 0xDD) {
{
cpt++; cpt++;
} }
if (((int)frame[cpt] & 0xFF)== 0xC0) if (((int) frame[cpt] & 0xFF) == 0xC0) {
{
endFrame = true; endFrame = true;
} }
contents[cptcontents++] = (byte) (frame[cpt++] & 0xFF); contents[cptcontents++] = (byte) (frame[cpt++] & 0xFF);
if (cpt>=nb) if (cpt >= nb) {
{
endFrame = true; endFrame = true;
} }
...@@ -113,5 +114,4 @@ public class KissFrame { ...@@ -113,5 +114,4 @@ public class KissFrame {
} }
} }
...@@ -9,12 +9,12 @@ package org.josast.ModuleSoundModem; ...@@ -9,12 +9,12 @@ package org.josast.ModuleSoundModem;
*/ */
public class KissException extends Exception { public class KissException extends Exception {
/** /**.
* *
*/ */
private static final long serialVersionUID = 7103474292775784017L; private static final long serialVersionUID = 7103474292775784017L;
/** /**.
* *
*/ */
public KissException() { public KissException() {
...@@ -24,7 +24,7 @@ public class KissException extends Exception { ...@@ -24,7 +24,7 @@ public class KissException extends Exception {
/** /**
* @param message * @param message
*/ */
public KissException(String message) { public KissException(final String message) {
super(message); super(message);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
...@@ -32,7 +32,7 @@ public class KissException extends Exception { ...@@ -32,7 +32,7 @@ public class KissException extends Exception {
/** /**
* @param cause * @param cause
*/ */
public KissException(Throwable cause) { public KissException(final Throwable cause) {
super(cause); super(cause);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
...@@ -41,7 +41,7 @@ public class KissException extends Exception { ...@@ -41,7 +41,7 @@ public class KissException extends Exception {
* @param message * @param message
* @param cause * @param cause
*/ */
public KissException(String message, Throwable cause) { public KissException(final String message, final Throwable cause) {
super(message, cause); super(message, cause);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
...@@ -52,7 +52,7 @@ public class KissException extends Exception { ...@@ -52,7 +52,7 @@ public class KissException extends Exception {
* @param enableSuppression * @param enableSuppression
* @param writableStackTrace * @param writableStackTrace
*/ */
public KissException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { public KissException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace); super(message, cause, enableSuppression, writableStackTrace);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
......
...@@ -24,7 +24,6 @@ import org.apache.commons.cli.ParseException; ...@@ -24,7 +24,6 @@ import org.apache.commons.cli.ParseException;
public class SoundModemCli { public class SoundModemCli {
private Logger log = Logger.getLogger("AmsatLogger"); private Logger log = Logger.getLogger("AmsatLogger");
private static String version = "0.2"; private static String version = "0.2";
private String configurationfile = "defaultConfigFile.ini"; private String configurationfile = "defaultConfigFile.ini";
/* /*
......
...@@ -26,7 +26,6 @@ public class SoundModemClient { ...@@ -26,7 +26,6 @@ public class SoundModemClient {
private InputStream in = null; private InputStream in = null;
private boolean open = false; private boolean open = false;
private int bufferSize = 1024; private int bufferSize = 1024;
private Path filepath; private Path filepath;
/** /**
...@@ -44,7 +43,7 @@ public class SoundModemClient { ...@@ -44,7 +43,7 @@ public class SoundModemClient {
* Initialise connection to soundmodem application with configuration * Initialise connection to soundmodem application with configuration
* *
*/ */
public SoundModemClient(SoundModemConfiguration smConfig) { public SoundModemClient(final SoundModemConfiguration smConfig) {
smConfiguration = smConfig; smConfiguration = smConfig;
openSocket(); openSocket();
...@@ -52,11 +51,11 @@ public class SoundModemClient { ...@@ -52,11 +51,11 @@ public class SoundModemClient {
} }
/** /**.
* Initialise connection to soundmodem application with configuration file * Initialise connection to soundmodem application with configuration file
* *
*/ */
public SoundModemClient(String filename) { public SoundModemClient(final String filename) {
smConfiguration = new SoundModemConfiguration(filename); smConfiguration = new SoundModemConfiguration(filename);
openSocket(); openSocket();
...@@ -112,7 +111,7 @@ public class SoundModemClient { ...@@ -112,7 +111,7 @@ public class SoundModemClient {
} }
/** /**.
* wait bytes from sound modem * wait bytes from sound modem
* *
* @return bytes received in KISS format * @return bytes received in KISS format
...@@ -154,7 +153,7 @@ public class SoundModemClient { ...@@ -154,7 +153,7 @@ public class SoundModemClient {
} }
@Deprecated @Deprecated
public int receiveData(byte[] cbuf) { public int receiveData(final byte[] cbuf) {
try { try {
return in.read(cbuf); return in.read(cbuf);
} catch (IOException e) { } catch (IOException e) {
...@@ -172,7 +171,7 @@ public class SoundModemClient { ...@@ -172,7 +171,7 @@ public class SoundModemClient {
} }
@Deprecated @Deprecated
public AX25Frame decode(byte[] frame, int nb) { public AX25Frame decode(final byte[] frame, final int nb) {
KissFrame kf = new KissFrame(); KissFrame kf = new KissFrame();
KissData kissData = kf.extactMessage(frame, nb); KissData kissData = kf.extactMessage(frame, nb);
...@@ -202,9 +201,7 @@ public class SoundModemClient { ...@@ -202,9 +201,7 @@ public class SoundModemClient {
public byte[] receivedRawData() { public byte[] receivedRawData() {
byte[] temp = receivedKissData(); byte[] temp = receivedKissData();
if (temp != null) if (temp != null) {
{
kiss k = new kiss(temp); kiss k = new kiss(temp);
try { try {
...@@ -213,14 +210,11 @@ public class SoundModemClient { ...@@ -213,14 +210,11 @@ public class SoundModemClient {
log.log(Level.SEVERE, "Extract Raw data " + e.toString()); log.log(Level.SEVERE, "Extract Raw data " + e.toString());
} }
return temp; return temp;
} }
else else {
{
log.severe("Buffer read null, return null"); log.severe("Buffer read null, return null");
return null; return null;
} }
} }
} }
...@@ -9,11 +9,37 @@ import org.josast.property.ConfigObject; ...@@ -9,11 +9,37 @@ import org.josast.property.ConfigObject;
* @author Christophe * @author Christophe
* *
*/ */
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
/**
* @author christophe
*
*/
public class SoundModemConfiguration extends ConfigObject { public class SoundModemConfiguration extends ConfigObject {
private Logger log = Logger.getLogger("AmsatLogger"); private Logger log = Logger.getLogger("AmsatLogger");
/** Default IP Adress. */
private String smIPadress = "localhost"; private String smIPadress = "localhost";
/** Default port. */
private int smPort = 8100; private int smPort = 8100;
private boolean smGenerateBinarieFile = false; private boolean smGenerateBinarieFile = false;
private String smBinarieOutputFile = "soundmodem.bin"; private String smBinarieOutputFile = "soundmodem.bin";
...@@ -21,19 +47,24 @@ public class SoundModemConfiguration extends ConfigObject { ...@@ -21,19 +47,24 @@ public class SoundModemConfiguration extends ConfigObject {
private boolean smBinarieFilePrefixDate = false; private boolean smBinarieFilePrefixDate = false;
protected CONFIG configFile = CONFIG.getInstance();
protected CONFIG ConfigFile = CONFIG.getInstance(); /**
* @param configFilename
public SoundModemConfiguration(String configFilename) { */
public SoundModemConfiguration(final String configFilename) {
super(configFilename); super(configFilename);
// vérifie si la propriété est dans le fichier // vérifie si la propriété est dans le fichier
String temp = ConfigFile.GetProperty("smPort"); String temp = configFile.GetProperty("smPort");
if (temp == null) { if (temp == null) {
// config file not initialised // config file not initialised
initialisePropertiesFile(); initialisePropertiesFile();
log.severe("properties file not initialised - a file is created with properties with defaults value"); log.severe(
System.out.println("config file does not content required properties \n the file " + configFilename "properties file not initialised - a file is created with properties with defaults value");
System.out.println(
"config file does not content required properties \n the file "
+ configFilename
+ " has been set up with properties to configure"); + " has been set up with properties to configure");
} else { } else {
...@@ -43,78 +74,97 @@ public class SoundModemConfiguration extends ConfigObject { ...@@ -43,78 +74,97 @@ public class SoundModemConfiguration extends ConfigObject {
} }
private void initialisePropertiesFile() { private void initialisePropertiesFile() {
ConfigFile.SetProperty("smIPadress", smIPadress); configFile.SetProperty("smIPadress", smIPadress);
ConfigFile.SetProperty("smPort", "" + smPort); configFile.SetProperty("smPort", "" + smPort);
ConfigFile.SetProperty("smGenerateBinarieFile",""+smGenerateBinarieFile); configFile.SetProperty("smGenerateBinarieFile",
ConfigFile.SetProperty("smBinarieOutputFile",smBinarieOutputFile); "" + smGenerateBinarieFile);
ConfigFile.SetProperty("smBinarieOutputFile",smBinarieOutputDirectory); configFile.SetProperty("smBinarieOutputFile", smBinarieOutputFile);
ConfigFile.SetProperty("smBinarieFilePrefixDate",""+smBinarieFilePrefixDate); configFile.SetProperty("smBinarieOutputFile", smBinarieOutputDirectory);
configFile.SetProperty("smBinarieFilePrefixDate",
"" + smBinarieFilePrefixDate);
} }
private void initialiseFromProperties() private void initialiseFromProperties() {
{ smIPadress = configFile.GetProperty("smIPadress");
smIPadress = ConfigFile.GetProperty("smIPadress"); smPort = Integer.parseInt(configFile.GetProperty("smPort"));
smPort = Integer.parseInt(ConfigFile.GetProperty("smPort")); smGenerateBinarieFile = Boolean
smGenerateBinarieFile = Boolean.parseBoolean(ConfigFile.GetProperty("smGenerateBinarieFile")); .parseBoolean(configFile.GetProperty("smGenerateBinarieFile"));
smBinarieOutputFile = ConfigFile.GetProperty("smBinarieOutputFile"); smBinarieOutputFile = configFile.GetProperty("smBinarieOutputFile");
smBinarieOutputDirectory = ConfigFile.GetProperty("smBinarieOutputDirectory"); smBinarieOutputDirectory = configFile
smBinarieFilePrefixDate = Boolean.parseBoolean(ConfigFile.GetProperty("smBinarieFilePrefixDate")); .GetProperty("smBinarieOutputDirectory");
smBinarieFilePrefixDate = Boolean.parseBoolean(
configFile.GetProperty("smBinarieFilePrefixDate"));
} }
/**
* @return IP adress
*/
public String getSmIPadress() { public String getSmIPadress() {
return smIPadress; return smIPadress;
} }
public void setSmIPadress(String iPadress) { /**
* @param iPadress
*/
public void setSmIPadress(final String iPadress) {
smIPadress = iPadress; smIPadress = iPadress;
} }
/**
* @return Port
*/
public int getSmPort() { public int getSmPort() {
return smPort; return smPort;
} }
public void setSmPort(int port) { public void setSmPort(final int port) {
this.smPort = port; this.smPort = port;
} }
public String toString() { public String toString() {
return smIPadress + ":" + smPort; return smIPadress + ":" + smPort;
} }
/**
* @return GenerateBinarieFile
*/
public boolean isSmGenerateBinarieFile() { public boolean isSmGenerateBinarieFile() {
return smGenerateBinarieFile; return smGenerateBinarieFile;
} }
public void setSmGenerateBinarieFile(boolean smGenerateBinarieFile) { public void setSmGenerateBinarieFile(final boolean smGenerateBinarieFile) {
this.smGenerateBinarieFile = smGenerateBinarieFile; this.smGenerateBinarieFile = smGenerateBinarieFile;
} }
/**
* @return BinarieOutputFile
*/
public String getSmBinarieOutputFile() { public String getSmBinarieOutputFile() {
return smBinarieOutputFile; return smBinarieOutputFile;
} }
public void setSmBinarieOutputFile(String smBinarieOutputFile) { public void setSmBinarieOutputFile(final String smBinarieOutputFile) {
this.smBinarieOutputFile = smBinarieOutputFile; this.smBinarieOutputFile = smBinarieOutputFile;
} }
/**
* @return BinarieFilePrefixDate
*/
public boolean isSmBinarieFilePrefixDate() { public boolean isSmBinarieFilePrefixDate() {
return smBinarieFilePrefixDate; return smBinarieFilePrefixDate;
} }
public void setSmBinarieFilePrefixDate(boolean smBinarieFilePrefixDate) { public void setSmBinarieFilePrefixDate(final boolean smBinarieFilePrefixDate) {
this.smBinarieFilePrefixDate = smBinarieFilePrefixDate; this.smBinarieFilePrefixDate = smBinarieFilePrefixDate;
} }
/**
* @return BinarieOutputDirectory
*/
public String getSmBinarieOutputDirectory() { public String getSmBinarieOutputDirectory() {
return smBinarieOutputDirectory; return smBinarieOutputDirectory;
} }
public void setSmBinarieOutputDirectory(String smBinarieOutputDirectory) { public void setSmBinarieOutputDirectory(final String smBinarieOutputDirectory) {
this.smBinarieOutputDirectory = smBinarieOutputDirectory; this.smBinarieOutputDirectory = smBinarieOutputDirectory;
} }
} }
...@@ -2,11 +2,8 @@ package org.josast.ModuleSoundModem; ...@@ -2,11 +2,8 @@ package org.josast.ModuleSoundModem;
import java.util.Arrays; import java.util.Arrays;
/** /** manage Kiss frame based on KISS protocol.
* manage Kiss frame based on KISS protocol
*
* @see http://www.ka9q.net/papers/kiss.html * @see http://www.ka9q.net/papers/kiss.html
*
* @author christophe * @author christophe
* *
*/ */
...@@ -75,8 +72,7 @@ public class kiss { ...@@ -75,8 +72,7 @@ public class kiss {
throw new KissException("FEND (0xC0) value not find at the end of the frame "); throw new KissException("FEND (0xC0) value not find at the end of the frame ");
} }
// Identifie le type de trame // Identifie le type de trame
switch (kissdata[1]) switch (kissdata[1]) {
{
case 0 : type = DATA; case 0 : type = DATA;
break; break;
case 1 : type = TXDELAY; case 1 : type = TXDELAY;
...@@ -95,7 +91,6 @@ public class kiss { ...@@ -95,7 +91,6 @@ public class kiss {
break; break;
default : type = UNKNOW; default : type = UNKNOW;
} }
int cptraw = 0; int cptraw = 0;
...@@ -105,11 +100,9 @@ public class kiss { ...@@ -105,11 +100,9 @@ public class kiss {
rawData[cptraw++] = kissdata[i++]; rawData[cptraw++] = kissdata[i++];
} else { } else {
if (kissdata[i + 1] == TFEND) { if (kissdata[i + 1] == TFEND) {
rawData[cptraw++] = FEND; rawData[cptraw++] = FEND;
i = i + 2; i = i + 2;
} else if (kissdata[i + 1] == TFESC) { } else if (kissdata[i + 1] == TFESC) {
rawData[cptraw++] = FESC; rawData[cptraw++] = FESC;
i = i + 2; i = i + 2;
} else { } else {
......