map_client_text: proof of concept, msg notification server

This commit is contained in:
Milanka Ringwald 2019-03-20 09:22:18 +01:00
parent 3eb02ce6c7
commit ebb2715c2c

View File

@ -60,6 +60,7 @@
#include "btstack_event.h"
#include "bluetooth_sdp.h"
#include "classic/goep_client.h"
#include "classic/obex.h"
#include "map_client.h"
#include "map_server.h"
#include "classic/sdp_client.h"
@ -70,6 +71,8 @@
#include "btstack_stdin.h"
#endif
static const uint8_t map_client_notification_service_uuid[] = {0xbb, 0x58, 0x2b, 0x41, 0x42, 0xc, 0x11, 0xdb, 0xb0, 0xde, 0x8, 0x0, 0x20, 0xc, 0x9a, 0x66};
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
static bd_addr_t remote_addr;
@ -145,6 +148,39 @@ static void stdin_process(char c){
}
}
static void obex_server_success_response(uint16_t rfcomm_cid){
uint8_t event[30];
int pos = 0;
event[pos++] = OBEX_RESP_SUCCESS;
// store len
pos += 2;
// obex version num
event[pos++] = OBEX_VERSION;
// flags
// Bit 0 should be used by the receiving client to decide how to multiplex operations
// to the server (should it desire to do so). If the bit is 0 the client should serialize
// the operations over a single TTP connection. If the bit is set the client is free to
// establish multiple TTP connections to the server and concurrently exchange its objects.
event[pos++] = 0;
// Maximum OBEX packet length
big_endian_store_16(event, pos, 0x0400);
pos += 2;
event[pos++] = OBEX_HEADER_CONNECTION_ID;
big_endian_store_32(event, pos, 0x1234);
pos += 4;
event[pos++] = OBEX_HEADER_WHO;
big_endian_store_16(event, pos, 16 + 3);
pos += 2;
memcpy(event+pos, map_client_notification_service_uuid, 16);
pos += 16;
big_endian_store_16(event, 1, pos);
rfcomm_send(rfcomm_cid, event, pos);
}
// packet handler for interactive console
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(channel);
@ -216,7 +252,8 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
for (i=0;i<size;i++){
printf("%02x ", packet[i]);
}
printf("'\n");
printf("'\n");
obex_server_success_response(rfcomm_channel_id);
break;
case MAP_DATA_PACKET: