@@ -240,7 +240,7 @@ class ControlPanel {
240240 interfaceBoxGanglion. draw();
241241 } else {
242242 interfaceBoxGanglion. draw();
243- if (selectedProtocol == BoardProtocol . BLED112 ) {
243+ if (selectedProtocol == BoardProtocol . BLED112 || selectedProtocol == BoardProtocol . NATIVE_BLE ) {
244244 bleBox. y = interfaceBoxGanglion. y + interfaceBoxGanglion. h;
245245 dataLogBoxGanglion. y = bleBox. y + bleBox. h;
246246 bleBox. draw();
@@ -724,12 +724,46 @@ class BLEBox {
724724 bleBox_cp5. draw();
725725 }
726726
727+ private void refreshGanglionNativeList () {
728+ if (bleIsRefreshing) {
729+ output(" Search for Ganglions using Native Bluetooth is in progress." );
730+ return ;
731+ }
732+ output(" Refreshing available Ganglions using Native Bluetooth..." );
733+ bleList. items. clear();
734+
735+ Thread thread = new Thread (){
736+ public void run (){
737+ refreshBLE. getCaptionLabel(). setText(" SEARCHING..." );
738+ bleIsRefreshing = true ;
739+
740+ try {
741+ bleMACAddrMap = GUIHelper . scan_for_ganglions (3 );
742+ for (Map . Entry<String , String > entry : bleMACAddrMap. entrySet ())
743+ {
744+ bleList. addItem(entry. getKey(), entry. getValue(), " " );
745+ bleList. updateMenu();
746+ println (" Found Ganglion Board: " + entry. getKey() + " " + entry. getValue());
747+ }
748+ } catch (GanglionError e)
749+ {
750+ e. printStackTrace();
751+ }
752+
753+ refreshBLE. getCaptionLabel(). setText(" START SEARCH" );
754+ bleIsRefreshing = false ;
755+ }
756+ };
757+
758+ thread. start();
759+ }
760+
727761 private void refreshGanglionBLEList () {
728762 if (bleIsRefreshing) {
729- output(" BLE Devices Refreshing in progress" );
763+ output(" Search for Ganglions using BLED112 Dongle is in progress. " );
730764 return ;
731765 }
732- output(" BLE Devices Refreshing " );
766+ output(" Refreshing available Ganglions using BLED112 Dongle... " );
733767 bleList. items. clear();
734768
735769 Thread thread = new Thread (){
@@ -779,7 +813,11 @@ class BLEBox {
779813 refreshBLE = createButton(bleBox_cp5, name, text, _x, _y, _w, _h);
780814 refreshBLE. onRelease(new CallbackListener () {
781815 public void controlEvent (CallbackEvent theEvent ) {
782- refreshGanglionBLEList();
816+ if (selectedProtocol == BoardProtocol . BLED112 ) {
817+ refreshGanglionBLEList();
818+ } else {
819+ refreshGanglionNativeList();
820+ }
783821 }
784822 });
785823 }
@@ -1114,6 +1152,7 @@ class InterfaceBoxCyton {
11141152class InterfaceBoxGanglion {
11151153 public int x, y, w, h, padding; // size and position
11161154 private ControlP5 ifbg_cp5;
1155+ private Button protocolGanglionNativeBLE;
11171156 private Button protocolBLED112Ganglion;
11181157 private Button protocolWifiGanglion;
11191158
@@ -1122,16 +1161,17 @@ class InterfaceBoxGanglion {
11221161 y = _y;
11231162 w = _w;
11241163 padding = _padding;
1125- h = (24 + _padding) * 3 ;
1164+ h = (24 + _padding) * 4 ;
11261165 int buttonHeight = 24 ;
11271166
11281167 // Instantiate local cp5 for this box
11291168 ifbg_cp5 = new ControlP5 (ourApplet);
11301169 ifbg_cp5. setGraphics(ourApplet, 0 ,0 );
11311170 ifbg_cp5. setAutoDraw(false );
11321171
1133- createBLED112Button(" protocolBLED112Ganglion" , " Bluetooth (BLED112 Dongle)" , false , x + padding, y + padding * 3 + 4 , w - padding * 2 , 24 );
1134- createGanglionWifiButton(" protocolWifiGanglion" , " Wifi (from Wifi Shield)" , false , x + padding, y + padding * 4 + 24 + 4 , w - padding * 2 , 24 );
1172+ createGanglionNativeBLEButton(" protocolNativeBLEGanglion" , " Bluetooth (Native)" , false , x + padding, y + padding * 3 + 4 , w - padding * 2 , 24 );
1173+ createBLED112Button(" protocolBLED112Ganglion" , " Bluetooth (BLED112 Dongle)" , false , x + padding, y + (padding * 4 ) + 24 + 4 , w - padding * 2 , 24 );
1174+ createGanglionWifiButton(" protocolWifiGanglion" , " Wifi (from Wifi Shield)" , false , x + padding, y + (padding * 5 ) + (24 * 2 ) + 4 , w - padding * 2 , 24 );
11351175 }
11361176
11371177 public void update () {}
@@ -1161,6 +1201,21 @@ class InterfaceBoxGanglion {
11611201 return b;
11621202 }
11631203
1204+ private void createGanglionNativeBLEButton (String name , String text , boolean isToggled , int _x , int _y , int _w , int _h ) {
1205+ protocolGanglionNativeBLE = createIFBGButton(name, text, isToggled, _x, _y, _w, _h);
1206+ protocolGanglionNativeBLE. onRelease(new CallbackListener () {
1207+ public void controlEvent (CallbackEvent theEvent ) {
1208+ controlPanel. wifiBox. wifiList. items. clear();
1209+ controlPanel. bleBox. bleList. items. clear();
1210+ selectedProtocol = BoardProtocol . NATIVE_BLE ;
1211+ controlPanel. bleBox. refreshGanglionNativeList();
1212+ protocolGanglionNativeBLE. setOn();
1213+ protocolBLED112Ganglion. setOff();
1214+ protocolWifiGanglion. setOff();
1215+ }
1216+ });
1217+ }
1218+
11641219 private void createBLED112Button (String name , String text , boolean isToggled , int _x , int _y , int _w , int _h ) {
11651220 protocolBLED112Ganglion = createIFBGButton(name, text, isToggled, _x, _y, _w, _h);
11661221 protocolBLED112Ganglion. onRelease(new CallbackListener () {
@@ -1169,6 +1224,7 @@ class InterfaceBoxGanglion {
11691224 controlPanel. bleBox. bleList. items. clear();
11701225 selectedProtocol = BoardProtocol . BLED112 ;
11711226 controlPanel. bleBox. refreshGanglionBLEList();
1227+ protocolGanglionNativeBLE. setOff();
11721228 protocolBLED112Ganglion. setOn();
11731229 protocolWifiGanglion. setOff();
11741230 }
@@ -1182,13 +1238,15 @@ class InterfaceBoxGanglion {
11821238 controlPanel. wifiBox. wifiList. items. clear();
11831239 controlPanel. bleBox. bleList. items. clear();
11841240 selectedProtocol = BoardProtocol . WIFI ;
1241+ protocolGanglionNativeBLE. setOff();
11851242 protocolBLED112Ganglion. setOff();
11861243 protocolWifiGanglion. setOn();
11871244 }
11881245 });
11891246 }
11901247
11911248 public void resetGanglionSelectedProtocol () {
1249+ protocolGanglionNativeBLE. setOff();
11921250 protocolBLED112Ganglion. setOff();
11931251 protocolWifiGanglion. setOff();
11941252 selectedProtocol = BoardProtocol . NONE ;
@@ -2913,7 +2971,7 @@ class InitBox {
29132971 } else if (eegDataSource == DATASOURCE_PLAYBACKFILE && playbackData_fname == " N/A" && sdData_fname == " N/A" ) { // if data source == playback && playback file == 'N/A'
29142972 outputWarn(" No playback file selected. Please select a playback file and retry system initiation." ); // tell user that they need to select a file before the system can be started
29152973 return ;
2916- } else if (eegDataSource == DATASOURCE_GANGLION && (selectedProtocol == BoardProtocol . BLE || selectedProtocol == BoardProtocol . BLED112 ) && ganglion_portName == " N/A" ) {
2974+ } else if (eegDataSource == DATASOURCE_GANGLION && (selectedProtocol == BoardProtocol . NATIVE_BLE || selectedProtocol == BoardProtocol . BLED112 ) && ganglion_portName == " N/A" ) {
29172975 outputWarn(" No BLE device selected. Please select your Ganglion device and retry system initiation." );
29182976 return ;
29192977 } else if (eegDataSource == DATASOURCE_GANGLION && selectedProtocol == BoardProtocol . WIFI && wifi_portName == " N/A" && controlPanel. getWifiSearchStyle() == controlPanel. WIFI_DYNAMIC ) {
0 commit comments