-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the github URL as user-agent and specify a date-code as software …
…version in the sens-com upload message.
- Loading branch information
Showing
4 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
sensor-data-bridge/src/test/java/nl/bertriksikken/senscom/RunSenscomUploader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package nl.bertriksikken.senscom; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import nl.bertriksikken.loraforwarder.AppDeviceId; | ||
import nl.bertriksikken.loraforwarder.AttributeMap; | ||
import nl.bertriksikken.pm.ESensorItem; | ||
import nl.bertriksikken.pm.SensorData; | ||
|
||
/** | ||
* Runs the SensComUploader to send a basic message to a local server, in order | ||
* to inspect the actual HTTP request. | ||
* <p> | ||
* Use with (for example): | ||
* https://gist.github.com/mdonkers/63e115cc0c79b4f6b8b3a6b797e485c7 | ||
*/ | ||
public final class RunSenscomUploader { | ||
|
||
public static void main(String[] args) { | ||
RunSenscomUploader runner = new RunSenscomUploader(); | ||
runner.run(); | ||
} | ||
|
||
private void run() { | ||
SensComConfig config = new SensComConfig("http://localhost:8080", 10); | ||
SensComUploader uploader = SensComUploader.create(config); | ||
uploader.start(); | ||
|
||
AppDeviceId id = new AppDeviceId("app", "device"); | ||
Map<AppDeviceId, AttributeMap> attributes = new HashMap<>(); | ||
attributes.put(id, new AttributeMap(Map.of("senscom-id", "sensor"))); | ||
uploader.scheduleProcessAttributes(attributes); | ||
|
||
SensorData sensorData = new SensorData(); | ||
sensorData.addValue(ESensorItem.TEMP, 12.34); | ||
uploader.scheduleUpload(id, sensorData); | ||
} | ||
|
||
} |