Commit 9300aa87 authored by Vlado Altmann's avatar Vlado Altmann
Browse files

GPIO bug fixes

parent 958330af
......@@ -26,8 +26,6 @@ import com.pi.lightbulb.configuration.ConfigurationServiceInterface.*;
public class ConfigurationService extends DefaultService {
public final static URI SERVICE_ID = new URI("ConfigurationService");
private ConfigurationClient client;
private ArrayList<DPWSParameterDescription> parameterDescriptionList = new ArrayList<DPWSParameterDescription>();
private HashMap<Integer, DPWSRule> rulesList1 = new HashMap<Integer, DPWSRule>();
......@@ -35,12 +33,12 @@ public class ConfigurationService extends DefaultService {
public ConfigurationService() {
try {
define(new URI("local:/com/pi/lightbulb/configuration/Configuration.wsdl"), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
define(new URI(Constants.CONFIGURATION_WSDL), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setServiceId(SERVICE_ID);
setServiceId(new URI(Constants.CONFIGURATION_SERVICE_ID));
client = new ConfigurationClient();
......
......@@ -4,18 +4,24 @@ import org.ws4d.java.types.URI;
public class Constants {
public final static String NAMESPACE_CONFIGURATION = "http://www.ws4d.org/Configuration";
public final static String NAMESPACE_CONFIGURATION = "http://www.ws4d.org/Configuration";
public final static String NAMESPACE_DEMO = "http://www.demo.com/bbsr";
public final static String NAMESPACE_DEMO = "http://www.demo.com/bbsr";
public final static String NAMESPACE = "http://www.ws4d.org/Device";
public final static String NAMESPACE = "http://www.ws4d.org/Device";
public final static String DEVICE = "LightBulb";
public final static String DEVICE = "LightBulb";
public final static String WSDL = "local:/com/pi/lightbulb/device/Switch.wsdl";
public final static String WSDL = "local:/com/pi/lightbulb/device/Switch.wsdl";
public final static String SERVICE_ID = "LightBulbService";
public final static String CONFIGURATION_WSDL = "local:/com/pi/lightbulb/configuration/Configuration.wsdl";
public final static String SERVICE_TYPE = "Switch";
public final static String SERVICE_ID = "LightBulbService";
public final static String CONFIGURATION_SERVICE_ID = "ConfigurationService";
public final static String SERVICE_TYPE = "Switch";
public final boolean ON_DEVICE = false;
}
package com.pi.lightbulb.device;
import java.io.IOException;
import org.ws4d.java.communication.CommunicationManagerRegistry;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.DefaultService;
......@@ -11,7 +12,6 @@ import org.ws4d.java.service.OperationStub;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.URI;
import com.pi.lightbulb.configuration.Constants;
/**
......@@ -92,6 +92,15 @@ public class LightBulbService extends DefaultService {
state = Boolean.parseBoolean(value);
if (state == true)
{
BulbGPIOListener.getInstance().setBulbStateOn();
}
else
{
BulbGPIOListener.getInstance().setBulbStateOff();
}
// create suitable response ...
ParameterValue result = operation.createOutputValue();
......@@ -122,6 +131,15 @@ public class LightBulbService extends DefaultService {
state = !state;
if (state == true)
{
BulbGPIOListener.getInstance().setBulbStateOn();
}
else
{
BulbGPIOListener.getInstance().setBulbStateOff();
}
// create suitable response ...
ParameterValue result = operation.createOutputValue();
......
......@@ -30,6 +30,7 @@ import org.ws4d.java.service.DefaultService;
import org.ws4d.java.types.URI;
import org.ws4d.java.util.Log;
import com.pi.lightbulb.client.LightBulbClient;
import com.pi.lightbulb.configuration.ConfigurationClient;
import com.pi.lightbulb.configuration.ConfigurationService;
import com.pi.lightbulb.configuration.ConfigurationServiceInterface.DPWSInterface;
......@@ -37,6 +38,7 @@ import com.pi.lightbulb.configuration.ConfigurationServiceInterface.DPWSParamete
import com.pi.lightbulb.configuration.ConfigurationServiceInterface.DataType;
import com.pi.lightbulb.configuration.ConfigurationServiceInterface.Role;
import com.pi.lightbulb.configuration.Constants;
import com.pi.lightbulb.gpio.GpioListener;
public class LightBulbServiceProvider {
......@@ -61,11 +63,12 @@ public class LightBulbServiceProvider {
// First we need a device.
LightBulbDevice device = new LightBulbDevice();
LightBulbService mainService = new LightBulbService();
LightBulbClient client = new LightBulbClient();
// Then we create a service.
final ConfigurationService configurationService = new ConfigurationService();
ConfigurationClient client = configurationService.getConfigurationClient();
ConfigurationClient configurationClient = configurationService.getConfigurationClient();
// Set supported interface types
ArrayList<DPWSInterface> list = new ArrayList<DPWSInterface>();
......@@ -77,7 +80,7 @@ public class LightBulbServiceProvider {
dpwsInterface.ruleSupport = true;
list.add(dpwsInterface);
client.setSupportedInterfaces(list);
configurationClient.setSupportedInterfaces(list);
//Set rule parameter
DPWSParameterDescription description = new DPWSParameterDescription();
......@@ -93,14 +96,38 @@ public class LightBulbServiceProvider {
// In the end we add our service to the device.
device.addService(configurationService);
device.addService(mainService);
String env = "SUDO_USER";
String environment = System.getenv(env);
if (environment != null) {
Log.info(env + "=" + environment);
} else {
Log.info(env + " is not assigned");
}
// Do not forget to start the device!
try {
device.start();
// Thread.sleep(5000);
// client.resetPairing();
// client.searchKnownDevices();
client.registerKnownHello();
// Select control buttons if on Pi
if (environment != null && environment.equals("pi")) {
GpioListener.getInstance().bindButton0(1);
//GpioListener.getInstance().bindButton0(3);
GpioListener.getInstance().registerDevice(device);
GpioListener.getInstance().registerClient(client);
GpioListener.getInstance().activateHello(true);
GpioListener.getInstance().activateProbe(true);
//BulbGPIOListener.getInstance().pulse(500);
}
} catch (IOException e) {
e.printStackTrace();
}
}
......
......@@ -3236,6 +3236,8 @@ public class DefaultDeviceGPIO extends DeviceCommons implements LocalDevice {
}
return null;
}
Log.info("Probe received");
if (GpioListener.getInstance().getGpioController() != null)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment