HID scanner demo
Dependencies: BLE_API WIFI_API_32kRAM nRF51822 mbed
BLE HID function in this demo is temporary working with Android phone ONLY. Will be fixed to support iOS device in next update.
Revision 2:be04a220392e, committed 2015-08-14
- Comitter:
- wgd8700
- Date:
- Fri Aug 14 09:37:24 2015 +0000
- Parent:
- 1:51535675abf4
- Commit message:
- Update BLE_API, nRF51822, and mbed libs to sync throughout all sample code, work for 32KB RAM revision platform; Update main.cpp to add RF switch lock mechanism to prevent packet losses for BLE
Changed in this revision
--- a/BLE_API.lib Thu Jul 16 01:18:16 2015 +0000 +++ b/BLE_API.lib Fri Aug 14 09:37:24 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#9f4251b3355c +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#8d316a3271a8
--- a/WIFI_API_32kRAM.lib Thu Jul 16 01:18:16 2015 +0000 +++ b/WIFI_API_32kRAM.lib Fri Aug 14 09:37:24 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Delta/code/WIFI_API_32kRAM/#4085cc9441f3 +http://developer.mbed.org/teams/Delta/code/WIFI_API_32kRAM/#1cc76b1199e6
--- a/main.cpp Thu Jul 16 01:18:16 2015 +0000
+++ b/main.cpp Fri Aug 14 09:37:24 2015 +0000
@@ -14,15 +14,17 @@
WIFIDevice wifi;
EthernetInterface eth;
+bool flip_lock = false;
+
void flip() {
- RFSWIO = !RFSWIO;
+ if (!flip_lock) RFSWIO = !RFSWIO;
}
unsigned char keyData;
bool is_input = false;
-char ap_ssid[10] = {'H','T','C','8','2','0','\0'};
-char ap_pw[10] = {'1','1','1','1','1','1','1','1','\0'};
-const char* PC_SERVER_ADDRESS = "192.168.1.234";
+char* ap_ssid = "Tsungta_iPhone";
+char* ap_pw = "icq87001";
+const char* PC_SERVER_ADDRESS = "172.20.10.4";
uint16_t PC_PORT = 5222;
static const char DEVICE_NAME[] = "HID_Keyboard";
@@ -57,7 +59,7 @@
static uint8_t modifyKey[50];
char msg[25] = "NNN40 CONNECTED\n";
int main(void)
-{ NRF_CLOCK->XTALFREQ = 0x00; //Tsungta, Used to active radio correctly external when XTAL 32MHz is loaded
+{
uart.baud(115200);
uart.printf("Starting HID Service\n");
RFSWIO = 1;
@@ -139,12 +141,19 @@
}
index_b++;
if(keyData == 0x0a && ble.getGapState().connected){
+ flip_lock = true;
+ RFSWIO = 0;// RF Switch to BLE and lockup temporary
for(int i = 0; i < index_b ; i++){
hidService.updateReport(modifyKey[i], key_press_scan_buff[i]);
wait(0.03);
}
+ flip_lock = false;
+
+ flip_lock = true;
+ RFSWIO = 1;// RF Switch to WiFi and lockup temporary
+ socket.send(msg, sizeof(msg));
+ flip_lock = false;
- socket.send(msg, sizeof(msg));
index_b = 0;
index_w = 0;
memset(modifyKey, 0, 50);
--- a/mbed-src.lib Thu Jul 16 01:18:16 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#61103edf8a92
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Aug 14 09:37:24 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7 \ No newline at end of file
--- a/nRF51822.lib Thu Jul 16 01:18:16 2015 +0000 +++ b/nRF51822.lib Fri Aug 14 09:37:24 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#7c68c8d67e1f +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#ca9c9c2cfc6a