diff --git a/README.md b/README.md index 145f426e..0daa7d40 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,5 @@ Scanning ... 00:12:6F:33:C9:FE Cabasse Stream Source 98:D3:35:00:A6:1C HC-05 ``` + +https://askubuntu.com/questions/248817/how-to-i-connect-a-raw-serial-terminal-to-a-bluetooth-connection \ No newline at end of file diff --git a/bsp/board/domo/ovl/etc/init.d/uhttpd b/bsp/board/domo/ovl/etc/init.d/uhttpd index 02a8bfb2..60dda340 100755 --- a/bsp/board/domo/ovl/etc/init.d/uhttpd +++ b/bsp/board/domo/ovl/etc/init.d/uhttpd @@ -18,7 +18,7 @@ USE_PROCD=1 start_service () { procd_open_instance - procd_set_param command "$PROG" -p $PORT -f -h /usr/local/share/uhttpd/ -U /usr/local/configs/uhttpd/ + procd_set_param command "$PROG" -p $PORT -f -h /usr/local/share/uhttpd/ -U /usr/local/configs/uhttpd/ -u /usr/local/bin/plugins/ procd_set_param pidfile "$PIDFILE" procd_set_param respawn procd_set_param stdout 1 # forward stdout of the command to logd diff --git a/src/3P/uhttpd/main.c b/src/3P/uhttpd/main.c index ecf8944b..d0aa7c51 100644 --- a/src/3P/uhttpd/main.c +++ b/src/3P/uhttpd/main.c @@ -444,7 +444,7 @@ int main(int argc, char **argv) break; #else case 'a': - case 'u': + //case 'u': //case 'U': case 'X': fprintf(stderr, "uhttpd: UBUS support not compiled, " @@ -456,7 +456,7 @@ int main(int argc, char **argv) conf.ubus_prefix = optarg; break; case 'u': - conf.ubus_prefix = optarg; + conf.lua_prefix = optarg; break; #endif default: @@ -509,7 +509,8 @@ int main(int argc, char **argv) return 1; #endif #ifdef HAVE_REST_API_PLUGING - if (uh_plugin_init("uhttpd_rest-api-plugin.so")) + snprintf(uh_buf, 4096, "%s/uhttpd_rest-api-plugin.so", conf.lua_prefix); + if (uh_plugin_init(uh_buf)) return 1; #endif /* fork (if not disabled) */ diff --git a/src/prog/dashboard3/README.md b/src/prog/dashboard3/README.md index e691b9d3..f8366c6c 100644 --- a/src/prog/dashboard3/README.md +++ b/src/prog/dashboard3/README.md @@ -27,4 +27,7 @@ export default { } ## example .... -https://appdividend.com/2018/05/08/vuex-axios-get-request-tutorial-with-example/ \ No newline at end of file + +a suivre !!!!=> + +https://appdividend.com/2018/05/08/vuex-axios-get-request-tutorial-with-example/ diff --git a/src/prog/dashboard3/src/api/domo.js b/src/prog/dashboard3/src/api/domo.js new file mode 100644 index 00000000..e42fcf29 --- /dev/null +++ b/src/prog/dashboard3/src/api/domo.js @@ -0,0 +1,76 @@ +import axios from 'axios' + +/* + * Make the Request and call onSuccess method on the call back object. + */ + +export default { + + request (route, data = null) { + // console.log('data:', data) + return new Promise((resolve, reject) => { + axios({ + method: route.method, + url: this.server + route.url, + timeout: this.timeout, + data: data + }).then((response) => { + // console.log('response...') + resolve(response) + }).catch((error) => { + console.log(error) + reject(error) + }) + }) + }, + etag_request (route, version, data = null) { + return new Promise((resolve, reject) => { + axios({ + method: route.method, + url: this.server + route.url, + headers: { 'If-None-Match': version, 'Prefer': 'wait=' + this.etag_timeout }, + timeout: this.timeout * 30, + data: data + }).then((response) => { + // console.log('response...', response) + if (response.status === 200) { + resolve(response.data) + } else if (response.status === 204) { + reject(response) + } else if (response.status === 412) { + reject(response) + } + }).catch((error) => { + if (error.response) { + // console.log('request error: ', error.response) + reject(error.response) + } else { + reject(error) + } + }) + }) + }, + // server: '', + server: 'http://192.168.1.129:8080', + timeout: 1000, + etag_timeout: 10, + route: { + /* + * The route tree for the network APIs. + */ + v1: { + outlets: { + }, + sequences: { + }, + shutters: { + }, + sprinklers: { + get: { + url: '/v1/sprinklers', + method: 'get' + } + } + } + } +} diff --git a/src/prog/dashboard3/src/pages/sprinklers.vue b/src/prog/dashboard3/src/pages/sprinklers.vue index c3680bff..5e718328 100644 --- a/src/prog/dashboard3/src/pages/sprinklers.vue +++ b/src/prog/dashboard3/src/pages/sprinklers.vue @@ -3,14 +3,14 @@ Sprinklers - + - + - + - + diff --git a/src/prog/dashboard3/src/store/index.js b/src/prog/dashboard3/src/store/index.js index 8d5181b0..f18cd134 100644 --- a/src/prog/dashboard3/src/store/index.js +++ b/src/prog/dashboard3/src/store/index.js @@ -1,17 +1,19 @@ import Vue from 'vue' import Vuex from 'vuex' -import axios from 'axios' -import VueAxios from 'vue-axios' import domoStore from './domo-store' +import sprinklers from './modules/sprinklers' Vue.use(Vuex) -Vue.use(VueAxios, axios) + +const debug = process.env.NODE_ENV !== 'production' const store = new Vuex.Store({ modules: { - domoStore - } + domoStore, + sprinklers + }, + strict: debug }) export default store diff --git a/src/prog/dashboard3/src/store/modules/sprinklers.js b/src/prog/dashboard3/src/store/modules/sprinklers.js new file mode 100644 index 00000000..fd87915c --- /dev/null +++ b/src/prog/dashboard3/src/store/modules/sprinklers.js @@ -0,0 +1,119 @@ +import api from '../../api/domo' + +// initial state +// shape: [{ id, quantity }] +const state = { + sprinklers: [] +} + +// getters +const getters = { +/* + cartProducts: (state, getters, rootState) => { + return state.items.map(({ id, quantity }) => { + const product = rootState.products.all.find(product => product.id === id) + return { + title: product.title, + price: product.price, + quantity + } + }) + }, + + cartTotalPrice: (state, getters) => { + return getters.cartProducts.reduce((total, product) => { + return total + product.price * product.quantity + }, 0) + } + */ +} + +// actions +const actions = { + load ({ commit }) { + api.request(api.route.v1.sprinklers.get) + .then(data => { + console.log('on est la.', data) + commit('SET_SPRINKLERS', data.data.sprinklers) + }) + } +} +/* + axios + .get('http://localhost:4000/results') + .then(r => r.data) + .then(coins => { + commit('SET_COINS', coins) + }) + } + } +*/ + +/* + checkout ({ commit, state }, products) { + const savedCartItems = [...state.items] + commit('setCheckoutStatus', null) + // empty cart + commit('setCartItems', { items: [] }) + shop.buyProducts( + products, + () => commit('setCheckoutStatus', 'successful'), + () => { + commit('setCheckoutStatus', 'failed') + // rollback to the cart saved before sending the request + commit('setCartItems', { items: savedCartItems }) + } + ) + }, + + addProductToCart ({ state, commit }, product) { + commit('setCheckoutStatus', null) + if (product.inventory > 0) { + const cartItem = state.items.find(item => item.id === product.id) + if (!cartItem) { + commit('pushProductToCart', { id: product.id }) + } else { + commit('incrementItemQuantity', cartItem) + } + // remove 1 item from stock + commit('products/decrementProductInventory', { id: product.id }, { root: true }) + } + } +*/ + +// mutations +const mutations = { + SET_SPRINKLERS (state, sprinklers) { + console.log('sprinkler', sprinklers) + state.sprinklers = sprinklers + } +/* + pushProductToCart (state, { id }) { + state.items.push({ + id, + quantity: 1 + }) + }, + + incrementItemQuantity (state, { id }) { + const cartItem = state.items.find(item => item.id === id) + cartItem.quantity++ + }, + + setCartItems (state, { items }) { + state.items = items + }, + + setCheckoutStatus (state, status) { + state.checkoutStatus = status + } +*/ +} + +export default { + namespaced: true, + state, + getters, + actions, + mutations +}