You are reading a single comment by @Vlad and its replies. Click here to read the full conversation.
  • Thanks everyone.

    Just a heads up, I've tried to enable full BLE API support for nrf51822 board (e.g. that are disabled atm by defined(NRF52) and SAVE_ON_FLASH - these are the APIs that allow to create GATT server, in other words to make nrf board to be "central" device), this is not possible with that small flash unfortunately:

    STORAGE: 247808 -> 262144
    CODE: 110592 -> 256372
    CODE AND STORAGE OVERLAP
    

    Effectively nrf51822 boards are forced to be peripheral devices only. That's ok methink as to be "central" is not that important/common for this small devices.

    However, I must say I was able to read some data from other BT devices by using advertised services, for example I was able to hook up to a Xiaomi Temperature and Humidity sensor:

    NRF.findDevices(function(devices) {
                print("Found");
                if (devices[0] && devices[0].serviceData.fe95) {
                    var data = devices[0].serviceData.fe95;
                    var flag = data[11];
                    print(flag);
                    switch (flag) {
                        case 4: {
                            // temp
                            temp = (data[14] | data[15] << 8) / 10;
                            break;
                        }
                        case 6: {
                            // humidity
                            humidity = (data[14] | data[15] << 8) / 10;
                            break;
                        }
                        case 10: {
                            // battery
                            battery = devices[0].serviceData.fe95[14];
                            break;
                        }
                        case 13: {
                            // temp and humidity
                            temp = (data[14] | data[15] << 8) / 10;
                            humidity = (data[16] | data[17] << 8) / 10;
                            break;
                        }
                        default : {
                            print("Unknown flag: " + flag);
                        }
                    }
                }
            }, {
                filters: [
                    { id: "4c:65:a8:d0:7a:ee public" }
                ],
                timeout: 2000
            }
        );
    

    Perfectly working.

About

Avatar for Vlad @Vlad started