Hardware components | ||||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
| ||||||
| ||||||
| ||||||
Hand tools and fabrication machines | ||||||
| ||||||
| ||||||
|
Weather monitoring system with emergency notifications, based on Rapid IoT Prototyping Kit.
Always use technology to improve the world, if you are a black hat or gray hat hacker please abstain at this point......... or at least leave your respect to make me feel less guilty XP.
It is a fact that today the use of bicycles and other multimodal transport is increasing due to various reasons, including traffic, increase of awareness in global warming, etc...
This is very good for the planet but it puts the users in a continuous latent risk when using it due to factors such as:
- Inadequate climate to exercise due to high pollutants.
- Fatal danger caused by motor vehicles.
- Danger of falling or an accident due to the fact that the vehicle does not have a safety system for the user (bicycles, unlike cars, do not have an airbag or any protection, duh).
This project will provide an integral platform connected to a smartphone for constant weather monitoring, and whenever the user suffers a fall or accident, can effectively notify relatives or the corresponding authority (or emergency service) with only a button.
The solutions that exist today are SmartWatch based, which provide distance travelled, but do not provide an emergency warning system or real-time analysis of air quality.
NXP Software:For the development of the software we use the Rapid IoT Studio using the template "Rapid IoT Weather Station" as template.
- The BLE communication with the cell phone was eliminated because we do not need the data from the sensors to be sent to the application.
- Comparison modules were added in order to obtain the data from the sensors with the following configuration.
The comparison modules have to have the following connections to work correctly.
- For temperature, the comparison block is connected to the "GetTempStr" function.
- For humidity the comparison block is connected to the "GetHumidityStr" function.
- To press the comparison block is connected to the "GetPressureStr" function.
- For ambient light, the comparison block is connected directly to the sensor block "TSL2572AmbientLigth".
- For air quality, the comparison block is connected directly to the sensor block "CCS811AirQuality".
The configuration of each comparison block has the following structure.
The comparison blocks do not have the "Set Purlpe LED On" and "Set Yellow LED On" option set, we will have to modify the skill code "Set White LED On" and "Toogle Red LED" with the following code.
The code:
ATMO_Status_t EmbeddedNxpRpkRgbLed_setWhiteOn(ATMO_Value_t *in, ATMO_Value_t *out)
{
RGB_Led_Set_State(RGB_LED_BRIGHT_HIGH, RGB_LED_COLOR_PURPLE);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedNxpRpkRgbLed_toggleRed(ATMO_Value_t *in, ATMO_Value_t *out)
{
RGB_Led_Set_State(RGB_LED_BRIGHT_HIGH, RGB_LED_COLOR_YELLOW);
return ATMO_Status_Success;
}
For the app, the following configuration is used to make the emergency call.
For the configuration of the URL we will obtain our location, and create an account at: https://infinityfree.net/ and create two web pages that contain the codes at the bottom as "location.html" and "nxp.html".
The geolocation can be done in two different ways, the first uses the geolocation provided by our device through mobile data or WiFi. This is the most accurate but requires that the user accepts that the browser on their cell phone allows to determine the location (or give permissions to the brwoser app via settings).
<script>
var x = document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position)
{
x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude;
}
</script>
The second way to get geolocation is by IP location, through a GET Request by an AJAX script to a web page that provides IP location such as: http://extreme-ip-lookup.com/json/, the example at the end named: location.html is designed with IP localization, but it is possible to change it easily with the following script.
<script>
// Obtaining the location JSON
$.ajax({
dataType: "json",
url: "http://extreme-ip-lookup.com/json/",
data: data,
success: function (data)
{
var datav = JSON.parse(JSON.stringify(data))
// Print the location in the Map
doStuff(datav.lat, datav.lon)
</script>
<script>
function doStuff(mylat, mylong)
{
if (document.getElementById("GeoAPI"))
{
document.getElementById("GeoAPI").innerHTML = "<iframe style=\"width: 400px; height: 400px\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"//maps.google.com/?ll=" + mylat + "," + mylong + "&z=16&output=embed\"></iframe>";
}
}
</script>
Once both pages are created, we will have to create our MQTT broker, which we will make from any of the following options.
- CloudMQTT: https://www.cloudmqtt.com/
- IBM Bluemix: https://www.ibm.com/internet-of-things
For the configuration of broker we recommend to follow the manual, which explains in detail how to do it.
Link for our Watson IoT Platform manual: https://github.com/altaga/The-Ultimate-IBM-Watson-IoT-Platform-Guide
Through MQTT we will send our latitude and longitude to the web page, in order to be able to deploy it on the webapp or send notifications to Pushetta.
Pushetta notifications:Once the broker is configured successfully, only the pushetta configuration will be needed to send the notifications to any person we want.
As a first step we will have to create an account at http://www.pushetta.com/ and once this is created we will create a channel to send notifications.
When the channel for notifications is created, we will go to the tab of the dashboard, where we will find its APIKEY. This is important as we will use it later to send notifications via python.
Because Javascript only supports Pushetta combined with NodeJS, we had to perform an additional process to make notifications through pushetta, using a virtual machine in Watson Studio, running in the cloud. The process to create it is as follows.
1.- Create an account in Bluemix IBM: https://www.ibm.com/cloud/.
2.- Create the WatsonStudio service.
3.- Open WatsonStudio service.
4.- Create a new project.
5.- Select the Standard package.
6.- Put any name to the project.
7.- Go to the "Enviroments" tab.
8.- Select Default Python 3.5 Free.
9.- Select "New notebook".
10.- Put in any name.
11.- With this we will have configured our python notebook in the cloud to run the code that will be at the bottom as "NXPNotification.ipynb".
To make the python application work, we will use the same credentials that we use in the MQTT broker and the APIKEY that we obtained from pushetta. Once we execute the code we can close the window and our application will be running in the cloud.
NOTE: Due to the limitations of the free plans the application can not run for more than 100 hours in a month and also the application will be turned off every 12 hours, we simply recommend turning it on every time you go out to exercise. (Or pay for a service).
The Final Product:For the final product regarding environmental alerts, it was decided to use these values because they are the maximum recommended values for exercise.
An acrylic base was placed on the Rapid IoT Prototyping Kit and a watch strap was glued on to be placed on a bicycle, however during the experiments we noticed that it was also possible to use it as a watch, as shown in the following images.
Product Video:
Comments:In this project we discovered that it was very easy to program the limits of the sensors in the NXP Studio. Besides that its simple to make the connections between the nodes facilitated by the block programming of the application.
Also thanks to our experience with HTML5 we were able to easily program web applications to perform geolocation and communication by MQTT.
References:All the information about the technology used, and direct references are in our wiki:
Wiki: https://github.com/altaga/SmartBike-NXP/wiki
Top:
{
"name": "Rapid IoT Weather Station",
"createVersion": "2017-08-12",
"description": "Demonstrates reading of weather related sensors such as temperature, humidity, pressure, ambient light, and air quality. Demonstrates basic BLE Characteristic writing and reading as well as cloud storage.",
"lastModified": "2018-02-13T00:39:19.386Z",
"created": "2018-02-13T00:39:19.386Z",
"meta": {
"projectTypeName": "NXP Rapid IoT",
"projectTypeId": "NxpRpk"
},
"planes": {
"NXP Rapid IoT": {
"type": "mcuxpresso",
"compilerVersion": "latest",
"variants": [
"NxpRpk"
],
"meta": {},
"elements": [
{
"name": "SX9500Touch",
"type": "EmbeddedSX9500",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"setup": "\tATMO_SX9500_Config_t config;\n\tconfig.address = ATMO_PROPERTY(SX9500Touch, i2cAddress);\n\tconfig.i2cDriverInstance = ATMO_PROPERTY(SX9500Touch, i2cInstance);\n\tconfig.gpioDriverInstance = ATMO_PROPERTY(SX9500Touch, gpioInstance);\n\tconfig.interruptEnabled = ATMO_PROPERTY(SX9500Touch, interruptEnabled);\n\tconfig.interruptPin = ATMO_PROPERTY(SX9500Touch, interruptGpio);\n\tATMO_SX9500_Init(&config);\n\tATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Up, ATMO_ABILITY(SX9500Touch, pressUp));\n\tATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Down, ATMO_ABILITY(SX9500Touch, pressDown));\n\tATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Left, ATMO_ABILITY(SX9500Touch, pressLeft));\n\tATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Right, ATMO_ABILITY(SX9500Touch, pressRight));\n\treturn ATMO_Status_Success;",
"getTouchData": "",
"pressUp": "SX9500_TouchState_t touchState;\nATMO_GetBinary(in, &touchState, sizeof(touchState));\nATMO_CreateValueBinary(out, &touchState, sizeof(touchState));\nreturn ATMO_Status_Success;",
"pressDown": "SX9500_TouchState_t touchState;\nATMO_GetBinary(in, &touchState, sizeof(touchState));\nATMO_CreateValueBinary(out, &touchState, sizeof(touchState));\nreturn ATMO_Status_Success;",
"pressLeft": "SX9500_TouchState_t touchState;\nATMO_GetBinary(in, &touchState, sizeof(touchState));\nATMO_CreateValueBinary(out, &touchState, sizeof(touchState));\nreturn ATMO_Status_Success;",
"pressRight": "SX9500_TouchState_t touchState;\nATMO_GetBinary(in, &touchState, sizeof(touchState));\nATMO_CreateValueBinary(out, &touchState, sizeof(touchState));\nreturn ATMO_Status_Success;"
},
"variables": {},
"embeddedPropertyConversions": {},
"codeUserChanged": {
"setup": false,
"getTouchData": false,
"pressUp": false,
"pressDown": false,
"pressLeft": false,
"pressRight": false
},
"i2cInstance": "ATMO_DRIVERINSTANCE_I2C_I2C2",
"gpioInstance": "ATMO_DRIVERINSTANCE_GPIO_GPIO1",
"interruptEnabled": true,
"interruptGpio": "PTA9",
"i2cAddress": "0x28"
},
"meta": {
"editorX": 1079.33349609375,
"editorY": 33,
"lastTrigger": "rightPressed"
},
"triggers": {
"triggered": [],
"touchDataRead": [],
"upPressed": [
{
"mapping": {},
"targetOrder": [],
"targetElement": "EmbeddedPageController",
"targetAbility": "navigateUp"
}
],
"downPressed": [
{
"mapping": {},
"targetOrder": [],
"targetElement": "EmbeddedPageController",
"targetAbility": "navigateDown"
}
],
"leftPressed": [
{
"mapping": {},
"targetOrder": [],
"targetElement": "EmbeddedPageController",
"targetAbility": "navigateLeft"
}
],
"rightPressed": [
{
"mapping": {},
"targetOrder": [],
"targetElement": "EmbeddedPageController",
"targetAbility": "navigateRight"
}
]
},
"interruptAbilities": {
"trigger": false,
"setup": false,
"getTouchData": false,
"pressUp": false,
"pressDown": false,
"pressLeft": false,
"pressRight": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
},
{
"name": "setup",
"triggers": []
},
{
"name": "getTouchData",
"triggers": [
"touchDataRead"
]
},
{
"name": "pressUp",
"triggers": [
"upPressed",
"touchDataRead"
]
},
{
"name": "pressDown",
"triggers": [
"downPressed",
"touchDataRead"
]
},
{
"name": "pressLeft",
"triggers": [
"leftPressed",
"touchDataRead"
]
},
{
"name": "pressRight",
"triggers": [
"rightPressed",
"touchDataRead"
]
}
]
},
{
"name": "Temperature_P",
"type": "EmbeddedIconLabelDisplay",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables",
"rpk"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"displayPage": "\n\tATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Temperature_P, x), ATMO_PROPERTY(Temperature_P, y), false);\n\treturn ATMO_Status_Success;\n\t",
"onDisplayed": "\n\treturn ATMO_Status_Success;\n ",
"topRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"topLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"setup": "\n ATMO_UI_PAGE_Config_t config;\n\tconfig.hidden = ATMO_PROPERTY(Temperature_P, pageHidden);\n\tconfig.textColor = ATMO_PROPERTY(Temperature_P, textColor);\n config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Temperature_P, topRightButtonEnabled),\n ATMO_PROPERTY(Temperature_P,bottomRightButtonEnabled), ATMO_PROPERTY(Temperature_P, topLeftButtonEnabled), ATMO_PROPERTY(Temperature_P, bottomLeftButtonEnabled));\n\tconfig.x = ATMO_PROPERTY(Temperature_P, x);\n config.x = ATMO_PROPERTY(Temperature_P, x);\n config.y = ATMO_PROPERTY(Temperature_P, y);\n\tstrncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Temperature_P, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.topRightButtonLabel, ATMO_PROPERTY(Temperature_P, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Temperature_P, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Temperature_P, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n config.spanX = ATMO_PROPERTY(Temperature_P, spanX);\n\tconfig.spanY = ATMO_PROPERTY(Temperature_P, spanY);\n config.title = ATMO_PROPERTY(Temperature_P, pageTitle);\n config.titleHidden = ATMO_PROPERTY(Temperature_P, titleHidden);\n\tATMO_UI_SINGLEICONTEXT_Init(&config);\n\tATMO_VARIABLE(Temperature_P, pageHandle) = config.templateInstance;\n ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Temperature_P, label));\n ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Temperature_P, icon));\n ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), ATMO_ABILITY(Temperature_P, onDisplayed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 1, ATMO_ABILITY(Temperature_P, topRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 2, ATMO_ABILITY(Temperature_P, bottomRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 3, ATMO_ABILITY(Temperature_P, topLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 4, ATMO_ABILITY(Temperature_P, bottomLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Temperature_P, onLeave));\n\treturn ATMO_Status_Success;\n ",
"onLeave": "\n\treturn ATMO_Status_Success;\n\t",
"setLabel": "\n char label[32];\n if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n {\n ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Temperature_P,pageHandle), label);\n }\n else\n {\n return ATMO_Status_Fail;\n }\n\n return ATMO_Status_Success;\n "
},
"variables": {
"pageHandle": {
"type": "ATMO_DriverInstanceHandle_t"
}
},
"embeddedPropertyConversions": {
"pageTitle": "string",
"topRightButtonLabel": "string",
"bottomRightButtonLabel": "string",
"topLeftButtonLabel": "string",
"bottomLeftButtonLabel": "string",
"label": "string"
},
"codeUserChanged": {
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"textColor": "GUI_BLACK",
"pageTitle": "Temperature",
"titleHidden": false,
"pageHidden": false,
"topRightButtonLabel": "",
"topRightButtonEnabled": false,
"bottomRightButtonLabel": "",
"bottomRightButtonEnabled": false,
"topLeftButtonLabel": "",
"topLeftButtonEnabled": false,
"bottomLeftButtonLabel": "",
"bottomLeftButtonEnabled": false,
"x": 0,
"y": 0,
"spanX": 1,
"spanY": 1,
"icon": "icon_applications_thermostat",
"label": "N/A"
},
"meta": {
"editorX": 639.33349609375,
"editorY": 5,
"lastTrigger": "onDisplayed"
},
"triggers": {
"triggered": [],
"onDisplayed": [],
"topRightButtonPressed": [],
"bottomRightButtonPressed": [],
"topLeftButtonPressed": [],
"bottomLeftButtonPressed": [],
"onLeave": []
},
"interruptAbilities": {
"trigger": false,
"displayPage": false,
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
},
{
"name": "displayPage",
"triggers": []
},
{
"name": "onDisplayed",
"triggers": [
"onDisplayed"
]
},
{
"name": "topRightButtonPressed",
"triggers": [
"topRightButtonPressed"
]
},
{
"name": "bottomRightButtonPressed",
"triggers": [
"bottomRightButtonPressed"
]
},
{
"name": "topLeftButtonPressed",
"triggers": [
"topLeftButtonPressed"
]
},
{
"name": "bottomLeftButtonPressed",
"triggers": [
"bottomLeftButtonPressed"
]
},
{
"name": "setup",
"triggers": []
},
{
"name": "onLeave",
"triggers": [
"onLeave"
]
},
{
"name": "setLabel",
"triggers": []
}
]
},
{
"name": "EmbeddedPageController",
"type": "EmbeddedPageController",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables",
"rpk"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"setup": "\n\tATMO_UI_PAGE_CONTROLLER_Config_t config;\n\tconfig.enableUpDownNavLabels = ATMO_PROPERTY(EmbeddedPageController, upDownNavigationLabelsEnabled);\n\tconfig.enableLeftRightNavLabels = ATMO_PROPERTY(EmbeddedPageController, leftRightNavigationLabelsEnabled);\n\tATMO_UI_Page_SetConfiguration(&config);\n return ATMO_Status_Success;\n\t",
"displayRootPage": "\n\t\n\tATMO_UI_Page_DisplayRootPage();\n\treturn ATMO_Status_Success;\n\t",
"navigateUp": "\n\tATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_UP);\n\treturn ATMO_Status_Success;\n\t",
"navigateDown": "\n\tATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_DOWN);\n\treturn ATMO_Status_Success;\n\t",
"navigateLeft": "\n\tATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_LEFT);\n\treturn ATMO_Status_Success;\n\t",
"navigateRight": "\n\tATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_RIGHT);\n\treturn ATMO_Status_Success;\n\t",
"processTopRightButton": "\n\tATMO_UI_Page_ProcessUserButton(1);\n\treturn ATMO_Status_Success;\n\t",
"processBottomRightButton": "\n\tATMO_UI_Page_ProcessUserButton(2);\n\treturn ATMO_Status_Success;\n\t",
"processTopLeftButton": "\n\tATMO_UI_Page_ProcessUserButton(3);\n\treturn ATMO_Status_Success;\n\t",
"processBottomLeftButton": "\n\tATMO_UI_Page_ProcessUserButton(4);\n\treturn ATMO_Status_Success;\n\t"
},
"variables": {},
"embeddedPropertyConversions": {},
"codeUserChanged": {
"setup": false,
"displayRootPage": false,
"navigateUp": false,
"navigateDown": false,
"navigateLeft": false,
"navigateRight": false,
"processTopRightButton": false,
"processBottomRightButton": false,
"processTopLeftButton": false,
"processBottomLeftButton": false
},
"upDownNavigationLabelsEnabled": true,
"leftRightNavigationLabelsEnabled": true
},
"meta": {
"editorX": 1222.33349609375,
"editorY": 29,
"lastTrigger": "triggered"
},
"triggers": {
"triggered": [],
"navigateUp": [],
"navigateDown": [],
"navigateLeft": [],
"navigateRight": [],
"processTopRightButton": [],
"processBottomRightButton": [],
"processTopLeftButton": [],
"processBottomLeftButton": []
},
"interruptAbilities": {
"trigger": false,
"setup": false,
"displayRootPage": false,
"navigateUp": false,
"navigateDown": false,
"navigateLeft": false,
"navigateRight": false,
"processTopRightButton": false,
"processBottomRightButton": false,
"processTopLeftButton": false,
"processBottomLeftButton": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
},
{
"name": "setup",
"triggers": []
},
{
"name": "displayRootPage",
"triggers": []
},
{
"name": "navigateUp",
"triggers": [
"navigateUp"
]
},
{
"name": "navigateDown",
"triggers": [
"navigateDown"
]
},
{
"name": "navigateLeft",
"triggers": [
"navigateLeft"
]
},
{
"name": "navigateRight",
"triggers": [
"navigateRight"
]
},
{
"name": "processTopRightButton",
"triggers": [
"processTopRightButton"
]
},
{
"name": "processBottomRightButton",
"triggers": [
"processBottomRightButton"
]
},
{
"name": "processTopLeftButton",
"triggers": [
"processTopLeftButton"
]
},
{
"name": "processBottomLeftButton",
"triggers": [
"processBottomLeftButton"
]
}
]
},
{
"name": "Humidity_Pag",
"type": "EmbeddedIconLabelDisplay",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables",
"rpk"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"displayPage": "\n\tATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Humidity_Pag, x), ATMO_PROPERTY(Humidity_Pag, y), false);\n\treturn ATMO_Status_Success;\n\t",
"onDisplayed": "\n\treturn ATMO_Status_Success;\n ",
"topRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"topLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"setup": "\n ATMO_UI_PAGE_Config_t config;\n\tconfig.hidden = ATMO_PROPERTY(Humidity_Pag, pageHidden);\n\tconfig.textColor = ATMO_PROPERTY(Humidity_Pag, textColor);\n config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Humidity_Pag, topRightButtonEnabled),\n ATMO_PROPERTY(Humidity_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(Humidity_Pag, topLeftButtonEnabled), ATMO_PROPERTY(Humidity_Pag, bottomLeftButtonEnabled));\n\tconfig.x = ATMO_PROPERTY(Humidity_Pag, x);\n config.x = ATMO_PROPERTY(Humidity_Pag, x);\n config.y = ATMO_PROPERTY(Humidity_Pag, y);\n\tstrncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Humidity_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.topRightButtonLabel, ATMO_PROPERTY(Humidity_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Humidity_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Humidity_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n config.spanX = ATMO_PROPERTY(Humidity_Pag, spanX);\n\tconfig.spanY = ATMO_PROPERTY(Humidity_Pag, spanY);\n config.title = ATMO_PROPERTY(Humidity_Pag, pageTitle);\n config.titleHidden = ATMO_PROPERTY(Humidity_Pag, titleHidden);\n\tATMO_UI_SINGLEICONTEXT_Init(&config);\n\tATMO_VARIABLE(Humidity_Pag, pageHandle) = config.templateInstance;\n ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Humidity_Pag, label));\n ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Humidity_Pag, icon));\n ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), ATMO_ABILITY(Humidity_Pag, onDisplayed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 1, ATMO_ABILITY(Humidity_Pag, topRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 2, ATMO_ABILITY(Humidity_Pag, bottomRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 3, ATMO_ABILITY(Humidity_Pag, topLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 4, ATMO_ABILITY(Humidity_Pag, bottomLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Humidity_Pag, onLeave));\n\treturn ATMO_Status_Success;\n ",
"onLeave": "\n\treturn ATMO_Status_Success;\n\t",
"setLabel": "\n char label[32];\n if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n {\n ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Humidity_Pag,pageHandle), label);\n }\n else\n {\n return ATMO_Status_Fail;\n }\n\n return ATMO_Status_Success;\n "
},
"variables": {
"pageHandle": {
"type": "ATMO_DriverInstanceHandle_t"
}
},
"embeddedPropertyConversions": {
"pageTitle": "string",
"topRightButtonLabel": "string",
"bottomRightButtonLabel": "string",
"topLeftButtonLabel": "string",
"bottomLeftButtonLabel": "string",
"label": "string"
},
"codeUserChanged": {
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"textColor": "GUI_BLACK",
"pageTitle": "Humidity",
"titleHidden": false,
"pageHidden": false,
"topRightButtonLabel": "",
"topRightButtonEnabled": false,
"bottomRightButtonLabel": "",
"bottomRightButtonEnabled": false,
"topLeftButtonLabel": "",
"topLeftButtonEnabled": false,
"bottomLeftButtonLabel": "",
"bottomLeftButtonEnabled": false,
"x": "1",
"y": 0,
"spanX": 1,
"spanY": 1,
"icon": "icon_applications_humidity",
"label": "N/A"
},
"meta": {
"editorX": 707.33349609375,
"editorY": 5,
"lastTrigger": "onDisplayed"
},
"triggers": {
"triggered": [],
"onDisplayed": [],
"topRightButtonPressed": [],
"bottomRightButtonPressed": [],
"topLeftButtonPressed": [],
"bottomLeftButtonPressed": [],
"onLeave": []
},
"interruptAbilities": {
"trigger": false,
"displayPage": false,
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
},
{
"name": "displayPage",
"triggers": []
},
{
"name": "onDisplayed",
"triggers": [
"onDisplayed"
]
},
{
"name": "topRightButtonPressed",
"triggers": [
"topRightButtonPressed"
]
},
{
"name": "bottomRightButtonPressed",
"triggers": [
"bottomRightButtonPressed"
]
},
{
"name": "topLeftButtonPressed",
"triggers": [
"topLeftButtonPressed"
]
},
{
"name": "bottomLeftButtonPressed",
"triggers": [
"bottomLeftButtonPressed"
]
},
{
"name": "setup",
"triggers": []
},
{
"name": "onLeave",
"triggers": [
"onLeave"
]
},
{
"name": "setLabel",
"triggers": []
}
]
},
{
"name": "Pressure_Pag",
"type": "EmbeddedIconLabelDisplay",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables",
"rpk"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"displayPage": "\n\tATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Pressure_Pag, x), ATMO_PROPERTY(Pressure_Pag, y), false);\n\treturn ATMO_Status_Success;\n\t",
"onDisplayed": "\n\treturn ATMO_Status_Success;\n ",
"topRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"topLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"setup": "\n ATMO_UI_PAGE_Config_t config;\n\tconfig.hidden = ATMO_PROPERTY(Pressure_Pag, pageHidden);\n\tconfig.textColor = ATMO_PROPERTY(Pressure_Pag, textColor);\n config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Pressure_Pag, topRightButtonEnabled),\n ATMO_PROPERTY(Pressure_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(Pressure_Pag, topLeftButtonEnabled), ATMO_PROPERTY(Pressure_Pag, bottomLeftButtonEnabled));\n\tconfig.x = ATMO_PROPERTY(Pressure_Pag, x);\n config.x = ATMO_PROPERTY(Pressure_Pag, x);\n config.y = ATMO_PROPERTY(Pressure_Pag, y);\n\tstrncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Pressure_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.topRightButtonLabel, ATMO_PROPERTY(Pressure_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Pressure_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Pressure_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n config.spanX = ATMO_PROPERTY(Pressure_Pag, spanX);\n\tconfig.spanY = ATMO_PROPERTY(Pressure_Pag, spanY);\n config.title = ATMO_PROPERTY(Pressure_Pag, pageTitle);\n config.titleHidden = ATMO_PROPERTY(Pressure_Pag, titleHidden);\n\tATMO_UI_SINGLEICONTEXT_Init(&config);\n\tATMO_VARIABLE(Pressure_Pag, pageHandle) = config.templateInstance;\n ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Pressure_Pag, label));\n ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Pressure_Pag, icon));\n ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), ATMO_ABILITY(Pressure_Pag, onDisplayed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 1, ATMO_ABILITY(Pressure_Pag, topRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 2, ATMO_ABILITY(Pressure_Pag, bottomRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 3, ATMO_ABILITY(Pressure_Pag, topLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 4, ATMO_ABILITY(Pressure_Pag, bottomLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Pressure_Pag, onLeave));\n\treturn ATMO_Status_Success;\n ",
"onLeave": "\n\treturn ATMO_Status_Success;\n\t",
"setLabel": "\n char label[32];\n if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n {\n ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Pressure_Pag,pageHandle), label);\n }\n else\n {\n return ATMO_Status_Fail;\n }\n\n return ATMO_Status_Success;\n "
},
"variables": {
"pageHandle": {
"type": "ATMO_DriverInstanceHandle_t"
}
},
"embeddedPropertyConversions": {
"pageTitle": "string",
"topRightButtonLabel": "string",
"bottomRightButtonLabel": "string",
"topLeftButtonLabel": "string",
"bottomLeftButtonLabel": "string",
"label": "string"
},
"codeUserChanged": {
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"textColor": "GUI_BLACK",
"pageTitle": "Pressure",
"titleHidden": false,
"pageHidden": false,
"topRightButtonLabel": "",
"topRightButtonEnabled": false,
"bottomRightButtonLabel": "",
"bottomRightButtonEnabled": false,
"topLeftButtonLabel": "",
"topLeftButtonEnabled": false,
"bottomLeftButtonLabel": "",
"bottomLeftButtonEnabled": false,
"x": "2",
"y": 0,
"spanX": 1,
"spanY": 1,
"icon": "icon_applications_pressure",
"label": "N/A"
},
"meta": {
"editorX": 765.3333740234375,
"editorY": 11,
"lastTrigger": "onDisplayed"
},
"triggers": {
"triggered": [],
"onDisplayed": [],
"topRightButtonPressed": [],
"bottomRightButtonPressed": [],
"topLeftButtonPressed": [],
"bottomLeftButtonPressed": [],
"onLeave": []
},
"interruptAbilities": {
"trigger": false,
"displayPage": false,
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
},
{
"name": "displayPage",
"triggers": []
},
{
"name": "onDisplayed",
"triggers": [
"onDisplayed"
]
},
{
"name": "topRightButtonPressed",
"triggers": [
"topRightButtonPressed"
]
},
{
"name": "bottomRightButtonPressed",
"triggers": [
"bottomRightButtonPressed"
]
},
{
"name": "topLeftButtonPressed",
"triggers": [
"topLeftButtonPressed"
]
},
{
"name": "bottomLeftButtonPressed",
"triggers": [
"bottomLeftButtonPressed"
]
},
{
"name": "setup",
"triggers": []
},
{
"name": "onLeave",
"triggers": [
"onLeave"
]
},
{
"name": "setLabel",
"triggers": []
}
]
},
{
"name": "ConvertPressur",
"type": "EmbeddedFunction",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\tunsigned int pressurePa = 0;\n\tATMO_GetUnsignedInt(in, &pressurePa);\n\tATMO_CreateValueUnsignedInt(out, pressurePa / 100);\n\treturn ATMO_Status_Success;"
},
"variables": {},
"embeddedPropertyConversions": {},
"codeUserChanged": {
"trigger": true
}
},
"meta": {
"editorX": 375.3333740234375,
"editorY": 206,
"lastTrigger": "triggered"
},
"triggers": {
"triggered": [
{
"mapping": {},
"targetOrder": [],
"targetElement": "GetPressureStr",
"targetAbility": "trigger"
}
]
},
"interruptAbilities": {
"trigger": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
}
]
},
{
"name": "AmientLight_Pag",
"type": "EmbeddedIconLabelDisplay",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables",
"rpk"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"displayPage": "\n\tATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(AmientLight_Pag, x), ATMO_PROPERTY(AmientLight_Pag, y), false);\n\treturn ATMO_Status_Success;\n\t",
"onDisplayed": "\n\treturn ATMO_Status_Success;\n ",
"topRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"topLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"setup": "\n ATMO_UI_PAGE_Config_t config;\n\tconfig.hidden = ATMO_PROPERTY(AmientLight_Pag, pageHidden);\n\tconfig.textColor = ATMO_PROPERTY(AmientLight_Pag, textColor);\n config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(AmientLight_Pag, topRightButtonEnabled),\n ATMO_PROPERTY(AmientLight_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(AmientLight_Pag, topLeftButtonEnabled), ATMO_PROPERTY(AmientLight_Pag, bottomLeftButtonEnabled));\n\tconfig.x = ATMO_PROPERTY(AmientLight_Pag, x);\n config.x = ATMO_PROPERTY(AmientLight_Pag, x);\n config.y = ATMO_PROPERTY(AmientLight_Pag, y);\n\tstrncpy(config.topLeftButtonLabel, ATMO_PROPERTY(AmientLight_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.topRightButtonLabel, ATMO_PROPERTY(AmientLight_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(AmientLight_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(AmientLight_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n config.spanX = ATMO_PROPERTY(AmientLight_Pag, spanX);\n\tconfig.spanY = ATMO_PROPERTY(AmientLight_Pag, spanY);\n config.title = ATMO_PROPERTY(AmientLight_Pag, pageTitle);\n config.titleHidden = ATMO_PROPERTY(AmientLight_Pag, titleHidden);\n\tATMO_UI_SINGLEICONTEXT_Init(&config);\n\tATMO_VARIABLE(AmientLight_Pag, pageHandle) = config.templateInstance;\n ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(AmientLight_Pag, label));\n ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(AmientLight_Pag, icon));\n ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), ATMO_ABILITY(AmientLight_Pag, onDisplayed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 1, ATMO_ABILITY(AmientLight_Pag, topRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 2, ATMO_ABILITY(AmientLight_Pag, bottomRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 3, ATMO_ABILITY(AmientLight_Pag, topLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 4, ATMO_ABILITY(AmientLight_Pag, bottomLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(AmientLight_Pag, onLeave));\n\treturn ATMO_Status_Success;\n ",
"onLeave": "\n\treturn ATMO_Status_Success;\n\t",
"setLabel": "\n char label[32];\n if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n {\n ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(AmientLight_Pag,pageHandle), label);\n }\n else\n {\n return ATMO_Status_Fail;\n }\n\n return ATMO_Status_Success;\n "
},
"variables": {
"pageHandle": {
"type": "ATMO_DriverInstanceHandle_t"
}
},
"embeddedPropertyConversions": {
"pageTitle": "string",
"topRightButtonLabel": "string",
"bottomRightButtonLabel": "string",
"topLeftButtonLabel": "string",
"bottomLeftButtonLabel": "string",
"label": "string"
},
"codeUserChanged": {
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"textColor": "GUI_BLACK",
"pageTitle": "Ambient Light",
"titleHidden": false,
"pageHidden": false,
"topRightButtonLabel": "",
"topRightButtonEnabled": false,
"bottomRightButtonLabel": "",
"bottomRightButtonEnabled": false,
"topLeftButtonLabel": "",
"topLeftButtonEnabled": false,
"bottomLeftButtonLabel": "",
"bottomLeftButtonEnabled": false,
"x": "3",
"y": 0,
"spanX": 1,
"spanY": 1,
"icon": "icon_applications_light",
"label": "N/A"
},
"meta": {
"editorX": 839.3333740234375,
"editorY": 10,
"lastTrigger": "onDisplayed"
},
"triggers": {
"triggered": [],
"onDisplayed": [],
"topRightButtonPressed": [],
"bottomRightButtonPressed": [],
"topLeftButtonPressed": [],
"bottomLeftButtonPressed": [],
"onLeave": []
},
"interruptAbilities": {
"trigger": false,
"displayPage": false,
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"abilities": [
{
"name": "trigger",
"triggers": [
"triggered"
]
},
{
"name": "displayPage",
"triggers": []
},
{
"name": "onDisplayed",
"triggers": [
"onDisplayed"
]
},
{
"name": "topRightButtonPressed",
"triggers": [
"topRightButtonPressed"
]
},
{
"name": "bottomRightButtonPressed",
"triggers": [
"bottomRightButtonPressed"
]
},
{
"name": "topLeftButtonPressed",
"triggers": [
"topLeftButtonPressed"
]
},
{
"name": "bottomLeftButtonPressed",
"triggers": [
"bottomLeftButtonPressed"
]
},
{
"name": "setup",
"triggers": []
},
{
"name": "onLeave",
"triggers": [
"onLeave"
]
},
{
"name": "setLabel",
"triggers": []
}
]
},
{
"name": "AirQuality_Pag",
"type": "EmbeddedIconLabelDisplay",
"variants": [
"embedded",
"triggers",
"abilities",
"properties",
"variables",
"rpk"
],
"properties": {
"errorData": {},
"code": {
"trigger": "\treturn ATMO_Status_Success;",
"displayPage": "\n\tATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(AirQuality_Pag, x), ATMO_PROPERTY(AirQuality_Pag, y), false);\n\treturn ATMO_Status_Success;\n\t",
"onDisplayed": "\n\treturn ATMO_Status_Success;\n ",
"topRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"topLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"bottomLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
"setup": "\n ATMO_UI_PAGE_Config_t config;\n\tconfig.hidden = ATMO_PROPERTY(AirQuality_Pag, pageHidden);\n\tconfig.textColor = ATMO_PROPERTY(AirQuality_Pag, textColor);\n config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(AirQuality_Pag, topRightButtonEnabled),\n ATMO_PROPERTY(AirQuality_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(AirQuality_Pag, topLeftButtonEnabled), ATMO_PROPERTY(AirQuality_Pag, bottomLeftButtonEnabled));\n\tconfig.x = ATMO_PROPERTY(AirQuality_Pag, x);\n config.x = ATMO_PROPERTY(AirQuality_Pag, x);\n config.y = ATMO_PROPERTY(AirQuality_Pag, y);\n\tstrncpy(config.topLeftButtonLabel, ATMO_PROPERTY(AirQuality_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.topRightButtonLabel, ATMO_PROPERTY(AirQuality_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(AirQuality_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(AirQuality_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n config.spanX = ATMO_PROPERTY(AirQuality_Pag, spanX);\n\tconfig.spanY = ATMO_PROPERTY(AirQuality_Pag, spanY);\n config.title = ATMO_PROPERTY(AirQuality_Pag, pageTitle);\n config.titleHidden = ATMO_PROPERTY(AirQuality_Pag, titleHidden);\n\tATMO_UI_SINGLEICONTEXT_Init(&config);\n\tATMO_VARIABLE(AirQuality_Pag, pageHandle) = config.templateInstance;\n ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(AirQuality_Pag, label));\n ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(AirQuality_Pag, icon));\n ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(AirQuality_Pag,pageHandle), ATMO_ABILITY(AirQuality_Pag, onDisplayed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AirQuality_Pag,pageHandle), 1, ATMO_ABILITY(AirQuality_Pag, topRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AirQuality_Pag,pageHandle), 2, ATMO_ABILITY(AirQuality_Pag, bottomRightButtonPressed));\n\tATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AirQuality_Pag,pageHandle), 3, ATMO_ABILITY(AirQuality_Pag, topLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AirQuality_Pag,pageHandle), 4, ATMO_ABILITY(AirQuality_Pag, bottomLeftButtonPressed));\n ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(AirQuality_Pag, onLeave));\n\treturn ATMO_Status_Success;\n ",
"onLeave": "\n\treturn ATMO_Status_Success;\n\t",
"setLabel": "\n char label[32];\n if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n {\n ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(AirQuality_Pag,pageHandle), label);\n }\n else\n {\n return ATMO_Status_Fail;\n }\n\n return ATMO_Status_Success;\n "
},
"variables": {
"pageHandle": {
"type": "ATMO_DriverInstanceHandle_t"
}
},
"embeddedPropertyConversions": {
"pageTitle": "string",
"topRightButtonLabel": "string",
"bottomRightButtonLabel": "string",
"topLeftButtonLabel": "string",
"bottomLeftButtonLabel": "string",
"label": "string"
},
"codeUserChanged": {
"onDisplayed": false,
"topRightButtonPressed": false,
"bottomRightButtonPressed": false,
"topLeftButtonPressed": false,
"bottomLeftButtonPressed": false,
"setup": false,
"onLeave": false,
"setLabel": false
},
"textColor": "GUI_BLACK",
"pageTitle": "Air TVOC",
"titleHidden": false,
"pageHidden": false,
"topRightButtonLabel": "",
"topRightButtonEnabled": false,
"bottomRightButtonLabel": "",
"bottomRightButtonEnabled": false,
"topLeftButtonLabel": "",
"topLeftButtonEnabled": false,
"bottomLeftButtonLabel": "",
"bottomLeftButtonEnabled": false,
"x": "5",
"y": 0,
...
This file has been truncated, please download it to see its full contents.
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run this code first to install the mqtt and pushetta libraries.\n",
"!pip install paho-mqtt && pip install pushetta"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Leave this code running to leave pushetta notifications active.\n",
"\n",
"import paho.mqtt.client as mqtt \n",
"import time\n",
"from pushetta import Pushetta\n",
"\n",
"# API Key You get after signup on www.pushetta.com\n",
"API_KEY=\"YOURPUSHETTAAPIKEY\"\n",
"p=Pushetta(API_KEY)\n",
"\n",
"def on_message(mosq, obj, msg):\n",
" p.pushMessage(\"NXP\",\"YOURNAME Needs Help!: \" \"https://maps.google.com/?q=\" + str(msg.payload.decode())[10:-21]+\",\"+str(msg.payload.decode())[-8:])\n",
"\n",
"\n",
"client = mqtt.Client()\n",
"client.on_message = on_message\n",
"client.username_pw_set(\"MQTTUSERNAME\", \"MQTTPASSWORD\")\n",
"client.connect('MQTTURL', MQTTPORT, 60)\n",
"client.loop_start()\n",
"client.subscribe (\"/NXPloc\" ,0 )\n",
"\n",
"try:\n",
" while True:\n",
" time.sleep(1)\n",
" \n",
"except KeyboardInterrupt:\n",
" print (\"exiting\")\n",
" client.disconnect()\n",
" client.loop_stop()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.5",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>
<script type="text/javascript">
// Create a client instance
client = new Paho.MQTT.Client("MQTTURL", MQTTPORT,"MQTTDEVICENAME");
//Example client = new Paho.MQTT.Client("m11.cloudmqtt.com", 32903, "web_" + parseInt(Math.random() * 100, 10));
// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
var options = {
useSSL: true,
userName: "MQTTUSERNAME",
password: "MQTTPASSWORD",
onSuccess:onConnect,
onFailure:doFail
}
// connect the client
client.connect(options);
// called when the client connects
function onConnect() {
var data
// Once a connection has been made, make a subscription and send a message.
console.log("onConnect");
$.ajax({
dataType: "json",
url: "http://extreme-ip-lookup.com/json/",
data: data,
success: function (data)
{
var datav = JSON.parse(JSON.stringify(data))
doStuff(datav.lat, datav.lon)
message = new Paho.MQTT.Message("Latitude: "+String(datav.lat) + ", Longitude: "+String(datav.lon));
message.destinationName = "/NXPloc";
client.send(message);
}
});
}
function doFail(e){
console.log(e);
}
// called when the client loses its connection
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
}
// called when a message arrives
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
}
</script>
<script>
function doStuff(mylat, mylong)
{
if (document.getElementById("GeoAPI"))
{
document.getElementById("GeoAPI").innerHTML = "<iframe style=\"width: 400px; height: 400px\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"//maps.google.com/?ll=" + mylat + "," + mylong + "&z=16&output=embed\"></iframe>";
}
}
</script>
</head>
<body>
<div id="GeoAPI"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url("NXP.png");
background-repeat: no-repeat;
background-size: 1500px 800px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>
<script type="text/javascript">
// Create a client instance
client = new Paho.MQTT.Client("MQTTURL", MQTTPORT,"MQTTDEVICENAME");
//Example client = new Paho.MQTT.Client("m11.cloudmqtt.com", 32903, "web_" + parseInt(Math.random() * 100, 10));
// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
var options = {
useSSL: true,
userName: "MQTTUSERNAME",
password: "MQTTPASSWORD",
onSuccess:onConnect,
onFailure:doFail
}
// connect the client
client.connect(options);
// called when the client connects
function onConnect() {
// Once a connection has been made, make a subscription and send a message.
console.log("onConnect");
client.subscribe("/NXPloc");
}
function doFail(e){
console.log(e);
}
// called when the client loses its connection
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
}
// called when a message arrives
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
var text = message.payloadString
var lati = parseFloat(text.substring(10, 18))
var long = parseFloat(text.substring(30, 40))
alert("Victor needs help!");
doStuff(lati, long)
}
</script>
<script>
function doStuff(mylat, mylong)
{
var map = new google.maps.Map(document.getElementById('GeoAPI'),
{
center: {lat: mylat, lng: mylong},
zoom: 20
});
var marker = new google.maps.Marker({
position: {lat: mylat, lng: mylong},
map: map,
title: 'YOURNAME'
});
}
</script>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#GeoAPI {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="GeoAPI"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API&callback=initMap" async defer></script>
</body>
</html>
Comments