diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5b450d4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/bin/*
diff --git a/.project b/.project
new file mode 100644
index 0000000..9c84f34
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ CriticalMapsSender
+
+
+
+
+
+ connectiq.builder
+
+
+
+
+
+ connectiq.projectNature
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..dcc34eb
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Christopher
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/barrels.jungle b/barrels.jungle
new file mode 100644
index 0000000..e6c3bd8
--- /dev/null
+++ b/barrels.jungle
@@ -0,0 +1,6 @@
+# Do not hand edit this file. To make changes right click
+# on the project and select "Configure Monkey Barrels".
+
+CriticalMapsAPIBarrel = ../CriticalMapsAPIBarrel/bin/CriticalMapsAPIBarrel.barrel
+base.barrelPath = $(base.barrelPath);$(CriticalMapsAPIBarrel)
+
diff --git a/manifest.xml b/manifest.xml
new file mode 100644
index 0000000..b487d88
--- /dev/null
+++ b/manifest.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+ deu
+ eng
+
+
+
+
+
+
diff --git a/monkey.jungle b/monkey.jungle
new file mode 100644
index 0000000..87796c7
--- /dev/null
+++ b/monkey.jungle
@@ -0,0 +1 @@
+project.manifest = manifest.xml
diff --git a/resources/drawables/drawables.xml b/resources/drawables/drawables.xml
new file mode 100644
index 0000000..9f9551d
--- /dev/null
+++ b/resources/drawables/drawables.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/resources/drawables/launcher_icon.png b/resources/drawables/launcher_icon.png
new file mode 100644
index 0000000..d3594e7
Binary files /dev/null and b/resources/drawables/launcher_icon.png differ
diff --git a/resources/drawables/logo-icon-192.png b/resources/drawables/logo-icon-192.png
new file mode 100644
index 0000000..a9d4894
Binary files /dev/null and b/resources/drawables/logo-icon-192.png differ
diff --git a/resources/drawables/monkey.png b/resources/drawables/monkey.png
new file mode 100644
index 0000000..2f172d7
Binary files /dev/null and b/resources/drawables/monkey.png differ
diff --git a/resources/layouts/layout.xml b/resources/layouts/layout.xml
new file mode 100644
index 0000000..69a13a7
--- /dev/null
+++ b/resources/layouts/layout.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/settings/properties.xml b/resources/settings/properties.xml
new file mode 100644
index 0000000..77ad40d
--- /dev/null
+++ b/resources/settings/properties.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/resources/settings/settings.xml b/resources/settings/settings.xml
new file mode 100644
index 0000000..33b8b5b
--- /dev/null
+++ b/resources/settings/settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/strings/strings.xml b/resources/strings/strings.xml
new file mode 100644
index 0000000..b199544
--- /dev/null
+++ b/resources/strings/strings.xml
@@ -0,0 +1,11 @@
+
+ CriticalMapsSender
+
+ Critical Maps
+
+ Next CM
+ Count Nearby
+
+ Device Id
+
+
diff --git a/source/CriticalMapsSenderApp.mc b/source/CriticalMapsSenderApp.mc
new file mode 100644
index 0000000..3b134b0
--- /dev/null
+++ b/source/CriticalMapsSenderApp.mc
@@ -0,0 +1,34 @@
+using Toybox.Application;
+using Toybox.WatchUi;
+
+using CriticalMapsAPIBarrel;
+
+class CriticalMapsSenderApp extends Application.AppBase {
+
+ static var id;
+
+ function initialize() {
+ AppBase.initialize();
+
+ var mySettings = System.getDeviceSettings();
+ self.id = mySettings.uniqueIdentifier;
+
+ System.println("DeviceID: " + self.id);
+ }
+
+ // onStart() is called on application start up
+ function onStart(state) {
+
+ }
+
+ // onStop() is called when your application is exiting
+ function onStop(state) {
+ }
+
+ // Return the initial view of your application here
+ function getInitialView() {
+ System.println(CriticalMapsAPIBarrel.getDeviceId());
+ return [ new CriticalMapsSenderView(), new CriticalMapsSenderDelegate() ];
+ }
+
+}
diff --git a/source/CriticalMapsSenderDelegate.mc b/source/CriticalMapsSenderDelegate.mc
new file mode 100644
index 0000000..4dabadb
--- /dev/null
+++ b/source/CriticalMapsSenderDelegate.mc
@@ -0,0 +1,28 @@
+using Toybox.WatchUi;
+
+class CriticalMapsSenderDelegate extends WatchUi.BehaviorDelegate {
+
+ function initialize() {
+ BehaviorDelegate.initialize();
+ }
+
+ function onImagePress() {
+ CriticalMapsSenderWeb.sendPositionData();
+ }
+
+ function onMenu() {
+ var menu = new WatchUi.Menu();
+ menu.setTitle("CM Menu");
+ menu.addItem("DeviceId:", :item_info);
+
+ menu.addItem(CriticalMapsSenderApp.id.substring( 0, 20), :item_info);
+ menu.addItem(CriticalMapsSenderApp.id.substring(20, 40), :item_info);
+
+ menu.addItem("Last Rsp: " + lastResponse, :item_info);
+ menu.addItem("Num Rsp: " + numResponse, :item_info);
+
+ WatchUi.pushView(menu, new CriticalMapsSenderMenuDelegate(), WatchUi.SLIDE_UP);
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/source/CriticalMapsSenderMenuDelegate.mc b/source/CriticalMapsSenderMenuDelegate.mc
new file mode 100644
index 0000000..a16bec3
--- /dev/null
+++ b/source/CriticalMapsSenderMenuDelegate.mc
@@ -0,0 +1,18 @@
+using Toybox.WatchUi;
+using Toybox.System;
+using Toybox.Communications;
+
+class CriticalMapsSenderMenuDelegate extends WatchUi.MenuInputDelegate {
+
+ function initialize() {
+ MenuInputDelegate.initialize();
+ }
+
+ function onMenuItem(item) {
+ if (item == :item_info) {
+ System.println("Show Info");
+ CriticalMapsSenderWeb.sendPositionData();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/source/CriticalMapsSenderView.mc b/source/CriticalMapsSenderView.mc
new file mode 100644
index 0000000..d4da023
--- /dev/null
+++ b/source/CriticalMapsSenderView.mc
@@ -0,0 +1,56 @@
+using Toybox.WatchUi;
+
+var outText = "";
+
+class CriticalMapsSenderView extends WatchUi.View {
+
+ var myTimer = new Timer.Timer();
+
+ function initialize() {
+ View.initialize();
+ }
+
+ function onLayout(dc) {
+ setLayout(Rez.Layouts.MainLayout(dc));
+ }
+
+ function onShow() {
+ sendUpdate();
+ myTimer.start(method(:sendUpdate), 30000, true);
+ }
+
+ function onUpdate(dc) {
+ if(chatText.equals("")) {
+ outPutText("# Positions send: " + numResponse);
+ } else {
+ outPutText(chatText);
+ System.println(chatText);
+ }
+
+ var v_count = View.findDrawableById("v_count");
+ var v_next = View.findDrawableById("v_next");
+
+ v_count.setText(countCM10+"");
+ if (nearestCM == 999) {
+ v_next.setText("you are alone.");
+ } else {
+ v_next.setText(nearestCM.format("%.2f") + " km");
+ }
+
+ View.onUpdate(dc);
+ }
+
+ function outPutText(text) {
+ var lab = View.findDrawableById("outputtext");
+ lab.setText(text + "");
+ }
+
+ function sendUpdate() {
+ CriticalMapsSenderWeb.sendPositionData();
+ WatchUi.requestUpdate();
+ }
+
+ function onHide() {
+ }
+
+}
diff --git a/source/CriticalMapsSenderWeb.mc b/source/CriticalMapsSenderWeb.mc
new file mode 100644
index 0000000..57f302e
--- /dev/null
+++ b/source/CriticalMapsSenderWeb.mc
@@ -0,0 +1,41 @@
+using Toybox.Background;
+using Toybox.System;
+using Toybox.Position;
+using Toybox.Time;
+using Toybox.Communications;
+using Toybox.Math;
+
+using CriticalMapsAPIBarrel as CM;
+
+//const BASEURL = "http://192.168.0.8:8088/"; // Test
+const BASEURL = "https://api.criticalmaps.net/";
+
+var lastResponse = -1;
+var numResponse = 0;
+var nearestCM = 0;
+var countCM10 = 0;
+var chatText = "";
+
+(:background)
+class CriticalMapsSenderWeb extends Toybox.System.ServiceDelegate {
+
+ function initialize() {
+ System.ServiceDelegate.initialize();
+ }
+
+ function sendPositionData() {
+ var callback = new Lang.Method($, :callbackCM);
+ CM.sendPositionData(callback);
+ }
+}
+
+function callbackCM(responseCode, data) {
+ var result = CM.callbackCM(responseCode, data);
+ lastResponse = result["responseCode"];
+ if (lastResponse == 200){
+ numResponse += 1;
+ nearestCM = result["nearestCM"];
+ countCM10 = result["countCM10"];
+ chatText = result["chatText"];
+ }
+}
\ No newline at end of file