0Pricing
Arduino & IoT Academy · درس

قراءة Characteristics وكتابتها

تبادل القيم عبر سمات BLE.

قراءة Characteristics وكتابتها درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Where the Data Lives

A service is a folder, but the real values live inside characteristics. These are the slots a phone actually reads and writes. 📦

Characteristics Have UUIDs Too

Like services, every characteristic carries its own UUID. The phone uses it to target one exact value, such as temperature.

Create One

You build a characteristic on a service and declare what it allows: reading, writing, or both. Properties decide who can do what.

auto c = svc->createCharacteristic(uuid,
  BLECharacteristic::PROPERTY_READ);

Properties Set Permissions

Use PROPERTY_READ for values the phone fetches, and PROPERTY_WRITE for ones it sends back. Combine them when both directions matter.

Set a Value to Read

Your sketch stores the current data with setValue. When the phone reads, it gets exactly whatever you placed there last.

c->setValue("23.5");

The Phone Writes Back

For a writable characteristic, the phone can push a value to your board. Your code reads it with getValue to learn what arrived.

std::string in = c->getValue();

React with a Callback

To respond the instant a write happens, attach a callback. Its onWrite method fires automatically whenever the phone sends data.

Notify Instead of Polling

With notify, your board pushes new values the moment they change. The phone gets fresh data without asking again and again.

c->setValue(temp);
c->notify();

Values Are Just Bytes

BLE sends raw bytes, not numbers. Send text like 23.5 or pack the number yourself, then unpack it on the phone side.

Keep Packets Small

A default BLE write fits about twenty bytes. Keep each characteristic focused on one small value rather than a giant blob.

Read, Write, Notify

Those three jobs cover almost every project. Read shares state, write accepts commands, and notify streams live updates.

Quick Check

You want the phone to get new readings the instant they change.

Recap

Characteristics hold the data: set properties for read, write, or notify, store values, and let callbacks react to incoming writes. 🚀

الأسئلة الشائعة

هل درس «قراءة Characteristics وكتابتها» مجاني؟

نعم — نص درس «قراءة Characteristics وكتابتها» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.

ماذا ستتعلم في «قراءة Characteristics وكتابتها»؟

تبادل القيم عبر سمات BLE. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟

لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «قراءة Characteristics وكتابتها»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟

نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. Bluetooth الكلاسيكي مقابل BLE
  2. الإعلان عن خدمة BLE
  3. قراءة Characteristics وكتابتها
  4. التحكم في LED من تطبيق هاتف
← العودة إلى Arduino & IoT Academy