Bluetooth: message limit

This commit is contained in:
Jeronimo Vallelunga 2017-11-27 19:35:31 -03:00
parent 63c80f1fba
commit a43db1659c
2 changed files with 3 additions and 8 deletions

View File

@ -8,7 +8,7 @@ export default function Central(
characteristic: null, characteristic: null,
message: '', message: '',
configuration: { configuration: {
limit: 20, limit: 20, // HARDCODE: https://devzone.nordicsemi.com/question/3860/largest-allowed-setting-for-variable-length-characteristic/
}, },
id, id,
}; };
@ -46,10 +46,6 @@ export default function Central(
.then(() => { .then(() => {
const eventListener = listener(callback); const eventListener = listener(callback);
state.characteristic.addEventListener('characteristicvaluechanged', eventListener); state.characteristic.addEventListener('characteristicvaluechanged', eventListener);
return state.characteristic.readValue();
}).then((data) => {
const configuration = decode(data);
state.configuration = JSON.parse(configuration.slice(3, configuration.length - 3));
return state.configuration; return state.configuration;
}); });

View File

@ -60,13 +60,12 @@ test('Central: connect', () => {
test('Central: handler', () => { test('Central: handler', () => {
const callback = jest.fn(); const callback = jest.fn();
expect.assertions(4); expect.assertions(3);
const promise = central.connect('mockName').then(() => central.handler(callback)) const promise = central.connect('mockName').then(() => central.handler(callback))
.then((configuration) => { .then((configuration) => {
expect(configuration).toEqual({ mockDecode: 'mockDecode' }); expect(configuration).toEqual({ limit: 20 });
expect(characteristic.startNotifications).toBeCalled(); expect(characteristic.startNotifications).toBeCalled();
expect(characteristic.readValue).toBeCalled();
return true; return true;
}); });