This is an example of BLE GATT Client, which receives broadcast data from BLE_Server_BME280 ( a GATT server) , then transfers values up to mbed Device Connector (cloud).
Please refer details about BLEClient_mbedDevConn below. https://github.com/soramame21/BLEClient_mbedDevConn
The location of required BLE GATT server, BLE_Server_BME280, is at here. https://developer.mbed.org/users/edamame22/code/BLE_Server_BME280/
pal/Docs/html/dynsections.js@2:b894b3508057, 2017-09-05 (annotated)
- Committer:
- Ren Boting
- Date:
- Tue Sep 05 11:56:13 2017 +0900
- Revision:
- 2:b894b3508057
- Parent:
- 0:29983394c6b6
Update all libraries and reform main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
edamame22 | 0:29983394c6b6 | 1 | function toggleVisibility(linkObj) |
edamame22 | 0:29983394c6b6 | 2 | { |
edamame22 | 0:29983394c6b6 | 3 | var base = $(linkObj).attr('id'); |
edamame22 | 0:29983394c6b6 | 4 | var summary = $('#'+base+'-summary'); |
edamame22 | 0:29983394c6b6 | 5 | var content = $('#'+base+'-content'); |
edamame22 | 0:29983394c6b6 | 6 | var trigger = $('#'+base+'-trigger'); |
edamame22 | 0:29983394c6b6 | 7 | var src=$(trigger).attr('src'); |
edamame22 | 0:29983394c6b6 | 8 | if (content.is(':visible')===true) { |
edamame22 | 0:29983394c6b6 | 9 | content.hide(); |
edamame22 | 0:29983394c6b6 | 10 | summary.show(); |
edamame22 | 0:29983394c6b6 | 11 | $(linkObj).addClass('closed').removeClass('opened'); |
edamame22 | 0:29983394c6b6 | 12 | $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); |
edamame22 | 0:29983394c6b6 | 13 | } else { |
edamame22 | 0:29983394c6b6 | 14 | content.show(); |
edamame22 | 0:29983394c6b6 | 15 | summary.hide(); |
edamame22 | 0:29983394c6b6 | 16 | $(linkObj).removeClass('closed').addClass('opened'); |
edamame22 | 0:29983394c6b6 | 17 | $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); |
edamame22 | 0:29983394c6b6 | 18 | } |
edamame22 | 0:29983394c6b6 | 19 | return false; |
edamame22 | 0:29983394c6b6 | 20 | } |
edamame22 | 0:29983394c6b6 | 21 | |
edamame22 | 0:29983394c6b6 | 22 | function updateStripes() |
edamame22 | 0:29983394c6b6 | 23 | { |
edamame22 | 0:29983394c6b6 | 24 | $('table.directory tr'). |
edamame22 | 0:29983394c6b6 | 25 | removeClass('even').filter(':visible:even').addClass('even'); |
edamame22 | 0:29983394c6b6 | 26 | } |
edamame22 | 0:29983394c6b6 | 27 | |
edamame22 | 0:29983394c6b6 | 28 | function toggleLevel(level) |
edamame22 | 0:29983394c6b6 | 29 | { |
edamame22 | 0:29983394c6b6 | 30 | $('table.directory tr').each(function() { |
edamame22 | 0:29983394c6b6 | 31 | var l = this.id.split('_').length-1; |
edamame22 | 0:29983394c6b6 | 32 | var i = $('#img'+this.id.substring(3)); |
edamame22 | 0:29983394c6b6 | 33 | var a = $('#arr'+this.id.substring(3)); |
edamame22 | 0:29983394c6b6 | 34 | if (l<level+1) { |
edamame22 | 0:29983394c6b6 | 35 | i.removeClass('iconfopen iconfclosed').addClass('iconfopen'); |
edamame22 | 0:29983394c6b6 | 36 | a.html('▼'); |
edamame22 | 0:29983394c6b6 | 37 | $(this).show(); |
edamame22 | 0:29983394c6b6 | 38 | } else if (l==level+1) { |
edamame22 | 0:29983394c6b6 | 39 | i.removeClass('iconfclosed iconfopen').addClass('iconfclosed'); |
edamame22 | 0:29983394c6b6 | 40 | a.html('►'); |
edamame22 | 0:29983394c6b6 | 41 | $(this).show(); |
edamame22 | 0:29983394c6b6 | 42 | } else { |
edamame22 | 0:29983394c6b6 | 43 | $(this).hide(); |
edamame22 | 0:29983394c6b6 | 44 | } |
edamame22 | 0:29983394c6b6 | 45 | }); |
edamame22 | 0:29983394c6b6 | 46 | updateStripes(); |
edamame22 | 0:29983394c6b6 | 47 | } |
edamame22 | 0:29983394c6b6 | 48 | |
edamame22 | 0:29983394c6b6 | 49 | function toggleFolder(id) |
edamame22 | 0:29983394c6b6 | 50 | { |
edamame22 | 0:29983394c6b6 | 51 | // the clicked row |
edamame22 | 0:29983394c6b6 | 52 | var currentRow = $('#row_'+id); |
edamame22 | 0:29983394c6b6 | 53 | |
edamame22 | 0:29983394c6b6 | 54 | // all rows after the clicked row |
edamame22 | 0:29983394c6b6 | 55 | var rows = currentRow.nextAll("tr"); |
edamame22 | 0:29983394c6b6 | 56 | |
edamame22 | 0:29983394c6b6 | 57 | var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub |
edamame22 | 0:29983394c6b6 | 58 | |
edamame22 | 0:29983394c6b6 | 59 | // only match elements AFTER this one (can't hide elements before) |
edamame22 | 0:29983394c6b6 | 60 | var childRows = rows.filter(function() { return this.id.match(re); }); |
edamame22 | 0:29983394c6b6 | 61 | |
edamame22 | 0:29983394c6b6 | 62 | // first row is visible we are HIDING |
edamame22 | 0:29983394c6b6 | 63 | if (childRows.filter(':first').is(':visible')===true) { |
edamame22 | 0:29983394c6b6 | 64 | // replace down arrow by right arrow for current row |
edamame22 | 0:29983394c6b6 | 65 | var currentRowSpans = currentRow.find("span"); |
edamame22 | 0:29983394c6b6 | 66 | currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
edamame22 | 0:29983394c6b6 | 67 | currentRowSpans.filter(".arrow").html('►'); |
edamame22 | 0:29983394c6b6 | 68 | rows.filter("[id^=row_"+id+"]").hide(); // hide all children |
edamame22 | 0:29983394c6b6 | 69 | } else { // we are SHOWING |
edamame22 | 0:29983394c6b6 | 70 | // replace right arrow by down arrow for current row |
edamame22 | 0:29983394c6b6 | 71 | var currentRowSpans = currentRow.find("span"); |
edamame22 | 0:29983394c6b6 | 72 | currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen"); |
edamame22 | 0:29983394c6b6 | 73 | currentRowSpans.filter(".arrow").html('▼'); |
edamame22 | 0:29983394c6b6 | 74 | // replace down arrows by right arrows for child rows |
edamame22 | 0:29983394c6b6 | 75 | var childRowsSpans = childRows.find("span"); |
edamame22 | 0:29983394c6b6 | 76 | childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed"); |
edamame22 | 0:29983394c6b6 | 77 | childRowsSpans.filter(".arrow").html('►'); |
edamame22 | 0:29983394c6b6 | 78 | childRows.show(); //show all children |
edamame22 | 0:29983394c6b6 | 79 | } |
edamame22 | 0:29983394c6b6 | 80 | updateStripes(); |
edamame22 | 0:29983394c6b6 | 81 | } |
edamame22 | 0:29983394c6b6 | 82 | |
edamame22 | 0:29983394c6b6 | 83 | |
edamame22 | 0:29983394c6b6 | 84 | function toggleInherit(id) |
edamame22 | 0:29983394c6b6 | 85 | { |
edamame22 | 0:29983394c6b6 | 86 | var rows = $('tr.inherit.'+id); |
edamame22 | 0:29983394c6b6 | 87 | var img = $('tr.inherit_header.'+id+' img'); |
edamame22 | 0:29983394c6b6 | 88 | var src = $(img).attr('src'); |
edamame22 | 0:29983394c6b6 | 89 | if (rows.filter(':first').is(':visible')===true) { |
edamame22 | 0:29983394c6b6 | 90 | rows.css('display','none'); |
edamame22 | 0:29983394c6b6 | 91 | $(img).attr('src',src.substring(0,src.length-8)+'closed.png'); |
edamame22 | 0:29983394c6b6 | 92 | } else { |
edamame22 | 0:29983394c6b6 | 93 | rows.css('display','table-row'); // using show() causes jump in firefox |
edamame22 | 0:29983394c6b6 | 94 | $(img).attr('src',src.substring(0,src.length-10)+'open.png'); |
edamame22 | 0:29983394c6b6 | 95 | } |
edamame22 | 0:29983394c6b6 | 96 | } |
edamame22 | 0:29983394c6b6 | 97 |