this is using the mbed os version 5-13-1
Revision 78:07bb86e3ce14, committed 2019-03-16
- Comitter:
- ocomeni
- Date:
- Sat Mar 16 13:05:52 2019 +0000
- Parent:
- 77:0b505d1e15f4
- Child:
- 79:a2187bbfa407
- Commit message:
- Main Manager class constructors and configuration structures implemented.
Changed in this revision
--- a/source/ATCmdManager.cpp Fri Mar 15 23:25:30 2019 +0000
+++ b/source/ATCmdManager.cpp Sat Mar 16 13:05:52 2019 +0000
@@ -1,10 +1,13 @@
#include "ATCmdManager.h"
#include "common_config.h"
-ATCmdManager::ATCmdManager(PinName tx, PinName rx, bool debug)
+ATCmdManager::ATCmdManager(PinName tx, PinName rx, SMDevicePeripheral *blePeripheral,
+ WiFiManager *wifi, bool debug)
:
_serial(tx, rx, DEFAULT_BAUD_RATE),
- _parser(&_serial)
+ _parser(&_serial),
+ blePeripheral(blePeripheral),
+ wifi(wifi)
{
// constructor
--- a/source/ATCmdManager.h Fri Mar 15 23:25:30 2019 +0000
+++ b/source/ATCmdManager.h Sat Mar 16 13:05:52 2019 +0000
@@ -2,6 +2,8 @@
#define __ATCMD_MANAGER_H__
#include <mbed.h>
#include "ATCmdParser.h"
+#include "BleManager.h"
+#include "WiFiManager.h"
#define MAIN_LOOP_WAIT_TIME_MS 1000 // milliseconds
#define NUM_UART_OPTIONS 6
@@ -12,7 +14,8 @@
class ATCmdManager {
public:
- ATCmdManager(PinName tx, PinName rx, bool debug = false);
+ ATCmdManager(PinName tx, PinName rx, SMDevicePeripheral *blePeripheral,
+ WiFiManager *wifi, bool debug = false);
public:
void runMain();
@@ -26,6 +29,8 @@
// AT Command Parser
ATCmdParser _parser;
+ SMDevicePeripheral *blePeripheral;
+ WiFiManager *wifi;
// OOB processing
void _process_oob(uint32_t timeout, bool all);
// OOB message handlers
--- a/source/BleManager.cpp Fri Mar 15 23:25:30 2019 +0000
+++ b/source/BleManager.cpp Sat Mar 16 13:05:52 2019 +0000
@@ -58,11 +58,13 @@
* back to the applications. You can provide overrides for a selection of events
* your application is interested in.
*/
-SMDevice::SMDevice(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address) :
+SMDevice::SMDevice(BLE &ble, events::EventQueue &event_queue,
+ BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config) :
_led1(LED1, 0),
_ble(ble),
_event_queue(event_queue),
_peer_address(peer_address),
+ ble_config(ble_config),
_handle(0),
_is_connecting(false) { }
@@ -360,8 +362,8 @@
/** A peripheral device will advertise, accept the connection and request
* a change in link security. */
-SMDevicePeripheral::SMDevicePeripheral(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address)
- : SMDevice(ble, event_queue, peer_address) { }
+SMDevicePeripheral::SMDevicePeripheral(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config)
+ : SMDevice(ble, event_queue, peer_address, ble_config) { }
void SMDevicePeripheral::start()
{
@@ -411,8 +413,8 @@
* increases the chances of being seen at the cost of more power */
//_ble.gap().setAdvertisingInterval(20);
//_ble.gap().setAdvertisingTimeout(0);
- _ble.gap().setAdvertisingInterval(1000); /* 1000ms. */
- _ble.gap().setAdvertisingTimeout(300); /* 16 * 1000ms. */
+ _ble.gap().setAdvertisingInterval(ble_config.advInterval); /* setting in ble_config */
+ _ble.gap().setAdvertisingTimeout(ble_config.advTimeout); /* setting in ble_config */
error = _ble.gap().startAdvertising();
@@ -495,8 +497,8 @@
/** A central device will scan, connect to a peer and request pairing. */
-SMDeviceCentral::SMDeviceCentral(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address)
- : SMDevice(ble, event_queue, peer_address) { };
+SMDeviceCentral::SMDeviceCentral(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config)
+ : SMDevice(ble, event_queue, peer_address, ble_config) { };
void SMDeviceCentral::start()
{
--- a/source/BleManager.h Fri Mar 15 23:25:30 2019 +0000
+++ b/source/BleManager.h Sat Mar 16 13:05:52 2019 +0000
@@ -22,6 +22,7 @@
#include <mbed.h>
#include "ble/BLE.h"
#include "SecurityManager.h"
+#include "common_types.h"
/** This example demonstrates all the basic setup required
* for pairing and setting up link security both as a central and peripheral
@@ -53,7 +54,8 @@
public SecurityManager::EventHandler
{
public:
- SMDevice(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address);
+ SMDevice(BLE &ble, events::EventQueue &event_queue,
+ BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config);
virtual ~SMDevice();
@@ -125,6 +127,7 @@
protected:
BLE &_ble;
+ ble_config_t ble_config;
events::EventQueue &_event_queue;
BLEProtocol::AddressBytes_t &_peer_address;
ble::connection_handle_t _handle;
@@ -135,7 +138,8 @@
* a change in link security. */
class SMDevicePeripheral : public SMDevice {
public:
- SMDevicePeripheral(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address);
+ SMDevicePeripheral(BLE &ble, events::EventQueue &event_queue,
+ BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config);
virtual void start();
@@ -150,7 +154,8 @@
/** A central device will scan, connect to a peer and request pairing. */
class SMDeviceCentral : public SMDevice {
public:
- SMDeviceCentral(BLE &ble, events::EventQueue &event_queue, BLEProtocol::AddressBytes_t &peer_address);
+ SMDeviceCentral(BLE &ble, events::EventQueue &event_queue,
+ BLEProtocol::AddressBytes_t &peer_address, ble_config_t ble_config);
virtual void start();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/WiFiManager.cpp Sat Mar 16 13:05:52 2019 +0000
@@ -0,0 +1,45 @@
+#include "WiFiManager.h"
+#include "common_config.h"
+
+
+WiFiManager::WiFiManager(wifi_config_t wifi_config, WiFiInterface *wifi)
+:
+ wifi_config(wifi_config),
+ network(wifi)
+
+{
+}
+
+WiFiManager::~WiFiManager()
+{
+}
+void WiFiManager::scanChannels()
+{
+}
+void WiFiManager::getAvailableAPs()
+{
+}
+void WiFiManager::set_WIFI_SSID(char * wifi_ssid)
+{
+ strcpy(wifi_config.ssid, wifi_ssid);
+}
+void WiFiManager::set_WIFI_PASSWORD(char * wifi_pass)
+{
+ strcpy(wifi_config.pass, wifi_pass);
+}
+void WiFiManager::set_WIFI_SECURITY(nsapi_security_t wifi_security)
+{
+ wifi_config.security = wifi_security;
+}
+void WiFiManager::connect()
+{
+}
+void WiFiManager::disconnect()
+{
+}
+void WiFiManager::sendHttpsRequest()
+{
+}
+void WiFiManager::sendHttpRequest()
+{
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/WiFiManager.h Sat Mar 16 13:05:52 2019 +0000
@@ -0,0 +1,31 @@
+#ifndef __WIFI_MANAGER_H__
+#define __WIFI_MANAGER_H__
+#include "common_types.h"
+
+class WiFiManager {
+public:
+ WiFiManager(wifi_config_t wifi_config, WiFiInterface *wifi);
+ ~WiFiManager();
+ void scanChannels();
+ void getAvailableAPs();
+ void set_WIFI_SSID(char * wifi_ssid);
+ void set_WIFI_PASSWORD(char * wifi_pass);
+ void set_WIFI_SECURITY(nsapi_security_t wifi_security);
+ void connect();
+ void disconnect();
+ void sendHttpsRequest();
+ void sendHttpRequest();
+
+
+
+private:
+ wifi_config_t wifi_config;
+ WiFiInterface *network;
+ /**
+ * Allows timeout to be changed between commands
+ *
+ * @param timeout_ms timeout of the connection
+ */
+ //void set_timeout(uint32_t timeout_ms = UBLOX_ODIN_W2_MISC_TIMEOUT);
+};
+#endif // __WIFI_MANAGER_H__
\ No newline at end of file
--- a/source/WifiManager.h Fri Mar 15 23:25:30 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#ifndef __WIFI_MANAGER_H__
-#define __WIFI_MANAGER_H__
-
-class WifiManager {
-public:
- WifiManager();
-public:
- void scanChannels();
- void getAvailableAPs();
- void connect2AP(const char * WIFI_SSID, const char * WIFI_PASSWORD);
- void sendHttpsRequest();
- void sendHttpRequest();
-
-
-
-private:
-
- /**
- * Allows timeout to be changed between commands
- *
- * @param timeout_ms timeout of the connection
- */
- void set_timeout(uint32_t timeout_ms = UBLOX_ODIN_W2_MISC_TIMEOUT);
-};
-#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/common_types.h Sat Mar 16 13:05:52 2019 +0000
@@ -0,0 +1,32 @@
+#ifndef __COMMON_TYPES_H__
+#define __COMMON_TYPES_H__
+#include <mbed.h>
+#define BLE_MAX_DEVICE_NAME_LEN 10
+#define MAX_SSID_LEN 32
+#define MAX_PASSKEY_LEN 32
+
+/** ble configuration structure
+*/
+typedef struct ble_config {
+ char deviceName[BLE_MAX_DEVICE_NAME_LEN]; /* BLE Device Name */
+ uint16_t advInterval; /* advertising interval in msecs */
+ uint16_t advTimeout; /* advertising timeout in secs */
+} ble_config_t;
+
+/** ble configuration structure
+*/
+typedef struct wifi_config {
+ char ssid[MAX_SSID_LEN]; /* WiFi SSID */
+ char pass[MAX_PASSKEY_LEN]; /* WiFi Passkey */
+ nsapi_security_t security; /* WiFi security */
+} wifi_config_t;
+
+/** ble configuration structure
+*/
+typedef struct app_config {
+ wifi_config_t wifi_config; /* wifi configuration */
+ ble_config_t ble_config; /* ble configuration */
+} app_config_t;
+
+
+#endif // __COMMON_TYPES_H__
\ No newline at end of file
--- a/source/main-https.cpp Fri Mar 15 23:25:30 2019 +0000
+++ b/source/main-https.cpp Sat Mar 16 13:05:52 2019 +0000
@@ -17,6 +17,7 @@
#include "common_config.h"
#include "ATCmdManager.h"
#include "BleManager.h"
+#include "WiFiManager.h"
UARTService *uart;
DigitalOut alivenessLED(LED1, 0);
@@ -24,10 +25,22 @@
static RawSerial *device; // tx, rx
-static UARTSerial *_serial; // tx, rx
-static ATCmdParser *_parser;
+
+// wifi configuration
+static wifi_config_t wifi_config;
+// wifi interface pointer
+static WiFiInterface *network;
+// wifi manager pointer
+static WiFiManager *wiFiManager;
+
+// BLE configuration
+static ble_config_t ble_config;
+// BLE interface pointer
+//BLE &_ble;
+// BLE peripheral pointer
static SMDevicePeripheral *peripheral;
-const static char DEVICE_NAME_MAIN[] = "BLE-UART";
+
+const static char DEVICE_NAME_MAIN[] = "UBLOX-BLE";
static const uint16_t uuid16_list[] = {LEDService::LED_SERVICE_UUID};
char buffer[BUFFER_LEN];
uint8_t TxBuffer[TX_BUFFER_LEN];
@@ -42,10 +55,9 @@
//unsigned char rt_stk[1024];
//unsigned char hp_stk[1024];
//unsigned char lp_stk[1024];
-unsigned char btle_stk[8*1024];
+unsigned char btle_stk[1024];
unsigned char wifi_stk[1024];
-unsigned char atcmd_stk[8*1024];
-static bool bleInitializationCompleted = false;
+unsigned char atcmd_stk[1024];
/* creates three tread objects with different priorities */
//Thread real_time_thread(osPriorityRealtime, 1024, &rt_stk[0]);
@@ -94,177 +106,6 @@
}
-void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
-{
- (void) params;
- BLE::Instance().gap().startAdvertising();
-}
-
-void blinkCallback(void)
-{
- alivenessLED = !alivenessLED; /* Do blinky on LED1 to indicate system aliveness. */
-}
-
-void EchoBleUartReceived()
-{
- uart->writeString(buffer);
- uart->writeString("\n"); //flushes uart output buffer and sends data
-}
-
-/**
- * This callback allows the LEDService to receive updates to the ledState Characteristic.
- *
- * @param[in] params
- * Information about the characterisitc being updated.
- */
-void onDataWrittenCallback(const GattWriteCallbackParams *params) {
- if ((params->handle == ledServicePtr->getValueHandle()) && (params->len == 1)) {
- actuatedLED = *(params->data);
- }
- else if ((uart != NULL) && (params->handle == uart->getTXCharacteristicHandle())) {
- uint16_t bytesRead = params->len;
-
- printf("received %u bytes\n\r ", bytesRead);
-
- if(bytesRead >= 255){
- printf("Overflow command %u n\r ", bytesRead);
- bytesRead = 255;
- }
-
- unsigned index = 0;
- for (; index < bytesRead; index++) {
- buffer[index] = params->data[index];
- }
-
- buffer[index++] = 0;
-
- printf("Data : %s ",buffer);
- printf("\r\n");
- eventQueue.call(EchoBleUartReceived);
-
- }
-}
-
-
-/**
- * This function is called when the ble initialization process has failled
- */
-void onBleInitError(BLE &ble, ble_error_t error)
-{
- printf("\n BLE Initialization failed!! \n");
-
- /* Initialization error handling should go here */
-}
-
-
-/* handle BLE timouts */
-static int bleTimoutCount = 0;
-
-void printBleTimeoutMsg()
-{
- bleTimoutCount++;
- device->printf("\n --- BLE Times out!! bleTimoutCount = %d --- \n", bleTimoutCount);
-}
-
-//void timeoutCallback(Gap::TimeoutEventCallback_t* context) {
-void timeoutCallback(Gap::TimeoutSource_t timeoutSource) {
- BLE &ble = BLE::Instance();
- eventQueue.call(printBleTimeoutMsg);
-}
-
-
-
-void printMacAddress()
-{
- /* Print out device MAC address to the console*/
- Gap::AddressType_t addr_type;
- Gap::Address_t address;
- BLE::Instance().gap().getAddress(&addr_type, address);
- printf("\nDEVICE MAC ADDRESS: ");
- for (int i = 5; i >= 1; i--){
- printf("%02x:", address[i]);
- }
- printf("%02x\r\n", address[0]);
-}
-
-/**
- * Callback triggered when the ble initialization process has finished
- */
-void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
-{
- BLE& ble = params->ble;
- ble_error_t error = params->error;
-
- if (error != BLE_ERROR_NONE) {
- /* In case of error, forward the error handling to onBleInitError */
- onBleInitError(ble, error);
- return;
- }
-
- /* Ensure that it is the default instance of BLE */
- if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {
- return;
- }
-
- ble.gap().onDisconnection(disconnectionCallback);
- ble.gattServer().onDataWritten(onDataWrittenCallback);
- ble.gap().onTimeout(timeoutCallback);
-
- bool initialValueForLEDCharacteristic = false;
- ledServicePtr = new LEDService(ble, initialValueForLEDCharacteristic);
- /* Setup primary service */
- uart = new UARTService(ble);
-
- /* setup advertising */
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME_MAIN, sizeof(DEVICE_NAME_MAIN));
- /* set up the services that can be discovered */
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,(const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
- ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
- ble.gap().setAdvertisingInterval(1000); /* 1000ms. */
- ble.gap().setAdvertisingTimeout(300); /* 16 * 1000ms. */
- ble.gap().startAdvertising();
-
- printMacAddress();
- bleInitializationCompleted = true;
-}
-
-void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context) {
- BLE &ble = BLE::Instance();
- eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));
-}
-
-
-void bleInitialization()
-{
- BLE &ble = BLE::Instance();
- device->printf("\n --- BLE Instance Instantiated --- \n");
- ble.onEventsToProcess(scheduleBleEventsProcessing);
- device->printf("\n --- BLE scheduleBleEventsProcessing setup --- \n");
- ble.init(bleInitComplete);
-}
-
-
-void restartBleAdvertising()
-{
- BLE &ble = BLE::Instance();
-
- //ble.init(bleInitComplete);
- // clear advertising payload
- ble.gap().clearAdvertisingPayload();
- /* setup advertising */
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME_MAIN, sizeof(DEVICE_NAME_MAIN));
- /* set up the services that can be discovered */
- ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,(const uint8_t *)UARTServiceUUID_reversed, sizeof(UARTServiceUUID_reversed));
- ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
- ble.gap().setAdvertisingInterval(1000); /* 1000ms. */
- ble.gap().startAdvertising();
- eventQueue.dispatch(1000); // Dispatch time - 1000msec
-}
-
static int uartExpectedRcvCount = 0;
static int uartCharRcvCount = 0;
static bool UartBusy = false;
@@ -414,35 +255,6 @@
}
}
-void reportGapState()
-{
- BLE &ble = BLE::Instance();
- Gap::GapState_t gapState = ble.gap().getState();
- char connStr[20] = " Not Connected ";
- char advStr[20] = " Not Advertising ";
- char devName[20] = "";
- if(gapState.advertising){
- strncpy(advStr, " Advertising ", 20);
- }
- if(gapState.connected){
- strncpy(connStr, " Connected ", 20);
- }
- device->printf("\n Advertising Status = %s\n Connection Status = %s\n", advStr, connStr);
- unsigned nLen;
- ble_error_t error;
- error = ble.gap().getDeviceName((uint8_t *) devName, &nLen);
- if(error != BLE_ERROR_NONE)
- {
- device->printf("\n Error Reading BLE device Name \n");
- return;
- }
- devName[nLen] = NULL;
- device->printf("\n BLE Device name = %s : Name Len %d\n", devName, nLen);
- for(int i=0;i<8;i++)
- device->putc(devName[i]);
-
-}
-
void printWait(int numSecs)
{
printf("Waiting for %d seconds...\n", numSecs);
@@ -454,6 +266,21 @@
}
}
+
+void setupDefaultBleConfig()
+{
+ strcpy(ble_config.deviceName, DEVICE_NAME_MAIN);// set BLE device name
+ ble_config.advInterval = 1000; // set advertising interval to 1 second default
+ ble_config.advTimeout = 0; // set advertising timeout to disabled by default
+}
+
+void setupDefaultWiFiConfig()
+{
+ strcpy(wifi_config.ssid, MBED_CONF_APP_WIFI_SSID);
+ strcpy(wifi_config.pass, MBED_CONF_APP_WIFI_PASSWORD);
+ wifi_config.security = NSAPI_SECURITY_WPA_WPA2;
+}
+
static int reset_counter = 0;
@@ -462,7 +289,7 @@
#define MAX_LOOP_COUNT 3
int ble_security_main()
{
- BLE& ble = BLE::Instance();
+ BLE& _ble = BLE::Instance();
events::EventQueue queue;
#if MBED_CONF_APP_FILESYSTEM_SUPPORT
@@ -476,7 +303,7 @@
while(1) {
{
printf("\r\n PERIPHERAL \r\n\r\n");
- SMDevicePeripheral peripheral(ble, queue, peer_address);
+ SMDevicePeripheral peripheral(_ble, queue, peer_address, ble_config);
peripheral.run();
return 0;
}
@@ -487,7 +314,7 @@
{
printf("\r\n CENTRAL \r\n\r\n");
- SMDeviceCentral central(ble, queue, peer_address);
+ SMDeviceCentral central(_ble, queue, peer_address, ble_config);
central.run();
}
loopCount++;
@@ -514,7 +341,7 @@
printf("Heap size: %lu / %lu bytes\r\n", heap_stats.current_size, heap_stats.reserved_size);
}
-#define DISABLE_WIFI_DEMO
+//#define DISABLE_WIFI
int main() {
reset_counter++;
//performFreeMemoryCheck();
@@ -522,8 +349,9 @@
printf("\r\n ++++++ PROGRAM STARTING -- reset count = %d ++++++ \r\n", reset_counter);
device = new RawSerial(USBTX, USBRX, DEFAULT_BAUD_RATE);
//ble_security_main();
-
- BLE& ble = BLE::Instance();
+ setupDefaultBleConfig();
+ setupDefaultWiFiConfig();
+ BLE& _ble = BLE::Instance();
events::EventQueue queue(/* event count */ 10 * EVENTS_EVENT_SIZE);
#if MBED_CONF_APP_FILESYSTEM_SUPPORT
/* if filesystem creation fails or there is no filesystem the security manager
@@ -535,7 +363,7 @@
print_memory_info();
printf("\r\n PERIPHERAL \r\n\r\n");
//SMDevicePeripheral peripheral(ble, queue, peer_address);
- peripheral = new SMDevicePeripheral(ble, queue, peer_address);
+ peripheral = new SMDevicePeripheral(_ble, queue, peer_address, ble_config);
print_memory_info();
peripheral->run();
@@ -553,10 +381,11 @@
//performFreeMemoryCheck();
printf("\r\n BTLE THREAD HAS RETURNED \r\n\r\n");
-#ifndef DISABLE_WIFI_DEMO // comment out wifi part
- printMacAddress();
- //reportGapState();
+#ifndef DISABLE_WIFI // comment out wifi part
int start = Kernel::get_ms_count();
+#ifdef DISABLE_WIFI_DEMO
+ wiFiManager = new WiFiManager(wifi_config, wifi);
+#else
NetworkInterface* network = connect_to_default_network_interface();
int stop = Kernel::get_ms_count();
device->printf("\n The Wifi Network scan took %d ms or %4.1f seconds\n", (stop - start), (float)((stop - start)/1000.0));
@@ -565,22 +394,15 @@
t.join();
network->disconnect();
delete network;
- printMacAddress();
- //reportGapState();
device->printf("\n Wifi-Demo completed - restarting BLE \n\n");
+#endif
#else
device->printf("\n Wifi Demo disabled so just waiting it out... \n\n");
printWait(60); // lets wait for a minute before turning BLE back on
device->printf("\n ++++++ restarting BLE ++++++ \n\n");
#endif
peripheral->startAdvertising();
- //peripheral->run();
- //btle_thread.start(callback(&queue, &EventQueue::dispatch_forever));
- //peripheral.run();
- //btle_thread.start(callback(peripheral, &SMDevicePeripheral::run));
- //t.start(callback(&queue, &EventQueue::dispatch_forever));
printWait(60);
- //reportGapState();
#ifdef ENABLE_UART_BACKGRND_DEMO
for(int i=0;i<255;i++)
{
@@ -603,7 +425,7 @@
}
#endif
device->printf("\r\n++++++ Starting ATCmdmanager ++++++ \r\n");
- ATCmdManager *aTCmdManager = new ATCmdManager(USBTX, USBRX, true);
+ ATCmdManager *aTCmdManager = new ATCmdManager(USBTX, USBRX, peripheral, wiFiManager, true);
aTCmdManager->runMain();
atcmd_thread.start(callback(aTCmdManager, &ATCmdManager::runMain));
//performFreeMemoryCheck();