Using BLE to control WIFI configuration as SSID and PW.
Dependencies: BLE_API WIFI_API_32kRAM mbed nRF51822
Fork of NNN40_WiFi by
BLE_WIFIControl enables user to setup Wifi connection via BLE link. Here is iPhone app that teaches you how to use this BLE_WIFIControl example. /media/uploads/Marcomissyou/ios_app_for_wifi_configure.pdf
Diff: main.cpp
- Revision:
- 3:65c5fce3a471
- Parent:
- 1:f8f52bde7864
- Child:
- 7:5d82c92ec2a3
--- a/main.cpp Tue Mar 03 10:47:16 2015 +0000
+++ b/main.cpp Mon Mar 23 01:57:16 2015 +0000
@@ -1,32 +1,28 @@
#include "mbed.h"
#include "WIFIDevice.h"
-
+#include "EthernetInterface.h"
WIFIDevice wifi;
-uint8_t ap_ssid[20] = {'H','T','C','S','V','\0'};
-uint8_t ap_pw[11] = {'1','1','1','1','1','1','1','1','\0'};
-
const char* PC_SERVER_ADDRESS = "192.168.1.234";
uint16_t PC_PORT = 5222;
-DigitalOut SW(p19);
+DigitalOut LED01(LED1);
+DigitalOut LED02(LED2);
int main(void)
-{
+{
EthernetInterface eth;
eth.init(); //Use DHCP
- SW = 1;
- wifi.setNetwork(ap_ssid, ap_pw, 0); // set given SSID and PW as the highest priority
-
+ wait(1);
+ // set given SSID and PW as the highest priority
+ wifi.setNetwork("HTCSV", "11111111", 0);
+ wait(1);
+ LED01 = 1;
eth.connect(40000);
- DPRINT(N_ERR, "IP Address: %s\n",eth.getIPAddress());
- DPRINT(N_ERR, "MAC Address: %s\n",eth.getMACAddress());
-
-
- TCPSocketConnection socket;
- DPRINT(N_ERR, "is_connected: %i\n",socket.is_connected());
- socket.connect(PC_SERVER_ADDRESS,PC_PORT);
- DPRINT(N_ERR, "is_connected: %i\n",socket.is_connected());
+
+ LED02 = 1;
+ TCPSocketConnection socket;
+ socket.connect(PC_SERVER_ADDRESS,PC_PORT);
char msg[] = "Hello World";
socket.send(msg, sizeof(msg));
@@ -34,4 +30,3 @@
eth.disconnect();
wifi.sleep();
}
-
