Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
| ||||||
| ||||||
|
The changes in climate led to the increased importance of environmental monitoring. In order to determine the quality of the environment, continuous tracking of the environmental parameter is needed. As the IoT and Voice Interface are the most emerging technology, it plays an important role in collecting the information from the sensing unit.
Leveraging these two rapid growing technology I made a weather station and environmental monitoring device and you can be informed about any parameter like temperature, humidity, air quality, air pressure and light intensity by asking Alexa at any time. You can also monitor the parameters from mobile apps as well as web dashboard.
NXP Rapid IoT Prototyping Kit provides all the necessary environmental data to Alexa and Alexa speak it for you. Thanks to NXP and Hackster for providing this nice kit. Before going further watch the demo video.
How it Works1. Internal sensors of Rapid IoT Prototyping Kit sense necessary environmental parameters and the built-in microcontroller process the data.
2. The kit becomes connected to smart phone using BLE (Bluetooth Low Energy) and a dedicated mobile app receives the sensor data and uploads to the DynamoDB cloud once in a minute. The phone app also display the data to the screen.
3. A custom Alexa Skill is used to speak the information from DynamoDB according to user's voice command. A lambda function was made to provide the data to Alexa after reading from DynamoDB and the function is triggered when the Alexa Skill is launched.
How you can make itStep 1: Developing the firmware for Rapid IoT Kit using Rapid IoT Studio
i. Go to https://rapid-iot-studio.nxp.com and log in using the credentials if you have an account. Otherwise create the account first.
ii. From the given example open Rapid IoT Weather Station project and go to the CLOUD tab. You have nothing to do with NXP RAPID IOT and APPLICATION tab.
iii. From the CLOUD tab add two AWS DynamoDB Element with every Cloud Event Element as shown in the partial image below.
You can also directly import the project I attached in the Code section.
iv. After adding AWS DynamoDB Element you need to configure the element with your own value. Before configuring AWS DynamoDB Element you will be required to create a DynamoDB table first from AWS Console. Before creating a DynamoDB table you need to create a new IAM Role to allow Atmosphere to communicate with your AWS DynamoDB table. Follow the AWS Integration Setup Guide https://developer.atmosphereiot.com/documents/guides/awsintegrationsetupguide.html to configure your AWS Service. Add the created role to the DynamoDB table you created for this project.
v. For easily accessing the sensor parameters from DynamoDB I want to keep only the last sensor value in the table. For this reason I deleted the previous value first and then uploaded the new value to the DynamoDB table. For this reason I have connected two AWS DynamoDB Element to every Cloud Event Element. I set first DynamoDB Element to delete the previous element and second DynamoDB Element to upload the new element (new sensor value) to the table like as following image.
The following figure shows the configuration of cloud element for AWS DynamoDB. You need to fill all the parameters e.g. REGION, EXTERNAL ID, ROLE ARN and TABLE NAME. You will get all the parameters at the time of configuring AWS console.
If you configured all the element you need to build the project. After successfully building you should upload the firmware to the device. If everything goes well Rapid IoT Kit will start with the app. Connect the device to the smartphone using Rapid IoT Mobile App (https://www.nxp.com/support/developer-resources/rapid-prototyping/nxp-rapid-iot-prototyping-kit:IOT-PROTOTYPING?tab=Design_Tools_Tab). The sensor data will be displayed on the screen and uploaded automatically to the DynamoDB table and your table should like following:
Step 2: Creating a Lambda Function
Now you need to create a Lambda function. Again you need to create a role for Lambda function for giving access to the DynamoDB. Next, select Alexa Skills Kit from Add triggers option. Keep the Skill ID field disable for this moment. We will came back to here again. After creating your Lambda function should look like following. If you never create a Lambda function before take a look to https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/lambda-tutorial.html and https://medium.freecodecamp.org/aws-lambda-offering-developers-ultimate-flexibility-d8939ff4220.
Step 3: Creating a custom Alexa Skill
For accessing the sensor data from Alexa you need to create a custom Alexa Skill. Go to https://developer.amazon.com/alexa-skills-kit and start with a new skill. From the JSON Editor you can directly upload the JSON file attached in code section for creating the skill or you may use GUI.
If you are new in creating custom Alexa Skill you can get some idea from the following link: https://developer.amazon.com/docs/custom-skills/steps-to-build-a-custom-skill.html and https://medium.com/crowdbotics/how-to-build-a-custom-amazon-alexa-skill-step-by-step-my-favorite-chess-player-dcc0edae53fb.
After creating the skill note the skill ID and paste it to the Skill ID box in the Lambda function.
Step 4: Uploading/Writing Code for Lambda Function
I hope you already created a lambda function. Go to inline code editor in Lambda and paste the python code attached in the code section named as Lambda Function. If it is OK you are ready to go.
Step 5: Connecting Rapid IoT Kit with Mobile Apps
We have completed all the necessary steps required to make the project. Now we will test our system. Power up the Rapid IoT Kit. Log in to atmosphare mobile app from your mobile phone using NXP account. Search for the new devise. You should get a new device named as your project name. Select it and click to provison. After successfully connecting you will get the data to your app. If your smart phone has internet connection the data will be automatically uploaded to DynamoDB.
From the DynamoDB table you can see your data. Is data is uploading successfully?
Congratulation! You made it!! Ask Alexa and Enjoy!!!
"""
This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit.
The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well
as testing instructions are located at http://amzn.to/1LzFrj6
For additional samples, visit the Alexa Skills Kit Getting Started guide at
http://amzn.to/1LGWsLG
"""
from __future__ import print_function
import xml.etree.ElementTree as etree
from datetime import datetime as dt
import boto3
import io
import time
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('temp')
def read_table_item(table_name, pk_name, pk_value):
"""
Return item read by primary key.
"""
table = dynamodb.Table(table_name)
response = table.get_item(Key={pk_name: pk_value})
if 'Item' in response:
value = response['Item']['value']
#print (value)
return value
def lambda_handler(event, context):
""" Route the incoming request based on type (LaunchRequest, IntentRequest,
etc.) The JSON body of the request is provided in the event parameter.
"""
#print("event.session.application.applicationId=" +
# event['session']['application']['applicationId'])
"""
Uncomment this if statement and populate with your skill's application ID to
prevent someone else from configuring a skill that sends requests to this
function.
"""
# if (event['session']['application']['applicationId'] !=
# "amzn1.echo-sdk-ams.app.[unique-value-here]"):
# raise ValueError("Invalid Application ID")
if event['session']['new']:
on_session_started({'requestId': event['request']['requestId']},
event['session'])
if event['request']['type'] == "LaunchRequest":
return on_launch(event['request'], event['session'])
elif event['request']['type'] == "IntentRequest":
return on_intent(event['request'], event['session'])
elif event['request']['type'] == "SessionEndedRequest":
return on_session_ended(event['request'], event['session'])
def on_session_started(session_started_request, session):
""" Called when the session starts """
print("on_session_started requestId=" + session_started_request['requestId']
+ ", sessionId=" + session['sessionId'])
def on_launch(launch_request, session):
""" Called when the user launches the skill without specifying what they
want
"""
print("on_launch requestId=" + launch_request['requestId'] +
", sessionId=" + session['sessionId'])
# Dispatch to your skill's launch
return get_welcome_response()
def on_intent(intent_request, session):
""" Called when the user specifies an intent for this skill """
print("on_intent requestId=" + intent_request['requestId'] +
", sessionId=" + session['sessionId'])
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
# Dispatch to your skill's intent handlers
if intent_name == "TemperatureSensorIntent":
return temperature_read(intent, session)
elif intent_name == "HumiditySensorIntent":
return humidity_read(intent, session)
elif intent_name == "LightSensorIntent":
return light_read(intent, session)
elif intent_name == "LightRequiredIntent":
return light_required(intent, session)
elif intent_name == "PressureSensorIntent":
return pressure_read(intent, session)
elif intent_name == "AirqualitySensorIntent":
return airquality_read(intent, session)
elif intent_name == "AllSensorIntent":
return all_sensor_read(intent, session)
elif intent_name == "AMAZON.HelpIntent":
return get_welcome_response()
elif intent_name == "AMAZON.StopIntent" or intent_name == "AMAZON.CancelIntent":
return session_end(intent, session)
else:
raise ValueError("Invalid intent")
def on_session_ended(session_ended_request, session):
""" Called when the user ends the session.
Is not called when the skill returns should_end_session=true
"""
print("on_session_ended requestId=" + session_ended_request['requestId'] +
", sessionId=" + session['sessionId'])
# add cleanup logic here
# --------------- Functions that control the skill's behavior ------------------
def get_welcome_response():
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
session_attributes = {}
card_title = "Welcome"
speech_output = "Welcome to the talking weather station. " \
"I know your room temperature, humidity, light intensity, air quality, air pressure. " \
" You can ask me about any parameter."
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = "Please ask me like, " \
"What is the temperature?"
should_end_session = False
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def temperature_read(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result = read_table_item("sensordata", "type", "temperature")
#temperature = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Reading Temperature"
speech_output = "The room temperature is {0:.2f} degree centigrade.".format(result)
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def humidity_read(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result = read_table_item("sensordata", "type", "humidity")
#humidity = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Reading Humidity"
speech_output = "The humidity is {0:.2f} percent.".format(result)
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def light_read(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result = read_table_item("sensordata", "type", "light")
#temperature = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Reading Light"
speech_output = "The light intensity in your room is %d Lumen per square meter." %(result)
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def pressure_read(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result = read_table_item("sensordata", "type", "pressure")
#temperature = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Reading Pressure"
speech_output = "The Atmospheric Pressure in your room is %d hectopascals." %(result)
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def light_required(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result = read_table_item("sensordata", "type", "light")
#temperature = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Calculating..."
if result < 240:
speech_output = "Your room illumination is not enough for reading. The recommended light level for reading is 250 to 300 lux, where you have only %d lux" %(result)
elif result >250 and result <=400:
speech_output = "Yes, your room illumination is good for reading and normal office work."
elif result >700:
speech_output = "Your room illumination is more than enough."
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def airquality_read(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result = read_table_item("sensordata", "type", "airquality")
#temperature = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Reading TVOC"
if result <= 50:
speech_output = "Total Volatile Organic Compounds in your room air is %d Parts per billion. It seems good." %(result)
elif result >50 and result <=150:
speech_output = "Total Volatile Organic Compounds in your room air is %d Parts per billion. It seems air quality is not so good." %(result)
elif result >150 and result <=250:
speech_output = "Total Volatile Organic Compounds in your room air is %d Parts per billion and air is polluted." %(result)
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def all_sensor_read(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
result1 = read_table_item("sensordata", "type", "temperature")
result2 = read_table_item("sensordata", "type", "humidity")
result3 = read_table_item("sensordata", "type", "light")
result4 = read_table_item("sensordata", "type", "pressure")
result5 = read_table_item("sensordata", "type", "airquality")
#temperature = float("{0:.2f}".format(result))
session_attributes = {}
card_title = "Varifying room condition"
speech_output1 = "Your room temperature is %.2f degree centigrade and humidity is %.2f percent." %(result1, result2)
speech_output2 = " Ambiant light is %d lux. Atmospheric air pressure in your room is %d hectopascals and air quality is good." %(result3, result4)
speech_output = speech_output1 + speech_output2
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
def session_end(intent, session):
""" If we wanted to initialize the session to have some attributes we could
add those here
"""
session_attributes = {}
card_title = "End"
speech_output = "Thank you for calling me. Have a nice day!"
# If the user either does not reply to the welcome message or says something
# that is not understood, they will be prompted again with this text.
reprompt_text = ""
should_end_session = True
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
# --------------- Helpers that build all of the responses ----------------------
def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
'outputSpeech': {
'type': 'PlainText',
'text': output
},
'card': {
'type': 'Simple',
'title': title,
'content': output
},
'reprompt': {
'outputSpeech': {
'type': 'PlainText',
'text': reprompt_text
}
},
'shouldEndSession': should_end_session
}
def build_response(session_attributes, speechlet_response):
return {
'version': '1.0',
'sessionAttributes': session_attributes,
'response': speechlet_response
}
{
"interactionModel": {
"languageModel": {
"invocationName": "rapid iot",
"intents": [
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
},
{
"name": "TemperatureSensorIntent",
"slots": [],
"samples": [
"amount of temperature",
"value of temperature",
"room temperature condition",
"about temperature",
"tell temperature",
"how much cold my room is",
"how much hot my room is",
"Tell the temperature",
"What is the room temperature",
"What is the temperature"
]
},
{
"name": "HumiditySensorIntent",
"slots": [],
"samples": [
"value of humidity",
"humidity percentage",
"percentage of humidity",
"amount of humidity",
"humidity amount",
"humidity situation",
"room humidity",
"about my room humidity",
"what about humidity",
"What is the room humidity",
"What is the humidity"
]
},
{
"name": "LightSensorIntent",
"slots": [],
"samples": [
"what is the light intensity in my room",
"what is the light intensity of my room",
"what is the room light intensity",
"about the light intensity",
"about the light amount",
"what is the light amount",
"What is the light intensity"
]
},
{
"name": "PressureSensorIntent",
"slots": [],
"samples": [
"value of air pressure",
"amount of air pressure",
"value of atmospheric pressure",
"amount of atmospheric pressure",
"what is the atmospheric pressure",
"how abou air pressure",
"What is the air pressure"
]
},
{
"name": "AirqualitySensorIntent",
"slots": [],
"samples": [
"waht is the room air quality",
"what about room air quality",
"about room air quality",
"air is good or not",
"is the air is good",
"what is the air purity",
"about air quality",
"What is the air quality"
]
},
{
"name": "AllSensorIntent",
"slots": [],
"samples": [
"about environmental condition of my room",
"about environmental parameters of my room",
"about room situation",
"about room environmrnt",
"What about room environment"
]
},
{
"name": "LightRequiredIntent",
"slots": [],
"samples": [
"is it ok to read in this illumination",
"is it ok to read in this light",
"is the light is enough to read",
"is the light is ok to read",
"is it ok to read",
"is the light is enough for reading",
"Is my illumination is enough for reading",
"Is the illumination is enough for reading",
"Is illumination is enough for reading",
"Is my room light is enough for reading",
"Is my room illumination is enough for reading"
]
}
],
"types": []
}
}
}
#include "callbacks.h"
//HEADER START
//HEADER END
void ATMO_Setup() {
}
ATMO_Status_t AirQualityCharacteristic_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AirQualityCharacteristic_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(AirQualityCharacteristic, instance),
&ATMO_VARIABLE(AirQualityCharacteristic, bleServiceHandle),
ATMO_PROPERTY(AirQualityCharacteristic, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(AirQualityCharacteristic, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(AirQualityCharacteristic, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(AirQualityCharacteristic, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(AirQualityCharacteristic, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(AirQualityCharacteristic, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(AirQualityCharacteristic, writeDataType), ATMO_PROPERTY(AirQualityCharacteristic, readDataType), ATMO_PROPERTY(AirQualityCharacteristic, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(AirQualityCharacteristic, instance),
&ATMO_VARIABLE(AirQualityCharacteristic, bleCharacteristicHandle),
ATMO_VARIABLE(AirQualityCharacteristic, bleServiceHandle),
ATMO_PROPERTY(AirQualityCharacteristic, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(AirQualityCharacteristic, instance),
ATMO_VARIABLE(AirQualityCharacteristic, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(AirQualityCharacteristic, written));
return ATMO_Status_Success;
}
ATMO_Status_t AirQualityCharacteristic_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(AirQualityCharacteristic, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(AirQualityCharacteristic, instance),
ATMO_VARIABLE(AirQualityCharacteristic, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t AirQualityCharacteristic_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(AirQualityCharacteristic, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t AirQualityCharacteristic_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AirQualityCharacteristic_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TemperatureCharacteristic_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TemperatureCharacteristic_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(TemperatureCharacteristic, instance),
&ATMO_VARIABLE(TemperatureCharacteristic, bleServiceHandle),
ATMO_PROPERTY(TemperatureCharacteristic, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(TemperatureCharacteristic, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(TemperatureCharacteristic, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(TemperatureCharacteristic, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(TemperatureCharacteristic, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(TemperatureCharacteristic, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(TemperatureCharacteristic, writeDataType), ATMO_PROPERTY(TemperatureCharacteristic, readDataType), ATMO_PROPERTY(TemperatureCharacteristic, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(TemperatureCharacteristic, instance),
&ATMO_VARIABLE(TemperatureCharacteristic, bleCharacteristicHandle),
ATMO_VARIABLE(TemperatureCharacteristic, bleServiceHandle),
ATMO_PROPERTY(TemperatureCharacteristic, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(TemperatureCharacteristic, instance),
ATMO_VARIABLE(TemperatureCharacteristic, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(TemperatureCharacteristic, written));
return ATMO_Status_Success;
}
ATMO_Status_t TemperatureCharacteristic_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(TemperatureCharacteristic, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(TemperatureCharacteristic, instance),
ATMO_VARIABLE(TemperatureCharacteristic, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t TemperatureCharacteristic_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(TemperatureCharacteristic, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t TemperatureCharacteristic_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t TemperatureCharacteristic_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t HumidityCharacteristic_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t HumidityCharacteristic_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(HumidityCharacteristic, instance),
&ATMO_VARIABLE(HumidityCharacteristic, bleServiceHandle),
ATMO_PROPERTY(HumidityCharacteristic, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(HumidityCharacteristic, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(HumidityCharacteristic, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(HumidityCharacteristic, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(HumidityCharacteristic, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(HumidityCharacteristic, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(HumidityCharacteristic, writeDataType), ATMO_PROPERTY(HumidityCharacteristic, readDataType), ATMO_PROPERTY(HumidityCharacteristic, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(HumidityCharacteristic, instance),
&ATMO_VARIABLE(HumidityCharacteristic, bleCharacteristicHandle),
ATMO_VARIABLE(HumidityCharacteristic, bleServiceHandle),
ATMO_PROPERTY(HumidityCharacteristic, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(HumidityCharacteristic, instance),
ATMO_VARIABLE(HumidityCharacteristic, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(HumidityCharacteristic, written));
return ATMO_Status_Success;
}
ATMO_Status_t HumidityCharacteristic_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(HumidityCharacteristic, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(HumidityCharacteristic, instance),
ATMO_VARIABLE(HumidityCharacteristic, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t HumidityCharacteristic_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(HumidityCharacteristic, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t HumidityCharacteristic_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t HumidityCharacteristic_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t PressureCharacteristic_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t PressureCharacteristic_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(PressureCharacteristic, instance),
&ATMO_VARIABLE(PressureCharacteristic, bleServiceHandle),
ATMO_PROPERTY(PressureCharacteristic, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(PressureCharacteristic, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(PressureCharacteristic, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(PressureCharacteristic, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(PressureCharacteristic, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(PressureCharacteristic, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(PressureCharacteristic, writeDataType), ATMO_PROPERTY(PressureCharacteristic, readDataType), ATMO_PROPERTY(PressureCharacteristic, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(PressureCharacteristic, instance),
&ATMO_VARIABLE(PressureCharacteristic, bleCharacteristicHandle),
ATMO_VARIABLE(PressureCharacteristic, bleServiceHandle),
ATMO_PROPERTY(PressureCharacteristic, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(PressureCharacteristic, instance),
ATMO_VARIABLE(PressureCharacteristic, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(PressureCharacteristic, written));
return ATMO_Status_Success;
}
ATMO_Status_t PressureCharacteristic_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(PressureCharacteristic, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(PressureCharacteristic, instance),
ATMO_VARIABLE(PressureCharacteristic, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t PressureCharacteristic_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(PressureCharacteristic, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t PressureCharacteristic_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t PressureCharacteristic_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmbientLightCharacteristic_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmbientLightCharacteristic_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_BLE_GATTSAddService(
ATMO_PROPERTY(AmbientLightCharacteristic, instance),
&ATMO_VARIABLE(AmbientLightCharacteristic, bleServiceHandle),
ATMO_PROPERTY(AmbientLightCharacteristic, bleServiceUuid));
uint8_t property = 0;
uint8_t permission = 0;
property |= ATMO_PROPERTY(AmbientLightCharacteristic, read) ? ATMO_BLE_Property_Read : 0;
property |= ATMO_PROPERTY(AmbientLightCharacteristic, write) ? ATMO_BLE_Property_Write : 0;
property |= ATMO_PROPERTY(AmbientLightCharacteristic, notify) ? ATMO_BLE_Property_Notify : 0;
permission |= ATMO_PROPERTY(AmbientLightCharacteristic, read) ? ATMO_BLE_Permission_Read : 0;
permission |= ATMO_PROPERTY(AmbientLightCharacteristic, write) ? ATMO_BLE_Permission_Write : 0;
ATMO_DATATYPE types[3] = {ATMO_PROPERTY(AmbientLightCharacteristic, writeDataType), ATMO_PROPERTY(AmbientLightCharacteristic, readDataType), ATMO_PROPERTY(AmbientLightCharacteristic, notifyDataType)};
ATMO_BLE_GATTSAddCharacteristic(
ATMO_PROPERTY(AmbientLightCharacteristic, instance),
&ATMO_VARIABLE(AmbientLightCharacteristic, bleCharacteristicHandle),
ATMO_VARIABLE(AmbientLightCharacteristic, bleServiceHandle),
ATMO_PROPERTY(AmbientLightCharacteristic, bleCharacteristicUuid),
property, permission, ATMO_GetMaxValueSize(3, 64, types));
ATMO_BLE_GATTSRegisterCharacteristicAbilityHandle(
ATMO_PROPERTY(AmbientLightCharacteristic, instance),
ATMO_VARIABLE(AmbientLightCharacteristic, bleCharacteristicHandle),
ATMO_BLE_Characteristic_Written,
ATMO_ABILITY(AmbientLightCharacteristic, written));
return ATMO_Status_Success;
}
ATMO_Status_t AmbientLightCharacteristic_setValue(ATMO_Value_t *in, ATMO_Value_t *out) {
// Convert to the desired write data type
ATMO_Value_t convertedValue;
ATMO_InitValue(&convertedValue);
ATMO_CreateValueConverted(&convertedValue, ATMO_PROPERTY(AmbientLightCharacteristic, readDataType), in);
ATMO_BLE_GATTSSetCharacteristic(
ATMO_PROPERTY(AmbientLightCharacteristic, instance),
ATMO_VARIABLE(AmbientLightCharacteristic, bleCharacteristicHandle),
convertedValue.size,
(uint8_t *)convertedValue.data,
NULL);
ATMO_FreeValue(&convertedValue);
return ATMO_Status_Success;
}
ATMO_Status_t AmbientLightCharacteristic_written(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_CreateValueConverted(out, ATMO_PROPERTY(AmbientLightCharacteristic, writeDataType), in);
return ATMO_Status_Success;
}
ATMO_Status_t AmbientLightCharacteristic_subscibed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmbientLightCharacteristic_unsubscribed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_SX9500_Config_t config;
config.address = ATMO_PROPERTY(SX9500Touch, i2cAddress);
config.i2cDriverInstance = ATMO_PROPERTY(SX9500Touch, i2cInstance);
config.gpioDriverInstance = ATMO_PROPERTY(SX9500Touch, gpioInstance);
config.interruptEnabled = ATMO_PROPERTY(SX9500Touch, interruptEnabled);
config.interruptPin = ATMO_PROPERTY(SX9500Touch, interruptGpio);
ATMO_SX9500_Init(&config);
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Up, ATMO_ABILITY(SX9500Touch, pressUp));
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Down, ATMO_ABILITY(SX9500Touch, pressDown));
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Left, ATMO_ABILITY(SX9500Touch, pressLeft));
ATMO_SX9500_RegisterTouchedAbilityHandle(SX9500_Touched_Right, ATMO_ABILITY(SX9500Touch, pressRight));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_getTouchData(ATMO_Value_t *in, ATMO_Value_t *out) {
return;
}
ATMO_Status_t SX9500Touch_pressUp(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_pressDown(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_pressLeft(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t SX9500Touch_pressRight(ATMO_Value_t *in, ATMO_Value_t *out) {
SX9500_TouchState_t touchState;
ATMO_GetBinary(in, &touchState, sizeof(touchState));
ATMO_CreateValueBinary(out, &touchState, sizeof(touchState));
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_displayPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Temperature_P, x), ATMO_PROPERTY(Temperature_P, y), false);
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_onDisplayed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_topRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_bottomRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_topLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_bottomLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_Config_t config;
config.hidden = ATMO_PROPERTY(Temperature_P, pageHidden);
config.textColor = ATMO_PROPERTY(Temperature_P, textColor);
config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Temperature_P, topRightButtonEnabled),
ATMO_PROPERTY(Temperature_P,bottomRightButtonEnabled), ATMO_PROPERTY(Temperature_P, topLeftButtonEnabled), ATMO_PROPERTY(Temperature_P, bottomLeftButtonEnabled));
config.x = ATMO_PROPERTY(Temperature_P, x);
config.x = ATMO_PROPERTY(Temperature_P, x);
config.y = ATMO_PROPERTY(Temperature_P, y);
strncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Temperature_P, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.topRightButtonLabel, ATMO_PROPERTY(Temperature_P, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Temperature_P, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Temperature_P, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
config.spanX = ATMO_PROPERTY(Temperature_P, spanX);
config.spanY = ATMO_PROPERTY(Temperature_P, spanY);
config.title = ATMO_PROPERTY(Temperature_P, pageTitle);
config.titleHidden = ATMO_PROPERTY(Temperature_P, titleHidden);
ATMO_UI_SINGLEICONTEXT_Init(&config);
ATMO_VARIABLE(Temperature_P, pageHandle) = config.templateInstance;
ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Temperature_P, label));
ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Temperature_P, icon));
ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), ATMO_ABILITY(Temperature_P, onDisplayed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 1, ATMO_ABILITY(Temperature_P, topRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 2, ATMO_ABILITY(Temperature_P, bottomRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 3, ATMO_ABILITY(Temperature_P, topLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Temperature_P,pageHandle), 4, ATMO_ABILITY(Temperature_P, bottomLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Temperature_P, onLeave));
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_onLeave(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Temperature_P_setLabel(ATMO_Value_t *in, ATMO_Value_t *out) {
char label[32];
if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)
{
ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Temperature_P,pageHandle), label);
}
else
{
return ATMO_Status_Fail;
}
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_CONTROLLER_Config_t config;
config.enableUpDownNavLabels = ATMO_PROPERTY(EmbeddedPageController, upDownNavigationLabelsEnabled);
config.enableLeftRightNavLabels = ATMO_PROPERTY(EmbeddedPageController, leftRightNavigationLabelsEnabled);
ATMO_UI_Page_SetConfiguration(&config);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_displayRootPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayRootPage();
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateUp(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_UP);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateDown(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_DOWN);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateLeft(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_LEFT);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_navigateRight(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessNavButton(ATMO_UI_PAGE_NAV_RIGHT);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processTopRightButton(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessUserButton(1);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processBottomRightButton(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessUserButton(2);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processTopLeftButton(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessUserButton(3);
return ATMO_Status_Success;
}
ATMO_Status_t EmbeddedPageController_processBottomLeftButton(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_ProcessUserButton(4);
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_displayPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Humidity_Pag, x), ATMO_PROPERTY(Humidity_Pag, y), false);
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_onDisplayed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_topRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_bottomRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_topLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_bottomLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_Config_t config;
config.hidden = ATMO_PROPERTY(Humidity_Pag, pageHidden);
config.textColor = ATMO_PROPERTY(Humidity_Pag, textColor);
config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Humidity_Pag, topRightButtonEnabled),
ATMO_PROPERTY(Humidity_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(Humidity_Pag, topLeftButtonEnabled), ATMO_PROPERTY(Humidity_Pag, bottomLeftButtonEnabled));
config.x = ATMO_PROPERTY(Humidity_Pag, x);
config.x = ATMO_PROPERTY(Humidity_Pag, x);
config.y = ATMO_PROPERTY(Humidity_Pag, y);
strncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Humidity_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.topRightButtonLabel, ATMO_PROPERTY(Humidity_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Humidity_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Humidity_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
config.spanX = ATMO_PROPERTY(Humidity_Pag, spanX);
config.spanY = ATMO_PROPERTY(Humidity_Pag, spanY);
config.title = ATMO_PROPERTY(Humidity_Pag, pageTitle);
config.titleHidden = ATMO_PROPERTY(Humidity_Pag, titleHidden);
ATMO_UI_SINGLEICONTEXT_Init(&config);
ATMO_VARIABLE(Humidity_Pag, pageHandle) = config.templateInstance;
ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Humidity_Pag, label));
ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Humidity_Pag, icon));
ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), ATMO_ABILITY(Humidity_Pag, onDisplayed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 1, ATMO_ABILITY(Humidity_Pag, topRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 2, ATMO_ABILITY(Humidity_Pag, bottomRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 3, ATMO_ABILITY(Humidity_Pag, topLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Humidity_Pag,pageHandle), 4, ATMO_ABILITY(Humidity_Pag, bottomLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Humidity_Pag, onLeave));
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_onLeave(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Humidity_Pag_setLabel(ATMO_Value_t *in, ATMO_Value_t *out) {
char label[32];
if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)
{
ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Humidity_Pag,pageHandle), label);
}
else
{
return ATMO_Status_Fail;
}
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_displayPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(Pressure_Pag, x), ATMO_PROPERTY(Pressure_Pag, y), false);
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_onDisplayed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_topRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_bottomRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_topLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_bottomLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_Config_t config;
config.hidden = ATMO_PROPERTY(Pressure_Pag, pageHidden);
config.textColor = ATMO_PROPERTY(Pressure_Pag, textColor);
config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(Pressure_Pag, topRightButtonEnabled),
ATMO_PROPERTY(Pressure_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(Pressure_Pag, topLeftButtonEnabled), ATMO_PROPERTY(Pressure_Pag, bottomLeftButtonEnabled));
config.x = ATMO_PROPERTY(Pressure_Pag, x);
config.x = ATMO_PROPERTY(Pressure_Pag, x);
config.y = ATMO_PROPERTY(Pressure_Pag, y);
strncpy(config.topLeftButtonLabel, ATMO_PROPERTY(Pressure_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.topRightButtonLabel, ATMO_PROPERTY(Pressure_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(Pressure_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(Pressure_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
config.spanX = ATMO_PROPERTY(Pressure_Pag, spanX);
config.spanY = ATMO_PROPERTY(Pressure_Pag, spanY);
config.title = ATMO_PROPERTY(Pressure_Pag, pageTitle);
config.titleHidden = ATMO_PROPERTY(Pressure_Pag, titleHidden);
ATMO_UI_SINGLEICONTEXT_Init(&config);
ATMO_VARIABLE(Pressure_Pag, pageHandle) = config.templateInstance;
ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(Pressure_Pag, label));
ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(Pressure_Pag, icon));
ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), ATMO_ABILITY(Pressure_Pag, onDisplayed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 1, ATMO_ABILITY(Pressure_Pag, topRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 2, ATMO_ABILITY(Pressure_Pag, bottomRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 3, ATMO_ABILITY(Pressure_Pag, topLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(Pressure_Pag,pageHandle), 4, ATMO_ABILITY(Pressure_Pag, bottomLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(Pressure_Pag, onLeave));
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_onLeave(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t Pressure_Pag_setLabel(ATMO_Value_t *in, ATMO_Value_t *out) {
char label[32];
if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)
{
ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(Pressure_Pag,pageHandle), label);
}
else
{
return ATMO_Status_Fail;
}
return ATMO_Status_Success;
}
ATMO_Status_t ConvertPressur_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
unsigned int pressurePa = 0;
ATMO_GetUnsignedInt(in, &pressurePa);
ATMO_CreateValueUnsignedInt(out, pressurePa / 100);
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_displayPage(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(AmientLight_Pag, x), ATMO_PROPERTY(AmientLight_Pag, y), false);
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_onDisplayed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_topRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_bottomRightButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_topLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_bottomLeftButtonPressed(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_setup(ATMO_Value_t *in, ATMO_Value_t *out) {
ATMO_UI_PAGE_Config_t config;
config.hidden = ATMO_PROPERTY(AmientLight_Pag, pageHidden);
config.textColor = ATMO_PROPERTY(AmientLight_Pag, textColor);
config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(AmientLight_Pag, topRightButtonEnabled),
ATMO_PROPERTY(AmientLight_Pag,bottomRightButtonEnabled), ATMO_PROPERTY(AmientLight_Pag, topLeftButtonEnabled), ATMO_PROPERTY(AmientLight_Pag, bottomLeftButtonEnabled));
config.x = ATMO_PROPERTY(AmientLight_Pag, x);
config.x = ATMO_PROPERTY(AmientLight_Pag, x);
config.y = ATMO_PROPERTY(AmientLight_Pag, y);
strncpy(config.topLeftButtonLabel, ATMO_PROPERTY(AmientLight_Pag, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.topRightButtonLabel, ATMO_PROPERTY(AmientLight_Pag, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(AmientLight_Pag, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
strncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(AmientLight_Pag, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);
config.spanX = ATMO_PROPERTY(AmientLight_Pag, spanX);
config.spanY = ATMO_PROPERTY(AmientLight_Pag, spanY);
config.title = ATMO_PROPERTY(AmientLight_Pag, pageTitle);
config.titleHidden = ATMO_PROPERTY(AmientLight_Pag, titleHidden);
ATMO_UI_SINGLEICONTEXT_Init(&config);
ATMO_VARIABLE(AmientLight_Pag, pageHandle) = config.templateInstance;
ATMO_UI_SINGLEICONTEXT_SetMainText(config.templateInstance, ATMO_PROPERTY(AmientLight_Pag, label));
ATMO_UI_SINGLEICONTEXT_SetIcon(config.templateInstance, ATMO_PROPERTY(AmientLight_Pag, icon));
ATMO_UI_SINGLEICONTEXT_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), ATMO_ABILITY(AmientLight_Pag, onDisplayed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 1, ATMO_ABILITY(AmientLight_Pag, topRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 2, ATMO_ABILITY(AmientLight_Pag, bottomRightButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 3, ATMO_ABILITY(AmientLight_Pag, topLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterButtonAbilityHandle(ATMO_VARIABLE(AmientLight_Pag,pageHandle), 4, ATMO_ABILITY(AmientLight_Pag, bottomLeftButtonPressed));
ATMO_UI_SINGLEICONTEXT_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(AmientLight_Pag, onLeave));
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_onLeave(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
ATMO_Status_t AmientLight_Pag_setLabel(ATMO_Value_t *in, ATMO_Value_t *out) {
char label[32];
if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)
{
ATMO_UI_SINGLEICONTEXT_SetMainText(ATMO_VARIABLE(AmientLight_Pag,pageHandle), label);
}
else
{
return ATMO_Status_Fail;
}
return ATMO_Status_Success;
}
ATMO_Status_t AirQuality_Pag_trigger(ATMO_Value_t *in, ATMO_Value_t *out) {
return ATMO_Status_Success;
}
...
This file has been truncated, please download it to see its full contents.
Comments