fixed issues in android sense

revert-dabc3590
ayyoob 9 years ago
parent e775c8ebe0
commit 3b75a2e9a4

@ -159,7 +159,7 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler {
*/
@Override
public void publishDeviceData(String... publishData) throws TransportHandlerException {
if (publishData.length != 3) {
if (publishData.length != 4) {
String errorMsg = "Incorrect number of arguments received to SEND-MQTT Message. " +
"Need to be [owner, deviceId, content]";
Log.e(TAG, errorMsg);

@ -251,7 +251,7 @@ public class LocalRegistry {
SharedPreferences sharedpreferences = context.getSharedPreferences(SENSE_SHARED_PREFERENCES, Context.MODE_PRIVATE);
LocalRegistry.tenantDomain = sharedpreferences.getString(TENANT_DOMAIN_KEY, "");
}
return LocalRegistry.mqttEndpoint;
return LocalRegistry.tenantDomain;
}
public static String getServerHost(Context context) {

@ -19,9 +19,9 @@
<eventReceiver name="EventReceiver_AndroidSense" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="oauth-mqtt">
<property name="topic">wso2/android_sense/+/data</property>
<property name="topic">wso2/carbon.super/android_sense/+/data</property>
<property name="username">admin</property>
<property name="contentValidationParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:2</property>
<property name="contentValidationParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:3</property>
<property name="contentValidation">default</property>
<property name="dcrUrl">https://localhost:9443/dynamic-client-web/register</property>
<property name="url">tcp://localhost:1883</property>

@ -47,7 +47,7 @@ public class AndroidSenseConstants {
public static final String SENSOR_ROTATION = "rotation";
public static final String SENSOR_WORDCOUNT = "wordcounter";
//MQTT Subscribe topic
public static final String MQTT_SUBSCRIBE_WORDS_TOPIC = "wso2/android_sense/+/data";
public static final String MQTT_SUBSCRIBE_WORDS_TOPIC = "wso2/+/android_sense/+/data";
public static final String DATA_SOURCE_NAME = "jdbc/AndroidSenseDM_DB";
public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
}

@ -47,8 +47,7 @@ public interface ArduinoControllerService {
@Path("device/{deviceId}/bulb")
@POST
@Feature(code = "bulb", name = "Control Bulb", type = "operation", description = "Control Bulb on Arduino Uno")
Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol,
@FormParam("state") String state);
Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state);
@Path("device/sensor")
@POST
@ -57,12 +56,12 @@ public interface ArduinoControllerService {
@Path("device/{deviceId}/controls")
@GET
Response readControls(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol);
Response readControls(@PathParam("deviceId") String deviceId);
@Path("device/temperature")
@POST
@Consumes(MediaType.APPLICATION_JSON)
Response pushTemperatureData(final DeviceData dataMsg, @Context HttpServletRequest request);
Response pushTemperatureData(final DeviceData dataMsg);
/**
* Retreive Sensor data for the device type

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

@ -34,7 +34,6 @@ import javax.ws.rs.core.Response;
@Path("enrollment")
@API(name = "arduino_mgt", version = "1.0.0", context = "/arduino_mgt", tags = {"arduino"})
@DeviceType(value = "arduino")
public interface ArduinoManagerService {
@Path("devices/{device_id}")
@ -61,9 +60,4 @@ public interface ArduinoManagerService {
@GET
@Produces("application/octet-stream")
Response downloadSketch(@QueryParam("deviceName") String customDeviceName);
@Path("devices/generate_link")
@GET
Response generateSketchLink(@QueryParam("deviceName") String deviceName);
}

@ -167,29 +167,6 @@ public class ArduinoManagerServiceImpl implements ArduinoManagerService {
}
}
@Override
@Path("devices/generate_link")
@GET
public Response generateSketchLink(@QueryParam("deviceName") String deviceName) {
try {
ZipArchive zipFile = createDownloadFile(APIUtil.getAuthenticatedUser(), deviceName);
Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId());
return rb.build();
} catch (IllegalArgumentException ex) {
return Response.status(400).entity(ex.getMessage()).build();//bad request
} catch (DeviceManagementException ex) {
return Response.status(500).entity(ex.getMessage()).build();
} catch (JWTClientException ex) {
return Response.status(500).entity(ex.getMessage()).build();
} catch (DeviceControllerException ex) {
return Response.status(500).entity(ex.getMessage()).build();
} catch (APIManagerException ex) {
return Response.status(500).entity(ex.getMessage()).build();
} catch (UserStoreException ex) {
return Response.status(500).entity(ex.getMessage()).build();
}
}
private ZipArchive createDownloadFile(String owner, String deviceName)
throws DeviceManagementException, JWTClientException, DeviceControllerException, APIManagerException,
UserStoreException {

Loading…
Cancel
Save