|
|
@ -76,12 +76,9 @@ public class ArduinoControllerServiceImpl implements ArduinoControllerService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Path("device/{deviceId}/bulb")
|
|
|
|
@Path("device/{deviceId}/bulb")
|
|
|
|
@POST
|
|
|
|
@POST
|
|
|
|
public Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol,
|
|
|
|
public Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state) {
|
|
|
|
@FormParam("state") String state) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LinkedList<String> deviceControlList = internalControlsQueue.get(deviceId);
|
|
|
|
LinkedList<String> deviceControlList = internalControlsQueue.get(deviceId);
|
|
|
|
String operation = "BULB:" + state.toUpperCase();
|
|
|
|
String operation = "BULB:" + state.toUpperCase();
|
|
|
|
log.info(operation);
|
|
|
|
|
|
|
|
if (deviceControlList == null) {
|
|
|
|
if (deviceControlList == null) {
|
|
|
|
deviceControlList = new LinkedList<>();
|
|
|
|
deviceControlList = new LinkedList<>();
|
|
|
|
deviceControlList.add(operation);
|
|
|
|
deviceControlList.add(operation);
|
|
|
@ -99,7 +96,6 @@ public class ArduinoControllerServiceImpl implements ArduinoControllerService {
|
|
|
|
public Response pushData(DeviceData dataMsg) {
|
|
|
|
public Response pushData(DeviceData dataMsg) {
|
|
|
|
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String deviceId = dataMsg.deviceId;
|
|
|
|
String deviceId = dataMsg.deviceId;
|
|
|
|
float pinData = dataMsg.value;
|
|
|
|
|
|
|
|
if (!ArduinoServiceUtils.publishToDAS(dataMsg.deviceId, dataMsg.value)) {
|
|
|
|
if (!ArduinoServiceUtils.publishToDAS(dataMsg.deviceId, dataMsg.value)) {
|
|
|
|
log.warn("An error occured whilst trying to publish pin data of Arduino with ID [" +
|
|
|
|
log.warn("An error occured whilst trying to publish pin data of Arduino with ID [" +
|
|
|
|
deviceId + "] of owner [" + owner + "]");
|
|
|
|
deviceId + "] of owner [" + owner + "]");
|
|
|
@ -111,7 +107,7 @@ public class ArduinoControllerServiceImpl implements ArduinoControllerService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Path("device/{deviceId}/controls")
|
|
|
|
@Path("device/{deviceId}/controls")
|
|
|
|
@GET
|
|
|
|
@GET
|
|
|
|
public Response readControls(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol) {
|
|
|
|
public Response readControls(@PathParam("deviceId") String deviceId) {
|
|
|
|
String result;
|
|
|
|
String result;
|
|
|
|
LinkedList<String> deviceControlList = internalControlsQueue.get(deviceId);
|
|
|
|
LinkedList<String> deviceControlList = internalControlsQueue.get(deviceId);
|
|
|
|
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
@ -142,10 +138,9 @@ public class ArduinoControllerServiceImpl implements ArduinoControllerService {
|
|
|
|
@Path("device/temperature")
|
|
|
|
@Path("device/temperature")
|
|
|
|
@POST
|
|
|
|
@POST
|
|
|
|
@Consumes(MediaType.APPLICATION_JSON)
|
|
|
|
@Consumes(MediaType.APPLICATION_JSON)
|
|
|
|
public Response pushTemperatureData(final DeviceData dataMsg, @Context HttpServletRequest request) {
|
|
|
|
public Response pushTemperatureData(final DeviceData dataMsg) {
|
|
|
|
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String deviceId = dataMsg.deviceId;
|
|
|
|
String deviceId = dataMsg.deviceId;
|
|
|
|
float temperature = dataMsg.value;
|
|
|
|
|
|
|
|
if (!ArduinoServiceUtils.publishToDAS(dataMsg.deviceId, dataMsg.value)) {
|
|
|
|
if (!ArduinoServiceUtils.publishToDAS(dataMsg.deviceId, dataMsg.value)) {
|
|
|
|
log.warn("An error occured whilst trying to publish temperature data of Arduino with ID [" + deviceId +
|
|
|
|
log.warn("An error occured whilst trying to publish temperature data of Arduino with ID [" + deviceId +
|
|
|
|
"] of owner [" + owner + "]");
|
|
|
|
"] of owner [" + owner + "]");
|
|
|
|