-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d747ca2
Showing
19 changed files
with
277 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/* |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>CriticalMapsSender</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>connectiq.builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>connectiq.projectNature</nature> | ||
</natures> | ||
</projectDescription> |
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,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. |
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,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) | ||
|
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,19 @@ | ||
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3"> | ||
<iq:application entry="CriticalMapsSenderApp" id="b0e45c9ffc8d49fcb87c7a001fea2b08" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.0.0" name="@Strings.AppName" type="widget" version="0.0.0"> | ||
<iq:products> | ||
<iq:product id="edge1030"/> | ||
</iq:products> | ||
<iq:permissions> | ||
<iq:uses-permission id="Background"/> | ||
<iq:uses-permission id="Communications"/> | ||
<iq:uses-permission id="Positioning"/> | ||
</iq:permissions> | ||
<iq:languages> | ||
<iq:language>deu</iq:language> | ||
<iq:language>eng</iq:language> | ||
</iq:languages> | ||
<iq:barrels> | ||
<iq:depends name="CriticalMapsAPIBarrel" version="0.1.0"/> | ||
</iq:barrels> | ||
</iq:application> | ||
</iq:manifest> |
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 @@ | ||
project.manifest = manifest.xml |
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,4 @@ | ||
<drawables> | ||
<bitmap id="LauncherIcon" filename="launcher_icon.png" /> | ||
<bitmap id="cm_logo" filename="logo-icon-192.png" /> | ||
</drawables> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
<layout id="MainLayout"> | ||
<label x="center" y="5" text="@Strings.prompt" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_CENTER" /> | ||
<button x="center" y="50" width="192" height="192" behavior="onImagePress"> | ||
<state id="stateDefault" bitmap="@Drawables.cm_logo" /> | ||
</button> | ||
|
||
<label id="t_next" x="20" y="260" text="@Strings.t_cm_next" /> | ||
<label id="v_next" x="right" y="260" text="0 km" /> | ||
<label id="t_count" x="20" y="290" text="@Strings.t_cm_count" /> | ||
<label id="v_count" x="right" y="290" text="0" /> | ||
<label id="outputtext" x="left" y="340" text="-" color="Graphics.COLOR_WHITE" justification="Graphics.TEXT_JUSTIFY_LEFT" font="Graphics.FONT_SMALL" /> | ||
</layout> |
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,3 @@ | ||
<properties> | ||
<property id="deviceId" type="string"></property> | ||
</properties> |
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,5 @@ | ||
<settings> | ||
<setting propertyKey="@Properties.deviceId" title="@Strings.deviceIdTitle"> | ||
<settingConfig type="alphaNumeric" /> | ||
</setting> | ||
</settings> |
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,11 @@ | ||
<strings> | ||
<string id="AppName">CriticalMapsSender</string> | ||
|
||
<string id="prompt">Critical Maps</string> | ||
|
||
<string id="t_cm_next">Next CM</string> | ||
<string id="t_cm_count">Count Nearby</string> | ||
|
||
<string id="deviceIdTitle">Device Id</string> | ||
|
||
</strings> |
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,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() ]; | ||
} | ||
|
||
} |
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,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; | ||
} | ||
|
||
} |
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,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(); | ||
} | ||
} | ||
|
||
} |
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,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() { | ||
} | ||
|
||
} |
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,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"]; | ||
} | ||
} |