8 # error This is a userspace-only header, not allowed by the current build.
11 #include <sifteo/abi.h>
68 if ((_SYS_getFeatures() & _SYS_FEATURE_BLUETOOTH) == 0) {
72 return _SYS_bt_isAvailable();
90 return _SYS_bt_isConnected();
117 _SYS_bt_advertiseState(bytes, length);
128 template <
typename T>
131 advertiseState(reinterpret_cast<const uint8_t*>(&
object),
sizeof object);
144 _SYSBluetoothPacket sys;
147 operator _SYSBluetoothPacket* () {
return &sys; }
148 operator const _SYSBluetoothPacket* ()
const {
return &sys; }
152 return _SYS_BT_PACKET_BYTES;
181 const uint8_t *
bytes()
const {
215 template <
unsigned tCapacity >
219 _SYSBluetoothQueueHeader header;
222 _SYSBluetoothPacket packets[tCapacity + 1];
226 operator _SYSBluetoothQueue* () {
return reinterpret_cast<_SYSBluetoothQueue*
>(&sys); }
227 operator const _SYSBluetoothQueue* ()
const {
return reinterpret_cast<const _SYSBluetoothQueue*
>(&sys); }
232 unsigned lastIndex = tCapacity;
238 sys.header32 = lastIndex << 16;
240 ASSERT(sys.header.head == 0);
241 ASSERT(sys.header.tail == 0);
242 ASSERT(sys.header.last == lastIndex);
257 unsigned size = tCapacity + 1;
258 unsigned head = sys.header.head;
259 unsigned tail = sys.header.tail;
262 return (tail - head) % size;
274 return tCapacity -
count();
307 unsigned head = sys.header.head;
308 ASSERT(head <= tCapacity);
321 unsigned head = sys.header.head + 1;
322 if (head > tCapacity)
324 sys.header.head = head;
336 _SYS_bt_queueReadHint();
370 unsigned tail = sys.header.tail;
371 ASSERT(tail <= tCapacity);
384 unsigned tail = sys.header.tail + 1;
385 if (tail > tCapacity)
387 sys.header.tail = tail;
400 _SYS_bt_queueWriteHint();
445 template <
unsigned tSendCapacity = 4,
unsigned tReceiveCapacity = 4 >
485 _SYS_bt_setPipe(0, 0);
550 _SYSBluetoothCounters current;
551 _SYSBluetoothCounters base;
560 _SYS_bt_counters(&base,
sizeof base);
567 _SYS_bt_counters(¤t,
sizeof current);
572 return current.rxPackets - base.rxPackets;
577 return current.txPackets - base.txPackets;
582 return current.rxBytes - base.rxBytes;
587 return current.txBytes - base.txBytes;
598 return current.rxUserDropped - base.rxUserDropped;