mbed HRM1017にSBBLE/konashiを移植する実験(途中)
Dependencies: BLE_API mbed nRF51822
Fork of BLE_TEST_konashi by
Konashi/SBBLEと完全互換ではないので注意!!
ライブラリ類をUpdateするとコンパイル出来なくなります。インポートした物をそのまま使って下さい。
Characteristicを増やすと挙動がおかしくなる不具合があります。
- onDataWrittenコールバック関数が呼ばれなくなる。
- onDisconnectionコールバック関数の中の"ble.startAdvertising()"でハングする。
PIO入出力と次の3つのうちの2つまでの組み合わせなら動作するのを確認しました。
main.cppの20行目付近で選択できます。
- PWM
- I2C
- UART
IOの構成を変更したときは、iPhone/iPadのBluetoothをOFF->ONしてキャッシュをクリアする必要があります。
IOのピン割り付けはソースコードを見てください。
動作確認にはiOSのSBBLEアプリが使えます。
https://itunes.apple.com/jp/app/sbble/id788610934?mt=8
Revision 12:dd866bd5eaf9, committed 2016-04-19
- Comitter:
- mbed_tw_hoehoe
- Date:
- Tue Apr 19 16:22:00 2016 +0000
- Parent:
- 11:c25480277877
- Commit message:
- 2016/04/20 ?????BLE API????; TY51822r3 ??Build?????;
Changed in this revision
diff -r c25480277877 -r dd866bd5eaf9 BLE_API.lib --- a/BLE_API.lib Sun Sep 07 05:35:49 2014 +0000 +++ b/BLE_API.lib Tue Apr 19 16:22:00 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#ca826083980e +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#66159681aa21
diff -r c25480277877 -r dd866bd5eaf9 main.cpp --- a/main.cpp Sun Sep 07 05:35:49 2014 +0000 +++ b/main.cpp Tue Apr 19 16:22:00 2016 +0000 @@ -15,7 +15,7 @@ */ #include "mbed.h" -#include "BLEDevice.h" +#include "BLE.h" //Debug用 #define USE_KONASHI_PWM 0 @@ -270,9 +270,9 @@ static Gap::ConnectionParams_t connectionParams; -void onConnectionCallback(Gap::Handle_t handle, const Gap::ConnectionParams_t *params) +void onConnectionCallback(const Gap::ConnectionCallbackParams_t *params) { - DEBUG("connected. Got handle %u\r\n", handle); + //DEBUG("connected. Got handle %u\r\n", handle); led2 = 0; /* connectionParams.slaveLatency = 1; @@ -280,7 +280,7 @@ DEBUG("failed to update connection paramter\r\n"); }*/ } -void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason) +void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *reason) { DEBUG("Disconnected handle %u!\n\r", handle); DEBUG("Restarting the advertising process\n\r"); @@ -328,7 +328,7 @@ } } -void onDataWritten(uint16_t charHandle, const GattCharacteristicWriteCBParams *params) +void onDataWritten(const GattWriteCallbackParams *params) { DEBUG("onDataWritten\n\r"); DEBUG("params->len = %d\n\r",params->len); @@ -337,7 +337,7 @@ DEBUG("pioSettingCharacteristic!\n\r"); } else if (charHandle == pioPullupCharacteristic.getValueAttribute().getHandle()) { DEBUG("pioPullupCharacteristic!\n\r"); - } else */ if (charHandle == pioOutputCharacteristic.getValueAttribute().getHandle()) { + } else */ if (params->handle == pioOutputCharacteristic.getValueAttribute().getHandle()) { DEBUG("pioOutputCharacteristic!\n\r"); // uint8_t getPioOut[10]; // uint16_t bytesRead; @@ -393,7 +393,7 @@ /* } else if (charHandle == analogDriveCharacteristic.getValueAttribute().getHandle()) { DEBUG("analogDriveCharacteristic!\n\r");*/ #if USE_KONASHI_I2C - } else if (charHandle == i2cConfigCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == i2cConfigCharacteristic.getValueAttribute().getHandle()) { DEBUG("i2cConfigCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(i2cConfigCharacteristic.getValueAttribute().getHandle(), i2cConfig, &bytesRead); @@ -407,7 +407,7 @@ i2c.frequency(400000); } } - } else if (charHandle == i2cStartStopCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == i2cStartStopCharacteristic.getValueAttribute().getHandle()) { DEBUG("i2cStartStopCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(i2cStartStopCharacteristic.getValueAttribute().getHandle(), i2cStartStop, &bytesRead); @@ -426,7 +426,7 @@ i2c_repeated = false; } } - } else if (charHandle == i2cWriteCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == i2cWriteCharacteristic.getValueAttribute().getHandle()) { DEBUG("i2cWriteCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(i2cWriteCharacteristic.getValueAttribute().getHandle(), i2cWrite, &bytesRead); @@ -438,7 +438,7 @@ if(bytesRead>=3){ i2c.write((int)(i2cWrite[1]),(char *)&i2cWrite[2],(int)i2cWrite[0],i2c_repeated); } - } else if (charHandle == i2cReadParamCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == i2cReadParamCharacteristic.getValueAttribute().getHandle()) { DEBUG("i2cReadParamCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(i2cReadParamCharacteristic.getValueAttribute().getHandle(), i2cReadParam, &bytesRead); @@ -459,7 +459,7 @@ // ble.updateCharacteristicValue(i2cReadCharacteristic.getValueAttribute().getHandle(), (uint8_t*)&i2cRead, i2c_recvlen); #endif //USE_KONASHI_I2C #if USE_KONASHI_UART - } else if (charHandle == uartConfigCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == uartConfigCharacteristic.getValueAttribute().getHandle()) { DEBUG("uartConfigCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(uartConfigCharacteristic.getValueAttribute().getHandle(), uartConfig, &bytesRead); @@ -471,7 +471,7 @@ pc.baud(uart_baudrate*240); } } - } else if (charHandle == uartBaudrateCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == uartBaudrateCharacteristic.getValueAttribute().getHandle()) { DEBUG("uartBaudrateCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(uartBaudrateCharacteristic.getValueAttribute().getHandle(), uartBaudrate, &bytesRead); @@ -482,7 +482,7 @@ uart_baudrate=((uint16_t)(uartBaudrate[0]))<<8; uart_baudrate+=uartBaudrate[1]; } - } else if (charHandle == uartTxCharacteristic.getValueAttribute().getHandle()) { + } else if (params->handle == uartTxCharacteristic.getValueAttribute().getHandle()) { DEBUG("uartTxCharacteristic!\n\r"); // uint16_t bytesRead; // ble.readCharacteristicValue(uartTxCharacteristic.getValueAttribute().getHandle(), uartTx, &bytesRead);
diff -r c25480277877 -r dd866bd5eaf9 mbed-src.lib --- a/mbed-src.lib Sun Sep 07 05:35:49 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-src/#8f72041da6ba
diff -r c25480277877 -r dd866bd5eaf9 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Apr 19 16:22:00 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f \ No newline at end of file
diff -r c25480277877 -r dd866bd5eaf9 nRF51822-060mod.lib --- a/nRF51822-060mod.lib Sun Sep 07 05:35:49 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/todotani/code/nRF51822-060mod/#97823585e091
diff -r c25480277877 -r dd866bd5eaf9 nRF51822.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nRF51822.lib Tue Apr 19 16:22:00 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#f7faad332abc