-
Notifications
You must be signed in to change notification settings - Fork 14
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
Bt bringup #31
Bt bringup #31
Conversation
I feel like it would be good to encapsulate a bluetooth connection to a camera as a class on its own, and have it be a library that can be put into other projects have you tried just not using security? unless I missed something, the freemote code doesn't have security |
Definitely yes for library, after fixing the bt pair (bond/security, whatever we call it), it will be put into a library. in freemote they have bool BLEConnection::requestPairing(void)
{
// skip if already paired
if ( secured() ) return true;
return Bluefruit.Security._authenticate(_conn_hdl);
} which jumps to bool BLESecurity::_authenticate(uint16_t conn_hdl)
{
VERIFY_STATUS(sd_ble_gap_authenticate(conn_hdl, &_sec_param ), false);
return true;
} The Since you have the actual remote, would you confirm/test that it requires first using camera's "bluetooth cfg -> pairing" and turn on the remote then the camera will show "pairing request from xxxx Yes/No". After select yes on camera, next time this remote can directly connect to camera and control it without pairing again. To simulate this behavior, For Linux, I have to pair it in the system menu first, and then use the script in the freemote PR I opened to simulate the remote. If it is not paired(bonded), it can connect to the camera, but as long as a write request to the characteristic(0xff01), the camera will drop the connection (for safety, authenticated control only). This is also the same for nrf connect app on Android. It has to be paired in system settings, then in the app it will show 'Bonded', after this I can send cmd and not being dropped. If not paired, but directly connect to the camera (without security), it just disconnects after any write to characteristics. |
confirmed maybe this becomes a mashup of https://github.com/maxmacstn/ESP32-Canon-BLE-Remote/tree/master and freemote? Act can you call omg especially |
Thanks for the hint, actually I created an empty project with only ble stuff. However, judging by the debug output of nimble (which can be enabled by modifying header file nimconfig.h), it stuck at the same place like the previous commit in this PR. I also erased the whole flash before tried this bt only crap to ensure nvm is empty. Here is the log, in case someone with enough bt knowledge can spot some way out.
Stuck at previous line for about 15-30s, it timed out(?). Then error output is like below: rt=13 sounds like timeout.
Strangely I was able to trace into All that being said, it seems that the |
Let me try the canon remote, actually it is not using the nimble stack with a 2x larger code footprint bt library, but it may work. There is an improved version: |
unfortunately, the canon one won't help since it's using if (pclient->connect(camera_address))
{
// Acquire reference to main service
pRemoteService = pclient->getService(SERVICE_UUID);
if (pRemoteService != nullptr)
{
// Acquire reference to BLE characteristics
pRemoteCharacteristic_Pairing = pRemoteService->getCharacteristic(PAIRING_SERVICE);
if ((pRemoteCharacteristic_Pairing != nullptr))
{
// Send request on pairing service from external device
String device_name_ = " " + device_name + " "; //Pairing message to send
byte cmdPress[device_name_.length()]; // Stocking list of Bytes char of the message
device_name_.getBytes(cmdPress, device_name_.length()); // message Parser
cmdPress[0] = {0x03};
pRemoteCharacteristic_Pairing->writeValue(cmdPress, sizeof(cmdPress), false); // Writing to Canon_pairing_service
log_e("Camera paring success");
delay(200);
disconnect();
BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT_NO_MITM);
delay(200);
connect();
nvs.setString("cameraaddr", String(camera_address.toString().c_str())) Also, the nvs is used to by the user to store an address of the camera. , not the bt stack to store crypto info |
I have implemented a working version just for taking pictures https://github.com/tao-j/alpha-ble I also made an integration into your code 6431c9d, however, it seems that either nvs is disturbed or the semaphones of the freertos is disturbed. See two locations of the |
The reason for the locality of The NimBLE stack problem seems to be related to ESP32 only. espressif/esp-idf#8303. And ESP32 is pretty old now, I guess they are not of high priority for a fix. In summary, when ESP32-S3-PICO-(R8F8) is available with PSRAM and FLASH in the same small package as ESP32-PICO and served in an upgraded m5stick (and I wish they replace side button with the same small up/down/button encoder as in m5ink), it may worth a second shot. |
It seems that M5Stack is going to release a new version of the device, dubbed "m5Stick c plus2". This internal image from FCC (July 11 2023) shows that ESP32-PICO-V3-02 is used, which has 8M flash and 2M PSRAM. So we can use the bluedroid BLE stack instead of the NimBLE. Just let everyone know here all hope is not lost. |
with the help of #30
now additional library can be put into the flash.
Trying to enable BT using NimbleBLE. But so far, I am unable to pair with the device.
in freemote PR I made. It is obvious and tested that the manual focus can be controlled in a fine grained way. Their nrf52 has a 'soft device' which is essentially a closed source library/binary version of what nimble is trying to achieve (and it does that well).
I found the BT remote in your pic. And given the ptp manual focus is far from perfect, so it might worth a try to figure out how to do it, but right now I could not figure out how. Stuck at waiting a BT event from the camera after initiating the
->SecureConnection()
call. And it timed out.