Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS14.1 and iOS12.4.8 cannot find ESP32 BLE keyboard #58

Closed
WebSamuraiDaisuke opened this issue Nov 19, 2020 · 13 comments
Closed

iOS14.1 and iOS12.4.8 cannot find ESP32 BLE keyboard #58

WebSamuraiDaisuke opened this issue Nov 19, 2020 · 13 comments

Comments

@WebSamuraiDaisuke
Copy link

WebSamuraiDaisuke commented Nov 19, 2020

I use M5StickC have Code include BleKeyboard.h. But they cannot find the device as ESP32 BLE keyboard.
Win10 can find the device with Bluetooth.
How iOS find the device with BleKeyboard?

#include <M5StickC.h>
#include <BleKeyboard.h>

BleKeyboard bleKeyboard;

enum ConfSystem {
  mic = 0,
  video
} conf;
int n_conf = 2;
bool on_air;

void setup() {
  M5.begin();
  bleKeyboard.begin();

  Serial.println("Webconf Mute button");
  Serial.println("Push Button A (M5) to toggle MUTE");
  Serial.println("Push Button B to switch VideoOn or VideoOFF");
  M5.Lcd.setRotation(3); // BtnA is left side to LCD

  // default
  conf = mic;
  on_air = true;
  update_display();
}

void loop() {
  M5.update();
  
  if(M5.BtnA.wasPressed()){
    Serial.println("BtnA was pressed");
    if(bleKeyboard.isConnected()){
      on_air = !on_air;
      if(conf==mic){
        send_mute_mic();
      }
      else if(conf==video){
      send_off_video();
      }
    }
    else {
      Serial.println("BLE is not connected");
    }
    update_display();
  }

  if(M5.BtnB.wasPressed()){
    Serial.println("BtnB was pressed");
    conf = ConfSystem((conf+1) % n_conf);
    Serial.print("New ConfSystem: ");
    Serial.println(conf);
    update_display();
  }
  delay(10);
}

void update_display(){
  Serial.println("update_display");
  Serial.print("On air?: ");
  Serial.println(on_air);
  if(on_air){
    show_onair();
  }
  else {
    show_inmute();
  }
}

void show_onair(){
  M5.Lcd.fillScreen(TFT_RED);
  M5.Lcd.setTextColor(TFT_WHITE, TFT_RED);
  M5.Lcd.setTextSize(3);
  M5.Lcd.setTextDatum(MC_DATUM);
  M5.Lcd.drawString("ON AIR",80,40);

  M5.Lcd.setTextSize(2);
  M5.Lcd.setTextDatum(BR_DATUM);
  if(conf==mic){
    M5.Lcd.drawString("Mic",158,78);
  }
  else if (conf==video){
    M5.Lcd.drawString("Video", 158,78);  
  }
}

void show_inmute(){
  M5.Lcd.fillScreen(TFT_DARKGREY);
  M5.Lcd.setTextColor(TFT_WHITE, TFT_DARKGREY);
  M5.Lcd.setTextSize(3);
  M5.Lcd.setTextDatum(MC_DATUM);
  M5.Lcd.drawString("Muted...",80,40);

  M5.Lcd.setTextSize(2);
  M5.Lcd.setTextDatum(BR_DATUM);
  if(conf==mic){
    M5.Lcd.drawString("Mic",158,78);
  }
  else if (conf==video){
    M5.Lcd.drawString("Video", 158,78);  
  }
}

void send_mute_mic(){
  // https://support.zoom.us/hc/en-us/articles/205683899-Hot-Keys-and-Keyboard-Shortcuts-for-Zoom
  // Command(⌘)+Shift+A: Mute/unmute audio
  Serial.println("Toggle Mic");
  bleKeyboard.press(KEY_LEFT_GUI);
  bleKeyboard.press(KEY_LEFT_SHIFT);
  bleKeyboard.press('a');
  delay(100);
  bleKeyboard.releaseAll();
}

void send_off_video(){
  // https://www.cisco.com/c/en/us/td/docs/collaboration/CWMS/2_5/b_manage_meetings/b_manage_meetings_chapter_0100.html
  Serial.println("Toggle Video");
  bleKeyboard.press(KEY_LEFT_GUI);
  bleKeyboard.press(KEY_LEFT_SHIFT);
  bleKeyboard.press('v');
  delay(100);
  bleKeyboard.releaseAll();
}
@T-vK
Copy link
Owner

T-vK commented Nov 19, 2020

Which iOS version and which device and model are you using? Some are not compatible.

Edit: Sorry, I see the iOS version is mentioned in the title.

Take a look at #51

@WebSamuraiDaisuke
Copy link
Author

WebSamuraiDaisuke commented Nov 19, 2020 via email

@WebSamuraiDaisuke
Copy link
Author

WebSamuraiDaisuke commented Nov 19, 2020 via email

@T-vK
Copy link
Owner

T-vK commented Nov 19, 2020

If you look at the list in #51 you can see that the iPhone 7 is not compatible.
And the iPhone SE 2nd Generation is compatible.

I don't know about the iPad 4. It may or may not work.

Please test it with the official example code that doesn't contain any M5 libraries.

@uolot
Copy link

uolot commented Nov 20, 2020

Please test it with the official example code that doesn't contain any M5 libraries.

Just to add my 2c, I've been using this lib on M5Stack and M5Atom and using M5 libs, doesn't seem to affect BLE keyboard function at all. Thank you @T-vK for making and maintaining this great piece of software by the way! :)

@WebSamuraiDaisuke
Copy link
Author

@uolot

Just to add my 2c,

What is your 2c?

@mbrunton22
Copy link

Yeah, I am also having issues on an iPhone 8 running 14.1 - just cannot see the advertisement (esp wroom 32)

@uolot
Copy link

uolot commented Nov 23, 2020

@uolot

Just to add my 2c,

What is your 2c?

https://en.wikipedia.org/wiki/My_two_cents

@WebSamuraiDaisuke
Copy link
Author

@T-vK, Will you make this library to be compatible with iOS and macOS in near future?

@T-vK
Copy link
Owner

T-vK commented Nov 23, 2020

It already is. Again, look at #51. Apple devices that don't properly support "Bluetooth Low Energy" will never work with this and there is nothing I can do about it.

@SunboX
Copy link

SunboX commented Nov 25, 2020

Same for me, but it worked with this code here some time ago (same Mac same iOS devices): https://gist.github.com/manuelbl/66f059effc8a7be148adb1f104666467

I have to re-test if this is still the case or if the Mac / iOS update also broke that snipped.

Tested devices:

MacBook Pro 2019
iPad 5. Generation
iPhone X

Tested with ESP32 DevKit v4

@mbrunton22
Copy link

Yeah, I am also having issues on an iPhone 8 running 14.1 - just cannot see the advertisement (esp wroom 32)

I actually got this working by making my device name really short (in my case I just set it to "Matt"), and it seemed to work after that on both my recent Ipad and an iphone 8 running IOS 14.

@WebSamuraiDaisuke
Copy link
Author

Sorry for my late reply.
I had to make the device name shorter, every iOS can detect the device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants