Skip to content

Commit

Permalink
rebase-2
Browse files Browse the repository at this point in the history
  • Loading branch information
PriyaGovind committed Sep 27, 2019
1 parent 155f4dd commit ccf8d0e
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 36 deletions.
54 changes: 30 additions & 24 deletions platforms/org.eclipse.mita.platform.xdk110/1.0.0/xdk110.platform
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ enum BMA280_Bandwidth {
*/
sensor BMA280 {
generator "org.eclipse.mita.platform.xdk110.sensors.Bma280Generator"
validator "org.eclipse.mita.platform.xdk110.sensors.Bma280Validator"

/**
* The range of acceleration we want to measure.
Expand All @@ -74,17 +73,17 @@ sensor BMA280 {
/**
* The X axis of the BMA280
*/
modality x_axis : int32
modality x_axis : int16

/**
* The Y axis of the BMA280
*/
modality y_axis : int32
modality y_axis : int16

/**
* The Z axis of the BMA280
*/
modality z_axis : int32
modality z_axis : int16

/**
* The L2 norm of the acceleration vector: sqrt(x^2 + y^2 + z^2)
Expand Down Expand Up @@ -712,10 +711,10 @@ connectivity named-singleton LoRa {
validator "org.eclipse.mita.platform.xdk110.connectivity.LoraValidator"

required configuration-item region: Region
required configuration-item loraAppKey: array<uint8>
required configuration-item loraAppEui: array<uint8>
required configuration-item loraAppKey: array<uint8, ?>
required configuration-item loraAppEui: array<uint8, ?>

configuration-item loraDeviceEui: array<uint8>
configuration-item loraDeviceEui: array<uint8, ?>
configuration-item adaptiveDataRate: bool = true

configuration-item bandFrequency: uint16
Expand All @@ -725,8 +724,8 @@ connectivity named-singleton LoRa {



signal raw(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array<uint8>
signal cayenne(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array<CayennePayload>
signal raw(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array<uint8, ?>
signal cayenne(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array<CayennePayload, ?>
}

/**
Expand Down Expand Up @@ -756,7 +755,7 @@ connectivity named-singleton WLAN {
/**
* Configure IP address and network via DHCP or static
*/
configuration-item ipConfiguration : IpConfiguration = Dhcp()
configuration-item ipConfiguration : IpConfiguration = IpConfiguration.Dhcp()
}

exception MqttException;
Expand Down Expand Up @@ -805,9 +804,9 @@ connectivity many MQTT {
*/
required configuration-item clientId : string

configuration-item lastWill: MqttWill = NoWill()
configuration-item lastWill: MqttWill = MqttWill.NoWill()

configuration-item authentication: MqttAuthentication = None()
configuration-item authentication: MqttAuthentication = MqttAuthentication.None()

/**
* The clean session flag indicates to the broker whether the client wants
Expand Down Expand Up @@ -922,7 +921,7 @@ connectivity many HttpRestClient {
}


enum LedColor {
export enum LedColor {
Red,
Yellow,
Orange
Expand Down Expand Up @@ -953,18 +952,18 @@ enum I2CMode {
bus many I2C {
generator "org.eclipse.mita.platform.xdk110.buses.I2CGenerator"
validator "org.eclipse.mita.platform.xdk110.buses.I2CValidator"
sizeInferrer "org.eclipse.mita.program.inferrer.GenericPlatformSizeInferrer"
sizeInferrer "org.eclipse.mita.library.stdlib.GenericPlatformSizeInferrer"

required configuration-item deviceAddress: uint8

configuration-item byteOrder : ByteOrder = ByteOrder.LittleEndian

signal array_register_uint8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<uint8>
signal array_register_int8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<int8>
signal array_register_uint16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<uint16>
signal array_register_int16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<int16>
signal array_register_uint32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<uint32>
signal array_register_int32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<int32>
signal array_register_uint8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<uint8, ?>
signal array_register_int8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<int8, ?>
signal array_register_uint16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<uint16, ?>
signal array_register_int16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<int16, ?>
signal array_register_uint32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<uint32, ?>
signal array_register_int32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array<int32, ?>

signal register_uint8(address: uint8, mode: I2CMode = I2CMode.ReadWrite): uint8
signal register_int8(address: uint8, mode: I2CMode = I2CMode.ReadWrite): int8
Expand Down Expand Up @@ -1043,14 +1042,14 @@ io named-singleton SDCard {
generator "org.eclipse.mita.platform.xdk110.io.SDCardGenerator"
sizeInferrer "org.eclipse.mita.platform.xdk110.io.SDCardSizeInferrer"

signal resumingBinaryRead(filePath: string, blockSize: uint32) : array<uint8>
signal appendingBinaryWrite(filePath: string) : array<uint8>
signal resumingBinaryRead(filePath: string, blockSize: uint32) : array<uint8, ?>
signal appendingBinaryWrite(filePath: string) : array<uint8, ?>

signal resumingTextRead(filePath: string, blockSize: uint32) : string
signal appendingTextWrite(filePath: string) : string

signal rewindingBinaryRead(filePath: string, fileSize: uint32) : array<uint8>
signal rewindingBinaryWrite(filePath: string) : array<uint8>
signal rewindingBinaryRead(filePath: string, fileSize: uint32) : array<uint8, ?>
signal rewindingBinaryWrite(filePath: string) : array<uint8, ?>

signal rewindingTextRead(filePath: string, fileSize: uint32) : string
signal rewindingTextWrite(filePath: string) : string
Expand Down Expand Up @@ -1111,6 +1110,13 @@ platform XDK110 {
*/
configuration-item startupDelay: uint32 = 0

/**
* The FreeRTOS stack size of the event loop task in 32-bit words. If you don't know what this
* means, be careful when you change this value. More information can be found here:
* http://www.freertos.org/FAQMem.html#StackSize
*/
configuration-item stackSize: uint32 = 2000

modality powerStatus: PowerStatus

event startup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class WlanGenerator extends AbstractSystemResourceGenerator {
{
do
{
if ((WLANNETWORKCONFIG_IPV4_ACQUIRED == WlanNetworkConfig_GetIpStatus()) && (WLANNETWORK_CONNECTED == WlanNetworkConnect_GetStatus()))
if ((WLANNWCNF_IPSTATUS_IPV4_AQRD == WlanNetworkConfig_GetIpStatus()) && (WLANNWCT_STATUS_CONNECTED == WlanNetworkConnect_GetStatus()))
{
exception = RETCODE_OK;
}
Expand All @@ -236,13 +236,67 @@ class WlanGenerator extends AbstractSystemResourceGenerator {
}
return exception;
}
Retcode_T CheckWlanConnectivityAndReconnect(void)
{
Retcode_T exception = RETCODE_OK;
WlanNetworkConnect_ScanInterval_T scanInterval = 5;
WlanNetworkConnect_ScanList_T scanList;
WlanNetworkConnect_IpStatus_T nwStatus;
bool networkStatusFlag = false;
nwStatus = WlanNetworkConnect_GetIpStatus();
if (WLANNWCT_IPSTATUS_CT_AQRD != nwStatus)
{
printf("Checking for network availability and trying to connect again\n");
exception = WlanNetworkConnect_ScanNetworks(scanInterval, &scanList);
if (RETCODE_OK == exception)
{
for (int i = 0U; i < WLANNWCT_MAX_SCAN_INFO_BUF; i++)
{
if (0U == strcmp((char *) NETWORK_SSID, (char *) scanList.ScanData[i].Ssid))
{
networkStatusFlag = true;
printf("Network with SSID %s is available\n", NETWORK_SSID);
exception = ConnectivityWLANWifi_Enable();
if (RETCODE_OK != exception)
{
printf("Not able to connect to the network\n");
}
break;
}
else
{
networkStatusFlag = false;
}
}
if (false == networkStatusFlag)
{
exception = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_WLAN_NETWORK_NOT_AVAILABLE);
printf("Network with SSID %s is not available\n", NETWORK_SSID);
}
}
else if ((uint32_t) RETCODE_NO_NW_AVAILABLE == Retcode_GetCode(exception))
{
printf("Network not available\n");
}
}
else
{
printf("Network Connection is active\n");
}
return exception;
}
''')
.addHeader('XdkCommonInfo.h', true, IncludePath.HIGH_PRIORITY)
.addHeader('BCDS_Basics.h', true, IncludePath.VERY_HIGH_PRIORITY)
.addHeader('BCDS_Wlan.h', true, IncludePath.HIGH_PRIORITY)
.addHeader('BCDS_WlanNetworkConfig.h', true, IncludePath.HIGH_PRIORITY)
.addHeader('Serval_Network.h', true, IncludePath.HIGH_PRIORITY)
.addHeader('Serval_Ip.h', true, IncludePath.HIGH_PRIORITY)
.addHeader("BCDS_WlanNetworkConnect.h", true)
.addHeader('wlan.h', true, IncludePath.HIGH_PRIORITY)
if(auth instanceof SumTypeRepr) {
if(auth.name == "Enterprise") {
Expand All @@ -256,10 +310,17 @@ class WlanGenerator extends AbstractSystemResourceGenerator {
}
return result
}
override generateAdditionalHeaderContent() {
return codeFragmentProvider.create('''
Retcode_T CheckWlanConnectivityAndReconnect(void);
''');
}
private def CodeFragment buildStatusCallbacks(SystemResourceSetup component) {
val baseName = component.baseName
codeFragmentProvider.create('''
return codeFragmentProvider.create('''
static void «baseName»_WlanConnectStatusCallback(WlanNetworkConnect_Status_T connectStatus)
{
BCDS_UNUSED(connectStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
package org.eclipse.mita.platform.xdk110.platform

import java.util.List
import javax.inject.Inject
import org.eclipse.mita.program.Program
import org.eclipse.mita.program.generator.CodeFragmentProvider
import org.eclipse.mita.program.generator.IPlatformMakefileGenerator
import org.eclipse.mita.program.generator.CompilationContext
import org.eclipse.mita.program.generator.PlatformMakefileGenerator
import org.eclipse.mita.program.inferrer.StaticValueInferrer

class MakefileGenerator implements IPlatformMakefileGenerator {

@Inject
private CodeFragmentProvider codeFragmentProvider

override generateMakefile(Iterable<Program> compilationUnits, List<String> sourceFiles) {
class MakefileGenerator extends PlatformMakefileGenerator {
override generateMakefile(CompilationContext context, List<String> sourceFiles) {
val compilationUnits = context.allUnits
val setups = compilationUnits?.flatMap[it.setup];
val appName = StaticValueInferrer.infer(
setups?.findFirst[it.type.name == "XDK110"]?.getConfigurationItemValue("applicationName"), []
Expand Down

0 comments on commit ccf8d0e

Please sign in to comment.