From ccf8d0ecc22a849608194c61567d92e60ddd9282 Mon Sep 17 00:00:00 2001 From: "Padmapriya Govindasamy (RBEI/EAC4)" Date: Fri, 27 Sep 2019 13:48:06 +0530 Subject: [PATCH] rebase-2 --- .../1.0.0/xdk110.platform | 54 ++++++++------- .../xdk110/connectivity/WlanGenerator.xtend | 65 ++++++++++++++++++- .../xdk110/platform/MakefileGenerator.xtend | 15 ++--- 3 files changed, 98 insertions(+), 36 deletions(-) diff --git a/platforms/org.eclipse.mita.platform.xdk110/1.0.0/xdk110.platform b/platforms/org.eclipse.mita.platform.xdk110/1.0.0/xdk110.platform index e73314eb..2dd2920d 100644 --- a/platforms/org.eclipse.mita.platform.xdk110/1.0.0/xdk110.platform +++ b/platforms/org.eclipse.mita.platform.xdk110/1.0.0/xdk110.platform @@ -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. @@ -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) @@ -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 - required configuration-item loraAppEui: array + required configuration-item loraAppKey: array + required configuration-item loraAppEui: array - configuration-item loraDeviceEui: array + configuration-item loraDeviceEui: array configuration-item adaptiveDataRate: bool = true configuration-item bandFrequency: uint16 @@ -725,8 +724,8 @@ connectivity named-singleton LoRa { - signal raw(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array - signal cayenne(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array + signal raw(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array + signal cayenne(portNum: uint8 = 1, confirmation: LoRaMessageConfirmation = LoRaMessageConfirmation.Unconfirmed): array } /** @@ -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; @@ -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 @@ -922,7 +921,7 @@ connectivity many HttpRestClient { } -enum LedColor { +export enum LedColor { Red, Yellow, Orange @@ -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 - signal array_register_int8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array - signal array_register_uint16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array - signal array_register_int16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array - signal array_register_uint32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array - signal array_register_int32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array + signal array_register_uint8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array + signal array_register_int8(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array + signal array_register_uint16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array + signal array_register_int16(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array + signal array_register_uint32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array + signal array_register_int32(address: uint8, length: uint8, mode: I2CMode = I2CMode.ReadWrite): array signal register_uint8(address: uint8, mode: I2CMode = I2CMode.ReadWrite): uint8 signal register_int8(address: uint8, mode: I2CMode = I2CMode.ReadWrite): int8 @@ -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 - signal appendingBinaryWrite(filePath: string) : array + signal resumingBinaryRead(filePath: string, blockSize: uint32) : array + signal appendingBinaryWrite(filePath: string) : array signal resumingTextRead(filePath: string, blockSize: uint32) : string signal appendingTextWrite(filePath: string) : string - signal rewindingBinaryRead(filePath: string, fileSize: uint32) : array - signal rewindingBinaryWrite(filePath: string) : array + signal rewindingBinaryRead(filePath: string, fileSize: uint32) : array + signal rewindingBinaryWrite(filePath: string) : array signal rewindingTextRead(filePath: string, fileSize: uint32) : string signal rewindingTextWrite(filePath: string) : string @@ -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 diff --git a/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/connectivity/WlanGenerator.xtend b/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/connectivity/WlanGenerator.xtend index 352ef0fc..1bdd932a 100644 --- a/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/connectivity/WlanGenerator.xtend +++ b/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/connectivity/WlanGenerator.xtend @@ -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; } @@ -236,6 +236,59 @@ 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) @@ -243,6 +296,7 @@ class WlanGenerator extends AbstractSystemResourceGenerator { .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") { @@ -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); diff --git a/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/platform/MakefileGenerator.xtend b/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/platform/MakefileGenerator.xtend index 825375e2..24576853 100644 --- a/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/platform/MakefileGenerator.xtend +++ b/platforms/org.eclipse.mita.platform.xdk110/src/org/eclipse/mita/platform/xdk110/platform/MakefileGenerator.xtend @@ -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 compilationUnits, List sourceFiles) { +class MakefileGenerator extends PlatformMakefileGenerator { + override generateMakefile(CompilationContext context, List sourceFiles) { + val compilationUnits = context.allUnits val setups = compilationUnits?.flatMap[it.setup]; val appName = StaticValueInferrer.infer( setups?.findFirst[it.type.name == "XDK110"]?.getConfigurationItemValue("applicationName"), []