}
#ifdef WITH_PRESENCE
- //TODO: Add other connectivity types to CAConnTypes[] when enabled
- CATransportAdapter_t CAConnTypes[] = {CA_ADAPTER_IP};
- const char * connTypes[] = {"IP"};
+ CATransportAdapter_t CAConnTypes[] = {CA_ADAPTER_IP, CA_ADAPTER_GATT_BTLE,
+ CA_ADAPTER_RFCOMM_BTEDR};
+ const char * connTypes[] = {"ip" , "ble", "edr"};
int size = sizeof(CAConnTypes)/ sizeof(CATransportAdapter_t);
CATransportAdapter_t adapter = responseEndpoint.adapter;
CAResult_t caResult = CA_STATUS_FAILED;
// processs url prefix, if any
size_t urlLen = slash - start;
+ // port
+ uint16_t port = 0;
+ size_t len = 0;
if (urlLen && devAddr)
{ // construct OCDevAddr
- if (start[0] == '[')
- { // ipv6 address
- char *close = strchr(++start, ']');
- if (!close || close > slash)
+ if (OC_ADAPTER_IP == adapter)
+ {
+ if (start[0] == '[')
+ { // ipv6 address
+ char *close = strchr(++start, ']');
+ if (!close || close > slash)
+ {
+ return OC_STACK_INVALID_URI;
+ }
+ end = close;
+ if (close[1] == ':')
+ {
+ colon = close + 1;
+ }
+ }
+ else
+ { // ipv4 address
+ end = slash;
+ colon = strchr(start, ':');
+ end = (colon && colon < slash) ? colon : slash;
+ }
+ len = end - start;
+ if (len >= sizeof(da->addr))
{
return OC_STACK_INVALID_URI;
}
- end = close;
- if (close[1] == ':')
+ // use standard multicast port
+ if (colon && colon < slash)
{
- colon = close + 1;
+ for (colon++; colon < slash; colon++)
+ {
+ char c = colon[0];
+ if (c < '0' || c > '9')
+ {
+ return OC_STACK_INVALID_URI;
+ }
+ port = 10 * port + c - '0';
+ }
}
}
else
- { // ipv4 address
+ {
+ /**
+ * This is for Non-IP adapters(EDR and BLE).
+ * The address will be between "//" and "/" in the request URI.
+ * [Ex. coap://AB:BC:CD:DE:EF:FG/resource_uri]
+ */
end = slash;
- colon = strchr(start, ':');
- end = (colon && colon < slash) ? colon : slash;
}
- size_t len = end - start;
+
+ len = end - start;
if (len >= sizeof(da->addr))
{
return OC_STACK_INVALID_URI;
}
- // port
- uint16_t port = 0; // use standard multicast port
- if (colon && colon < slash)
- {
- for (colon++; colon < slash; colon++)
- {
- char c = colon[0];
- if (c < '0' || c > '9')
- {
- return OC_STACK_INVALID_URI;
- }
- port = 10 * port + c - '0';
- }
- }
-
da = (OCDevAddr *)OICCalloc(sizeof (OCDevAddr), 1);
if (!da)
{