This section provides a description
of how to use the demo application to connect two configured boards and communicate
over bluetooth. Bluetooth CSCP is a simple Client-Server connection process. We will
setup one of the boards as a Server and the other board as a Client. We will then
initiate a connection from the Client to the Server. Once connected, we can transmit
data between the two devices over bluetooth.
Server setup on the demo
application
- We will setup the first board as
a Server. Note the bluetooth address of the Server; we will later use this to
initiate a connection from the Client.Up to four commands are all that is needed
to setup the CSCS Server.
- The first command we need is
RegisterCSCS, this command will register the service and initiate the Server,
issue the RegisterCSCS command.
- In order to set the supported
features we issue the SetSupportedFeatures <Wheel Measurement Support>
<Crank Measurement Support> <Multiple Location Support>.Issue the SetSupportedFeatures 1 1 1 command to enable all
features, the terminal will display a note that indicates the we need to issue
the GetRemoteFeatures command in the Client's terminal.
- If Multiple Location is
supported, in order to set the supported sensor locations list we issue the
SetSupportedSensorLocationBitMask <BitMask> command, which is a
bitmask that will enable the supported locations in the Server.Issue the SetSupportedSensorLocationBitMask 0x7fff command to set
all the available locations in the list, the terminal will display that the
update was successful.
- Now, after we configured the
Server, we can begin advertising to nearby devices by issuing the AdvertiseLE
1 command.
Initiating connection from the ClientNote: Steps 1 and 2 are optional if you
already know the Bluetooth address of the device that you want to connect
to.
- The Client LE device can try to find which LE devices are in the vicinity by
issuing the StartScanning command.
- Once you have found the device,
you can stop scanning by issuing the StopScanning command.
- Retrieve the Bluetooth address of the first board that was configured as a
Server.
- Issue a ConnectLE <BD_ADDR of Server> command in the Client
terminal.
- When a Client successfully
connects to a Server, both the Client and Server will output
LE_Connection_Complete notification and information about the current
connection.Discovering and Configuring the Server
Now we have a connection
established and both devices are ready to send data to each other. Before
Cycle Speed and Cadence information can be sent we must first initialize
commands in the Client terminal.
- In order to discover The service
handles we issue the DiscoverCSCS command and the handles that are
discovered will be displayed in the terminal.
- After discovering the handles we need to discover the supported features of the
Server, so we issue the GetRemoteFeatures command, which will display the
supported features in the Client terminal.
- In order to enable Server
notifications, and if the SC Control Point exists also enable indications we
issue the ConfigureRemoteCSCS 1 command in the Client's terminal. If the
configuration succeeds information about the CCCD configuration will be
displayed in the Client and Server terminals.
Transferring Cycle Speed and Cadence InformationNow we have a connection
established and both devices configured and are ready to send data to each
other.
We can now notify from the Sensor (Jump to paragraph t) or we
can send SC Control Point Command to the sensor from the collector (next
paragraph).
In Client Terminal:
- When we make new connection
between collector and Sensor we need to Set the wheel circumference so the
collector will be able to calculate Instantaneous speed, so we issue the
SetWheelCircumference <Circumference> command to set the
circumference in cm. Type SetWheelCircumference 210 in order to set wheel
circumference of 210 cm.
- When we want to change data in
the sensor we can do it only from the collector by issuing the
SetSCControlPoint command. We can update the cumulative wheel
revolutions, the sensor location or retrieve a list of supported sensor
locations using this command. After each command the collector will receive a
response indication from the sensor.
- If we want, and only when we
support wheel revolutions, we can update the cumulative wheel revolutions using
the SC Control Point Command. To do so we issue the SetSCControlPoint 1
<Cumulative value to update> command, for example type
SetSCControlPoint 1 2000.
- If we want to change sensor
location, and only if we support multiple sensor location, we can change it only
to locations that the sensor supports. To see the supported locations list, we
issue the DisplayAvailableLocations command. If the list is empty we need
to retrieve it first, we will do so in the next paragraph. If the list isn't
empty jump to paragraph "p".
- In order to retrieve the sensor location list, and only when we supported
multiple sensor location, we need to use the set SC Control Point command which
retrieve the list, to do so we use SetSCControlPoint 3. Type SetSCControlPoint 3
and you will see the available sensor locations.
- You can see confirmation for the
command and the indication from the sensor that includes the list.
- After the collector has the
sensor supported list locations, the collector can update the sensor location
using SetSCControlPoint 2 and the number of the location from the list
that we want to update, type SetSCControlPoint 2 3.In Server Terminal:
- After we set new sensor location,
we can check it by issuing the Querylocation command and you will be able to see
the new location.
- Now, when we finish with all the
configurations and command the sensor can start notifying his measurements, in
order to do so, we issue the NotifyMeasurements command. When the sensor
support only wheel revolutions or crank revolutions you need to input 2
parameters, cumulative value, and time event value, when both are supported you
need to input 4 parameters wheel cumulative value, wheel time event value, crank
cumulative value and crank time event value.
- In this example wheel revolutions
and crank revolutions are supported. then type NotifyMeasurements 2008 64000
65534 9300, you will be able to see on the Client terminal the
parameters you entered.
- Server Terminal
- Client Terminal
- The Calculation for
instantaneous speed
Speed[cm/(s/1024)] = (Difference in two successive Cumulative Wheel
Revolution values * Wheel Circumference) / (Difference in two
successive Last Wheel Event Time values) In order to receive
Speed[km/h] we need to multiple the result with (3.6*1024/100) - The
Demo is doing the calculation for us when we use DISPLAY_DEBUG
definitions in the environment
- The Calculation for
instantaneous cadence
Cadence[r/(s/1024)] = (Difference in two successive Cumulative
Crank Revolution values) / (Difference in two successive Last Crank
Event Time values) In order to receive Cadence[rpm] we need to
multiple the result with (60*1024) - The Demo is doing the
calculation for us when we use DISPLAY_DEBUG definitions in the
environment
- When using debug mode, the
application will calculate the Instantaneous Speed and Instantaneous Cadence. In
order to do this calculation we need to send another notification. Type
NotifyMeasurements 2016 65024 65535 10324, now in the Client Terminal you can
see Instantaneous Speed [km/h] and Instantaneous Cadence [rpm].
- Server Terminal
- Client Terminal