Doug Anson / mbedEndpointNetwork_BLE

Dependencies:   libnsdl_m0 BLE_API Base64 nRF51822 SplitterAssembler

Committer:
ansond
Date:
Tue Feb 17 02:56:36 2015 +0000
Revision:
6:98af441fd960
Parent:
5:9233e88b9c83
Child:
9:bf0cf5828378
updates still not working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 5:9233e88b9c83 1 /**
ansond 5:9233e88b9c83 2 * @file UartRPC.cpp
ansond 5:9233e88b9c83 3 * @brief BLE UART RPC implementation
ansond 5:9233e88b9c83 4 * @author Doug Anson
ansond 5:9233e88b9c83 5 * @version 1.0
ansond 5:9233e88b9c83 6 * @see
ansond 5:9233e88b9c83 7 *
ansond 5:9233e88b9c83 8 * Copyright (c) 2014
ansond 5:9233e88b9c83 9 *
ansond 5:9233e88b9c83 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 5:9233e88b9c83 11 * you may not use this file except in compliance with the License.
ansond 5:9233e88b9c83 12 * You may obtain a copy of the License at
ansond 5:9233e88b9c83 13 *
ansond 5:9233e88b9c83 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 5:9233e88b9c83 15 *
ansond 5:9233e88b9c83 16 * Unless required by applicable law or agreed to in writing, software
ansond 5:9233e88b9c83 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 5:9233e88b9c83 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 5:9233e88b9c83 19 * See the License for the specific language governing permissions and
ansond 5:9233e88b9c83 20 * limitations under the License.
ansond 5:9233e88b9c83 21 */
ansond 5:9233e88b9c83 22
ansond 5:9233e88b9c83 23 #include "UartRPC.h"
ansond 5:9233e88b9c83 24
ansond 5:9233e88b9c83 25 #include "Base64.h"
ansond 5:9233e88b9c83 26
ansond 5:9233e88b9c83 27 #ifdef DBG
ansond 5:9233e88b9c83 28 #undef DBG
ansond 5:9233e88b9c83 29 #endif
ansond 5:9233e88b9c83 30 #define DBG std::printf
ansond 5:9233e88b9c83 31
ansond 5:9233e88b9c83 32 // constructor
ansond 5:9233e88b9c83 33 UartRPC::UartRPC(BLEDevice &ble) : m_dispatcher(ble) {
ansond 5:9233e88b9c83 34 }
ansond 5:9233e88b9c83 35
ansond 5:9233e88b9c83 36 // dispatch RPC
ansond 6:98af441fd960 37 int UartRPC::dispatch(uint8_t fn_id,uint8_t *response,int response_length,const char *format,...)
ansond 5:9233e88b9c83 38 {
ansond 5:9233e88b9c83 39 // serialize the variable arguments into a long string...
ansond 5:9233e88b9c83 40 va_list args;
ansond 5:9233e88b9c83 41 uint8_t buffer[MAX_ARGUMENT_LENGTH+1];
ansond 5:9233e88b9c83 42 memset(buffer,0,sizeof(buffer));
ansond 5:9233e88b9c83 43 va_start(args, format);
ansond 5:9233e88b9c83 44 vsnprintf((char *)buffer,MAX_ARGUMENT_LENGTH,format,args);
ansond 5:9233e88b9c83 45 va_end(args);
ansond 5:9233e88b9c83 46
ansond 5:9233e88b9c83 47 // dispatch now...
ansond 5:9233e88b9c83 48 return this->m_dispatcher.dispatch(fn_id,buffer,strlen((char *)buffer),response,response_length);
ansond 5:9233e88b9c83 49 }