<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