This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sending I2C commands via BLE

Hello,

I will explain my setup:

I have 2 nRF51-DK each one of them connected via I2C and SPI to two different custom boards. One being the central(nrfA) and the other being the peripheral(nrfB), regarding BLE.

I want to send from 1st board----I2C----> nRFA -----BLE----> nRFB ---I2C--->2nd board and the other way around at the same time if needed. I am already using the NUS service to send the data received by SPI so wanted to use a different one for I2C.

What I wanted to know is what is the easiest service or profile to send the I2C commands via BLE? Or is it easier to send SPI and I2C via NUS?

I thought using the Immediate Alert Service (IAS) to send the I2C commands, but from what I discovered it can only be used on the peripheral side, is this correct?

I'm using SDK11 and SD130 v2.

Thank you for the help,

Jorge Costa

  • Just use the NUS service for that too. Prepend each message you're sending with one byte saying whether it's I2C or SPI and then do the right thing at the other end, sending to one service or the other.

    Using the Immediate Alert Service is really wrong, it's not a data transfer service, it's a service for immediate alerts.

    I'm generally appalled how the NUS service appears to be taken as-is, whether it's really appropriate for the data being sent or not, and used by just about everyone for just about everything. You can just write your own service with a couple of characteristics to do what you want.

    Here's another idea, just have two instances of the NUS service but with different UUIDs, that works too. Or have two primary services which have no characteristics but just identify which is I2C and which is SPI by their UUID, each of which has a secondary service which is the NUS service, and in that case you don't even need to change UUIDs, you have two NUS services, one for each data channel.

    Either way, please don't shoehorn defined services like IAS into doing other things, when peripherals connect to such services, they expect them to mean what they are defined to mean, not be a transport for random data.

  • I agree with RK on all the above. You can learn to create your own custom service by following tutorials found on the tutorials page. Start with the advertising and service tutorial. The quickest way is of course to just use NUS for both.

  • Ok, thanks for the answer, I'll try to make the two instances of the NUS service then, it seems easier to me.

  • I already created the 2 instances of the NUS service, one for SPI and one for I2C, do I need to create two different NUS_BASE_UUID or just two different BLE_UUID_NUS_SERVICE?

    Or I'm totally off on making the two instances?

  • Either works - having a different NUS SERVICE id is easiest as you don't need to register a new base.

Related