Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

BIG RESTful Smart Server Demo

BIG RESTful Smart Server Demo

JaeyoungY_71
Employee
Employee
First comment on KBA 25 solutions authored 10 solutions authored

<BIG RESTful Smart Server Demo>

 

The RESTful Smart server implements the Bluetooth Internet Gateway(BIG), and is the successor of SmartBridge. It allows you to connect to the WICED device through WiFi and then connect to peripherals through BLE. You can issue http get/put requests to scan/connect/read and write characteristic and descriptor values from ble peripherals through WICED devices.

 

Below is a guide on how to use the RESTful Smart Server with curl commands. You can also use RESTful clients for a gui environment. The http requests will be the same. Note that results with REST clients may vary, you will get the best results with using curl commands in Cygwin. When using REST clients, be sure to always include “user-Agent: curl/7.37.1”.

 

The ble peripherals used for testing are WICED Sense kits, hello_sensor app loaded on a BCM920737 (TAG 4), and iOS LightBlue peripherals. If you do not have any physical peripheral devices available for testing you can download the Light Blue app in iOS to generate virtual peripheral devices. Make sure that your iOS device screen does not time out as that may disconnect the bluetooth connections. In the case that data gets corrupted and you are not getting the right JSON response, try reconnecting or resetting the peripheral.

 

- For BCM943909WCD1 / BCM943341WCD1 / BCM943438 REFAD

- See attached files for GAP and GATT API spec sheets for the format of the RESTful API.

 

- REST Client For Mac

    https://luckymarmot.com/paw

- REST Client For Windows

    http://www.swensensoftware.com/im-only-resting

- Installing Curl on Cygwin

    http://stackoverflow.com/questions/3647569/how-do-i-install-curl-on-cygwin

 

 

<SETUP>

 

1. Change the network SSID and password to match your network in /apps/demo/bt_internet_gateway/restful_smart_server/wifi_config_dct.h

  ssid.PNG

 

2. Compile and download with target demo.bt_internet_gateway.restful_smart_server-<PLATFORM> download run

smart_server.PNG

 

3. Open a terminal (PuTTY/TeraTerm/CoolTerm) to check the serial output. Once the device has downloaded and reset, it will connect to the network and set up the smart server automatically. You can access the server using the address it was assigned.

  smart_screen.PNG

 

4. Turn on some ble peripherals and use the curl commands below on your PC or use REST clients to scan/connect/read/write data. If you set up a local network for testing be sure to connect to the same network from your PC.

 

**When accessing services or characteristics, be sure to use the full hex value in the last part of the "self" "href" field.

 

**You will need to use GAP API to scan and connect to the device, then GATT API to access the data

 

<GAP Commands>

  • Active Scan
    • curl -v -X GET "http://<IP>/gap/nodes?active=1"
  • Passive Scan:
    • curl -v -X GET "http://<IP>/gap/nodes?passive=1"
  • Connect
    • curl -v -X PUT "http://<IP>/gap/nodes/<NODE_HANDLE>?connect=1&enable=1"
  • List Available Connect Nodes
    • curl -v -X GET "http://<IP>/gap/nodes?enable=1"
  • Remove Node
    • curl -v -X PUT "http://<IP>/gap/nodes/<NODE_HANDLE>?enable=0"

 

<GATT Commands>

  • Discover Primary Services
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/services?primary=1"
  • Discover Services by UUID
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/services?primary=1&uuid=<UUID>"
  • Discover All Characteristics of a Service
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/services/<SERVICE_REF>/characteristics"
  • Discover Characteristic by UUID
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/characteristics?uuid=<UUID>"
  • Discover Descriptors
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/characteristics/<CHARACTERISTIC_REF>/descriptors"
  • Read Characteristic Value
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/characteristics/<CHARACTERISTIC_REF>/value"
  • Write Characteristic Value
    • curl -v -X PUT "http://<IP>/gatt/nodes/<NODE_HANDLE>/characteristics/<CHARACTERISTIC_REF>/value/<VALUE>"
  • Read Descriptor Value
    • curl -v -X GET "http://<IP>/gatt/nodes/<NODE_HANDLE>/descriptors/<DESCRIPTOR_HANDLE>/value"
  • Write Descriptor Value
    • curl -v -X PUT "http://<IP>/gatt/nodes/<NODE_HANDLE>/descriptors/<DESCRIPTOR_HANDLE>/value/<VALUE>"

 

 

restful1.png

restful2.png

restful3.png

restful4.png

restful5.png

1403 Views
Comments
Anonymous
Not applicable

Hello,

I am not able to read/write into the characteristic value.

$ curl -v -X GET "http://172.20.10.8/gatt/nodes/00A050E169200/characteristics/000E000E000D/value"

Note: Unnecessary use of -X or --request, GET is already inferred.

* STATE: INIT => CONNECT handle 0x6000577d0; line 1103 (connection #-5000)

* Added connection 0. The cache now contains 1 members

*   Trying 172.20.10.8...

* STATE: CONNECT => WAITCONNECT handle 0x6000577d0; line 1156 (connection #0)

* Connected to 172.20.10.8 (172.20.10.8) port 80 (#0)

* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x6000577d0; line 1253 (connection #0)

* STATE: SENDPROTOCONNECT => DO handle 0x6000577d0; line 1271 (connection #0)

> GET /gatt/nodes/00A050E169200/characteristics/000E000E000D/value HTTP/1.1

> Host: 172.20.10.8

> User-Agent: curl/7.47.1

> Accept: */*

>

* STATE: DO => DO_DONE handle 0x6000577d0; line 1350 (connection #0)

* STATE: DO_DONE => WAITPERFORM handle 0x6000577d0; line 1477 (connection #0)

* STATE: WAITPERFORM => PERFORM handle 0x6000577d0; line 1487 (connection #0)

* HTTP 1.1 or later with persistent connection, pipelining supported

< HTTP/1.1 404 Not Found

< Content-Type: application/json

< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

< Pragma: no-cache

< Connection: Keep-Alive

< Transfer-Encoding: chunked

<

* STATE: PERFORM => DONE handle 0x6000577d0; line 1645 (connection #0)

* Curl_done

* Connection #0 to host 172.20.10.8 left intact

* Expire cleared

Anyone able to read and write into characteristic value. I am just trying to run a standard FIND ME profile.

VikramR_26
Employee
Employee
25 sign-ins 10 sign-ins 10 comments on KBA

Presently there is an issue with characteristics that have notify property, you are not able read/write since this feature is yet to be implemented.