115 OBJ_PROP_DELETE = 1u << 0,
116 OBJ_PROP_EXECUTE = 1u << 1,
117 OBJ_PROP_READ = 1u << 2,
118 OBJ_PROP_WRITE = 1u << 3,
119 OBJ_PROP_APPEND = 1u << 4,
120 OBJ_PROP_TRUNC = 1u << 5,
121 OBJ_PROP_PATCH = 1u << 6,
122 OBJ_PROP_MARKED = 1u << 7
129 OACP_OP_CREATE = 0x01,
130 OACP_OP_DELETE = 0x02,
132 OACP_OP_EXECUTE = 0x05,
133 OACP_OP_WRITE = 0x06,
134 OACP_OP_ABORT = 0x07,
135 OACP_OP_RESPONSE = 0x60
142 OACP_RES_SUCCESS = 0x01,
144 OACP_RES_INVALID_PARAM = 0x03,
145 OACP_RES_INSUF_RES = 0x04,
146 OACP_RES_INVALID_OBJ = 0x05,
147 OACP_RES_CHANNEL_UNAVAIL = 0x06,
148 OACP_RES_PROC_NOT_PERM = 0x07,
149 OACP_RES_OBJ_LOCKED = 0x08,
150 OACP_RES_OPER_FAILED = 0x0a
157 OLCP_OP_FIRST = 0x01,
159 OLCP_OP_PREVIOUS = 0x03,
162 OLCP_OP_ORDER = 0x06,
163 OLCP_OP_REQ_NUM = 0x07,
164 OLCP_OP_CLEAR_MK = 0x08,
165 OLCP_OP_RESPONSE = 0x70
172 OLCP_RES_SUCCESS = 0x01,
173 OLCP_RES_OPCODE_NS = 0x02,
174 OLCP_RES_INVALID_PARAM = 0x03,
175 OLCP_RES_OPER_FAILED = 0x04,
177 OLCP_RES_NO_OBJECT = 0x06,
178 OLCP_RES_OBJECT_ID_NF = 0x07
185 PRPH_OTS_TYPE_FILE = 0,
186 PRPH_OTS_TYPE_DESCRIPTOR = 1,
187 PRPH_OTS_TYPE_CAPS = 2
194 PRPH_OTS_ACCESS_READ = 0,
195 PRPH_OTS_ACCESS_WRITE = 1,
196 PRPH_OTS_ACCESS_RW = 2
202 constexpr static uint8_t CFG_TYPE_MASK = 0xf;
203 constexpr static uint8_t CFG_ACCESS_SHIFT = 4;
204 constexpr static uint8_t CFG_ACCESS_MASK = 0x3;
246 int start()
override;
252 struct SOtsObjectMeta
269 struct ble_l2cap_chan *chan;
281 static constexpr uint8_t MODE_IDLE = 0;
282 static constexpr uint8_t MODE_READING = 1;
283 static constexpr uint8_t MODE_WRITING = 2;
287 struct ble_gatt_svc_def svc;
288 struct ble_gatt_chr_def *chrs;
292 std::vector<SOtsObjectMeta> vmeta;
293 std::map<uint16_t, SOtsConnState> vconn;
295 void configureDesc(
const SObjectCfg::SObjectCfgItem *item);
296 void allocObject(
const SProtoNimblePrphIOBindOtsObjid &entry);
300 int setChrDef(
size_t idx,
302 ble_gatt_access_fn *cb_,
304 uint16_t *valHandle);
308 static int featureCb(uint16_t conn_handle,
309 uint16_t attr_handle,
310 struct ble_gatt_access_ctxt *ctxt,
313 static int nameCb(uint16_t conn_handle,
314 uint16_t attr_handle,
315 struct ble_gatt_access_ctxt *ctxt,
318 static int typeCb(uint16_t conn_handle,
319 uint16_t attr_handle,
320 struct ble_gatt_access_ctxt *ctxt,
323 static int sizeCb(uint16_t conn_handle,
324 uint16_t attr_handle,
325 struct ble_gatt_access_ctxt *ctxt,
328 static int idCb(uint16_t conn_handle,
329 uint16_t attr_handle,
330 struct ble_gatt_access_ctxt *ctxt,
333 static int propsCb(uint16_t conn_handle,
334 uint16_t attr_handle,
335 struct ble_gatt_access_ctxt *ctxt,
338 static int oacpCb(uint16_t conn_handle,
339 uint16_t attr_handle,
340 struct ble_gatt_access_ctxt *ctxt,
343 static int olcpCb(uint16_t conn_handle,
344 uint16_t attr_handle,
345 struct ble_gatt_access_ctxt *ctxt,
350 static int l2capEventCb(
struct ble_l2cap_event *event,
void *arg);
351 void onL2capRx(
struct ble_l2cap_event *event);
355 int handleOacpRead(uint16_t conn, uint32_t off, uint32_t len);
356 int handleOacpWrite(uint16_t conn, uint32_t off, uint32_t len, uint8_t mode);
357 int handleOacpAbort(uint16_t conn);
358 uint8_t oacpValidate(uint16_t conn,
bool wantWrite, SOtsConnState *&st, CIOCommon *&io);
360 int handleOlcpFirst(uint16_t conn);
361 int handleOlcpLast(uint16_t conn);
362 int handleOlcpPrev(uint16_t conn);
363 int handleOlcpNext(uint16_t conn);
364 int handleOlcpGoto(uint16_t conn, uint64_t obj_id);
365 int olcpSeekAbs(uint16_t conn, uint8_t op,
size_t idx);
366 int olcpStep(uint16_t conn, uint8_t op,
int delta);
370 void sendCpResponse(uint16_t conn,
375 void sendOacpResponse(uint16_t conn, uint8_t req_op, uint8_t result);
376 void sendOlcpResponse(uint16_t conn, uint8_t req_op, uint8_t result);
378 static int metaPrologue(uint16_t conn,
379 ble_gatt_access_ctxt *ctxt,
381 CProtoNimblePrphOts **self,
382 SOtsObjectMeta **meta,
384 int pumpRead(uint16_t conn);
385 bool selected(uint16_t conn, SOtsConnState *&state, SOtsObjectMeta *&meta);
387 static uint8_t cfgGetType(uint32_t cfg)
392 static uint8_t cfgGetAccess(uint32_t cfg)
394 return (cfg >> CFG_ACCESS_SHIFT) & CFG_ACCESS_MASK;
397 static uint32_t cfgPack(uint8_t type, uint8_t access)
400 ((access & CFG_ACCESS_MASK) << CFG_ACCESS_SHIFT);