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

about Disney Magicband bluetooth codes #1

Open
ilker-aktuna opened this issue Jul 27, 2024 · 33 comments
Open

about Disney Magicband bluetooth codes #1

ilker-aktuna opened this issue Jul 27, 2024 · 33 comments

Comments

@ilker-aktuna
Copy link

ilker-aktuna commented Jul 27, 2024

Hi,

I'm sorry; I could not find any other way to contact you. So I'm trying my chance to reach via this channel.
I read on the page below , about your findings on Mgicband+ ble codes:
https://emcot.world/Disney_MagicBand%2B_Bluetooth_Codes#The_cc_Codes

I am trying to make a fun application for my family to make use of the bands at home.
I will try your codes, but I'm not sure which service and characteristic I have to send the commands.

I see there are 5 different services and a few characteristic under each service as below.
Could you tell me which one to use ?
I just want to make the band leds do some effects.

service:00001801-0000-1000-8000-00805f9b34fb
characteristic:00002a05-0000-1000-8000-00805f9b34fb
characteristic:00002b2a-0000-1000-8000-00805f9b34fb
characteristic:00002b29-0000-1000-8000-00805f9b34fb
service:00001800-0000-1000-8000-00805f9b34fb
characteristic:00002a00-0000-1000-8000-00805f9b34fb
characteristic:00002a01-0000-1000-8000-00805f9b34fb
service:1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0
characteristic:f7bf3564-fb6d-4e53-88a4-5e37e0326063
characteristic:984227f3-34fc-4045-a5d0-2c581f81a153
service:0000fe03-0000-1000-8000-00805f9b34fb
characteristic:f04eb177-3005-43a7-ac61-a390ddf83076
characteristic:2beea05b-1879-4bb4-8a2f-72641f82420b
characteristic:74f996c9-7d6c-4d58-9232-0427ab61c53c
characteristic:b32e83c0-fece-47c1-9015-53b7e7f0d2fe
service:0000fd98-0000-1000-8000-00805f9b34fb
characteristic:bd75b722-3dda-bef1-454d-7119c8ff26a2
characteristic:0b4d1c14-b070-8938-9a0b-d5f8188488cd

If you don't want to have this conversation under Github issues, you can contact me directly.
Thanks

@jjdb210
Copy link
Owner

jjdb210 commented Jul 28, 2024 via email

@ilker-aktuna
Copy link
Author

Hi,

Thanks for your quick response. How can we contact directly ? (Using this issue thread under an unrelated github repository is not the best method I believe)

I have a bluetooth sniffer , so I am now trying to sniff between my phone (Disney app) and the magicband.
Unfortunately I could not decrypt the packets. If you have experience on this, maybe you can help me with that.
Please see here, my question:
https://devzone.nordicsemi.com/f/nordic-q-a/113465/encrypted-packet-decrypted-incorrectly-bad-mic---how-to-get-ltk

About broadcast messages; I don't have any experience. And I really don't know the usage of hcitool
So if you can describe me what these parameters are (which one is the address , service, characteristic etc.) , maybe I can try to replicate them on Arduino , or Java.

hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A ff *83 01* e9 0c 00 0f 0f 5d
46 5b f0 05 32 37 48 95 cf 8a ad

If Arduino is able to do this, at least I can use broadcast until I discover the codes for unicast (direct) commands.

And lastly, what do you mean by " I was really hoping the Alexa integration would have come out by
now" ?
Is there an expected Alexa integration for Magicband+ ?

@ilker-aktuna
Copy link
Author

I've found the method for BLE advertising on esp32

But I need a device name. What should it be ?
Also, do you mean advertising by "broadcast" message or something else ?


  NimBLEDevice::init("Disney");
  
  NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising(); // create advertising instance
  NimBLEAdvertisementData advertisementData;   
  advertisementData.setManufacturerData(advDataString);         // Set the advertisement data
  pAdvertising->setAdvertisementData(advertisementData);
  pAdvertising->start(); // start advertising

@jjdb210
Copy link
Owner

jjdb210 commented Jul 28, 2024 via email

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jul 29, 2024 via email

@jjdb210
Copy link
Owner

jjdb210 commented Jul 29, 2024 via email

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jul 29, 2024 via email

@jjdb210
Copy link
Owner

jjdb210 commented Jul 29, 2024 via email

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jul 29, 2024

do you mean like this :
std::string advDataString = /* Length / "\x1E"
/
Flags / "\x02\x01\x1A"
/
Manufacturer info / "\x1A\xFF\x83\x01"
/
Custom data */ "\xE9\x0C\x00\x0F\x0F\x5D\x46\x5B\xF0\x05\x32\x37\x48\x95\xCF\x8A\xAD";

NimBLEDevice::init("disney");
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising(); // create advertising instance
NimBLEAdvertisementData advertisementData;
advertisementData.setManufacturerData(advDataString); // Set the advertisement data
pAdvertising->setAdvertisementData(advertisementData);
pAdvertising->addServiceUUID("ABCD");
pAdvertising->start(); // start advertising

@ilker-aktuna
Copy link
Author

that didn't change anything.

I am looking at NimBLE reference here:
https://h2zero.github.io/NimBLE-Arduino/class_nim_b_l_e_advertising.html

there are setManufacturerData and setAdvertisementData methods but I am not sure how to use these in compliance with your recommendation.

@jjdb210
Copy link
Owner

jjdb210 commented Jul 29, 2024 via email

@ilker-aktuna
Copy link
Author

but I am checking your code and as far as I understand, your code is sending all data as manufacture data
So as my example.
I don't see the difference.
But then both of them do not work for me. Maybe my magicband is a different version ???

@ilker-aktuna
Copy link
Author

about sniffing;
I have a nrf 52840 bluetooth sniffer and I can sniff with it using wireshark, but I don't know which packets are advertisement packets. I mostly have experience with btatt protocol which is not advertisment.

@jjdb210
Copy link
Owner

jjdb210 commented Jul 29, 2024 via email

@jjdb210
Copy link
Owner

jjdb210 commented Jul 29, 2024 via email

@ilker-aktuna
Copy link
Author

this code seems to work (at least it does something, I didn't check if it was the correct behaviour)
Magicband leds turned on (red)
thank you.

how do I turn off the leds now ?

btw, I can't find your email address , so I am still writing here.
My email address is my name + .info@gmail.com
So it is i_______a.info@gmail.com (no dash between name and surname)

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jul 30, 2024

I just made some more tests.
The code you provide makes the band leds red.
But I have 2 issues:

  1. it always makes the band "red" , I tried to change "6f" to other colors but it always makes red. So I assume it is not working as expected.
    uint8_t Adv_DATA[] = {0x83, 0x01, 0xe1, 0x00, 0xe9, 0x05, 0x00, **0x6f**, 0x0e, 0xf5, 0xb0};

for example I tried:
uint8_t Adv_DATA[] = {0x83, 0x01, 0xe1, 0x00, 0xe9, 0x05, 0x00, 0x7a, 0x0e, 0xf5, 0xb0};
expecting lime green according to your color palette. but it was "red" again.

  1. any other code I try from your examples, do not work
    I tried:
//e100e9080065d255005500b0 - custom color
//uint8_t Adv_DATA[] = {0x83, 0x01, 0xe1, 0x00, 0xe9, 0x08, 0x00, 0x65, 0xd2, 0x55, 0x00, 0x55, 0x00, 0xb0}; 
//e9 0b 0b 0f 0f 5c 5d 48 a5 d1 45 32 05 - circle animation
//uint8_t Adv_DATA[] = {0x83, 0x01, 0xe1, 0x00, 0xe9, 0x0b, 0x0b, 0x0f, 0x0f, 0x5c, 0x5d, 0x48, 0xa5, 0xd1, 0x45, 0x32, 0x05}; 

any idea about what's happening ?

@jjdb210
Copy link
Owner

jjdb210 commented Jul 30, 2024 via email

@ilker-aktuna
Copy link
Author

Make sure if you change the size of the array, that you update the 11 to
the proper value of data being sent (same number of elements that is in the
array).

Ok. That was something I missed. Sorry. Circle animation works if I change the 11 to 17.

As far as the changing the code not changing the color... 2 notes on that:

  1. Only 5 of the bits are being used, which makes the math a little
    funny... I'm not sure which 5 off the top of my head... but based on it
    being red... Try 5f and see what happens.

well, I did the math there.
Your example 6f is 0110 1111
bottom 5 bits : 01111 , decimal 15 , shows as "pink" in your table -> I get "red" (ok, maybe that's pink, let's say)

So I changed it to 7a , which is 0111 1010
bottom 5 bits : 11010 , decimal 26 , should be "lime green" but I still get "red"

You suggest 5f , I tried that and still get "red"

what am I doing wrong ?

  1. The other thing that might be happening, is if the beacon isn't
    getting fully cleared, you might be still sending the red beacon, even
    after sending something else... I'm not in a place I can test that at a
    moment, but I'll see if I can rig up some other sample code. There's also a
    timing variable, so it might be a really long red, so it may take a bit
    before it refreshes. If the band leds are off though, it should grab the
    code pretty quick.

well I powered off the esp32 module several times. So beacon is certainly cleared. And I tried with long durations between my tests. (2-3 hours later etc.)
Also, after each "advertisement" , I put a 10 second delay and then stop the advertisement:

pAdvertising->start(); // start advertising 
delay(10000);
pAdvertising->stop();

and the led goes off. I am not sure if this is the ideal way to stop the leds, but it works.

@ilker-aktuna
Copy link
Author

I just tried the "Single 6-bit color" command and it works.
So in fact do we really need the "Single Color From Pallette Function" ?

How do we make a circle animation with custom color ?

@jjdb210
Copy link
Owner

jjdb210 commented Jul 31, 2024 via email

@ilker-aktuna
Copy link
Author

ilker-aktuna commented Jul 31, 2024

ok. in that case, understanding palette colors and their usage is really important.
I still could not change the color from red to any other color by playing with "6f". If you have any advise on this , please let me know.

Also, what is the "5 Color Pallet" example in your wiki actually doing ?
A full command might look like this: e9 08 00 f4 0f a0 a4 b9 b9 a4

I am mostly interested in ;

  1. adding vibration to any single color
  2. changing color of a circle animation (with or without vibration)

If you have any ideas on achieving these (even trial & error) , I'd really like to test.

and, last but not least, I really would like to use single device control (like we do on the disney app when selecting color theme)
any ideas on that ?
I tried to sniff the traffic with nrf52840 sniffer but it was encrypted and I could not get a LTK to decrypt.

Probably the Disney app has an hardcoded LTK and without it we can not decrypt the BLE traffic from/to Disney app.
Do you know how to sniff traffic on Android phone ? Maybe from that perspective, it could be sniffed with no encryption ?

@jjdb210
Copy link
Owner

jjdb210 commented Jul 31, 2024 via email

@ilker-aktuna
Copy link
Author

ok. let's leave vibration for now.
what about changing colors ?
I even could not change the color in "Single Color From Pallette Function" example.
Are you able to change it ? Can you give me an example which will output any color other than red in this:
8301e100e905006f0ef5b0

Btw, what is the "5 Color Pallet" example in your wiki actually doing ?
A full command might look like this: e9 08 00 f4 0f a0 a4 b9 b9 a4

about direct connection; I see what you are trying to do with 2 RPI sniffing solution. But I have a better sniffing setup and I am already able to sniff. But without a LTK the messages are encrypted. Do you know how to get the LTK ?
mb.zip

I am attaching the capture file that I have already captured. If you can get the LTK from the pairing phase in this file, then we can decrypt the messages.

@jjdb210
Copy link
Owner

jjdb210 commented Aug 1, 2024 via email

@ilker-aktuna
Copy link
Author

I may be wrong, but I dont think there is going to be a way to use a
passive sniffer to decode the LTK for a paired magicband.

well in fact, I am doing pairing in each sniff session. But still I am not able to get the LTK.
I am not able to do the MITM setup right now. (I have a few spare RPI but I am going on a vacation and don't have the time to prepare the setup)
If you find anything, please let me know.

about color palette;
thanks for clarifying it. Now I can use that command.
But I still have a question about use of color palette in other commands.
For example, what is the "5 Color Pallet" example in your wiki actually doing ?
e9 08 00 f4 0f a0 a4 b9 b9 a4

@jjdb210
Copy link
Owner

jjdb210 commented Aug 1, 2024 via email

@ilker-aktuna
Copy link
Author

hi,

I am trying to do the same on an Android app. And normally the following code should work. But it does not.

   ```

BluetoothLeAdvertiser mBluetoothLeAdvertiser = mBTAdapter.getBluetoothLeAdvertiser();
AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder();
String s = "8301e100e90800f40ffca1b1a4b1";
byte[] b = new byte[s.length() / 2];
for (int i = 0; i < b.length; i++) {
int index = i * 2;
int v = Integer.parseInt(s.substring(index, index + 2), 16);
b[i] = (byte) v;
}
dataBuilder.addManufacturerData(224 , b);

    AdvertiseSettings.Builder settingsBuilder = new AdvertiseSettings.Builder();
    settingsBuilder.setTimeout(0); //set to 0 to continously advertise

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADVERTISE) != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(new String[]{Manifest.permission.BLUETOOTH_ADVERTISE}, 1);
       
        return;
    }
    mBluetoothLeAdvertiser.startAdvertising(settingsBuilder.build(), dataBuilder.build(), new AdvertiseCallback() {
        @Override
        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
            super.onStartSuccess(settingsInEffect);
        }
        @Override
        public void onStartFailure(int errorCode) {
            super.onStartFailure(errorCode);
        }
    });

Do you have any idea what's wrong ?

the "addManufacturerData" on Android BLE requires 2 parameters:
1. manufacturerId (integer) 
2. manufacturerSpecificData (byte)

I don't know what to use as manufacturerId.
From your guide I understand that it is 0x83 0x01 but how should I put it in an integer ?

@jjdb210
Copy link
Owner

jjdb210 commented Aug 8, 2024 via email

@ilker-aktuna
Copy link
Author

yes that worked !
full working code:


BluetoothLeAdvertiser mBluetoothLeAdvertiser = mBTAdapter.getBluetoothLeAdvertiser();
        AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder();

        String hexString = "e100e90c000f0f5d465bf005323748b0";
        int len = hexString.length();
        byte[] data = new byte[len / 2];

        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4)
                    + Character.digit(hexString.charAt(i+1), 16));
        }
        
        dataBuilder.addManufacturerData(387 , data);

        AdvertiseSettings.Builder settingsBuilder = new AdvertiseSettings.Builder();
        settingsBuilder.setTimeout(1000); //set to 0 to continously advertise

        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADVERTISE) != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.BLUETOOTH_ADVERTISE}, 1);
            return;
        }
        mBluetoothLeAdvertiser.startAdvertising(settingsBuilder.build(), dataBuilder.build(), new AdvertiseCallback() {
            @Override
            public void onStartSuccess(AdvertiseSettings settingsInEffect) {
                super.onStartSuccess(settingsInEffect);
            }
            @Override
            public void onStartFailure(int errorCode) {
                super.onStartFailure(errorCode);
            }
        });

@ilker-aktuna
Copy link
Author

thanks again. do you have any progress about direct messages (GATT/ATT) ?

@jjdb210
Copy link
Owner

jjdb210 commented Aug 8, 2024 via email

@ilker-aktuna
Copy link
Author

Hi,

Do you have any progress on this ?

thanks

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

2 participants