<?xml version="1.0" encoding="iso-8859-9" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Clomosy | Forum : MQTT ile veri tabanına kayıt ekleme</title>
  <link>https://forum.clomosy.com.tr/</link>
  <description><![CDATA[XML içerik linki; Clomosy | Forum : Genel &#304;&#351;lemler : MQTT ile veri tabanına kayıt ekleme]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Mon, 04 May 2026 10:53:10 +0000</pubDate>
  <lastBuildDate>Tue, 08 Jul 2025 13:44:04 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.07</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forum.clomosy.com.tr/RSS_post_feed.asp?TID=1064</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Clomosy | Forum]]></title>
   <url>https://forum.clomosy.com.tr/forum_images/logo.png</url>
   <link>https://forum.clomosy.com.tr/</link>
  </image>
  <item>
   <title><![CDATA[MQTT ile veri tabanına kayıt ekleme : Merhaba Mahmut,ParseAndApplyMQTTMessage...]]></title>
   <link>https://forum.clomosy.com.tr/forum_posts.asp?TID=1064&amp;PID=2139#2139</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="https://forum.clomosy.com.tr/member_profile.asp?PF=142">BilalCndn</a><br /><strong>Konu:</strong> 1064<br /><strong>Gönderim Zamanı:</strong> 08&nbsp;Temmuz&nbsp;2025 Saat 13:44<br /><br />Merhaba Mahmut,<div><br></div><div>ParseAndApplyMQTTMessage ile kompleks bir parse işlemi yapmışsın. Hatanın bu kısımda oluşabileceğini tahmin ediyorum. Bunun yerine CLParseJSON özelliğini kullanırsan çok daha kolay bir şekilde JSON parse yapabilirsin. Parçaladığın JSON içeriklerini tek tek ekrana yazdırarak hangi aşamada hatalı olduğunu tespit edebilirsin.</div><div><a href="https://www.docs.clomosy.com/index.php?title=CLParseJS&#079;N" target="_blank" rel="nofollow">https://www.docs.clomosy.com/index.php?title=CLParseJSON</a><br></div><div><br></div><div>İyi çalışmalar dilerim.</div>]]>
   </description>
   <pubDate>Tue, 08 Jul 2025 13:44:04 +0000</pubDate>
   <guid isPermaLink="true">https://forum.clomosy.com.tr/forum_posts.asp?TID=1064&amp;PID=2139#2139</guid>
  </item> 
  <item>
   <title><![CDATA[MQTT ile veri tabanına kayıt ekleme : Bir cihazdan kay&#305;t i&#351;lemi (&#246;rne&#287;in...]]></title>
   <link>https://forum.clomosy.com.tr/forum_posts.asp?TID=1064&amp;PID=2133#2133</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="https://forum.clomosy.com.tr/member_profile.asp?PF=307">Mahmutdmr</a><br /><strong>Konu:</strong> 1064<br /><strong>Gönderim Zamanı:</strong> 08&nbsp;Temmuz&nbsp;2025 Saat 10:35<br /><br /><div>Bir cihazdan kayıt işlemi (örneğin giriş/çıkış ya da kullanıcı ekleme) gerçekleştirdiğimde, o cihazda kayıt işlemi başarılı bir şekilde veritabanına işleniyor. Aynı işlem sırasında diğer cihazda MQTT üzerinden mesaj geldiğini ShowMessage ile görebiliyorum, fakat o cihazda mesaj gelmesine rağmen veritabanına kayıt işlemi gerçekleşmiyor.</div><div>MQTT bağlantısını anaEkran (menü) unitinde kurdum ve mesajları burada dinliyorum.</div><div>Her iki cihazda da aynı kod çalışıyor ve aynı topic'e aboneyiz.</div><div><div>Sorum ise:</div><div>Mesaj diğer cihaza ulaşmasına rağmen neden veritabanına kayıt işlemi gerçekleşmiyor olabilir?</div><div>Ana ekranda MQTT bağlantısı kurmamda bir sakınca var mı, yoksa farklı bir birimde mi kurmam gerekir?</div></div><div><br></div><div>var</div><div>&nbsp; anaEkranForm: TclForm;</div><div>&nbsp; pnlContainer: TclProPanel;</div><div>&nbsp; lblWelcome: TclProLabel;</div><div>&nbsp; btnLogin, btnRegister, btnMembers, btnQrOkuyucu: TclProButton;</div><div>&nbsp; MQTT1: TclMQTT;</div><div>&nbsp; gelenMesaj: string;</div><div>&nbsp; action, table, id, user_id, checkin_time, checkout_time, kullanici_adi, email, password: string;</div><div>&nbsp; subStr: string;</div><div>&nbsp; sql: string;</div><div>&nbsp; mesaj: string;</div><div>&nbsp; pos1, pos2: integer;&nbsp; &nbsp;</div><div>&nbsp; temp: string;&nbsp;</div><div>&nbsp; checkin_location, checkout_location: string;</div><div><br></div><div>void ParseAndApplyMQTTMessage</div><div>{</div><div>&nbsp; mesaj = gelenMesaj;</div><div>&nbsp; action = '';</div><div>&nbsp; table = '';</div><div>&nbsp; id = '';</div><div>&nbsp; user_id = '';</div><div>&nbsp; checkin_time = '';</div><div>&nbsp; checkout_time = '';</div><div>&nbsp; checkin_location = '';</div><div>&nbsp; checkout_location = '';</div><div>&nbsp; kullanici_adi = '';</div><div>&nbsp; email = '';</div><div>&nbsp; password = '';</div><div><br></div><div>&nbsp; // Basit string ayrıştırma</div><div>&nbsp; if Pos('"action":"insert"', mesaj) &gt; 0</div><div>&nbsp; &nbsp; action = 'insert';</div><div>&nbsp; else if Pos('"action":"update"', mesaj) &gt; 0</div><div>&nbsp; &nbsp; action = 'update';</div><div>&nbsp; else if Pos('"action":"delete"', mesaj) &gt; 0</div><div>&nbsp; &nbsp; action = 'delete';</div><div><br></div><div>&nbsp; if Pos('"table":"checkins"', mesaj) &gt; 0</div><div>&nbsp; &nbsp; table = 'checkins';</div><div>&nbsp; else if Pos('"table":"users"', mesaj) &gt; 0</div><div>&nbsp; &nbsp; table = 'users';</div><div><br></div><div>&nbsp; // id</div><div>&nbsp; subStr = '"id":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; id = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; // user_id</div><div>&nbsp; subStr = '"user_id":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; user_id = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"checkin_time":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; checkin_time = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"checkout_time":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; checkout_time = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"checkin_location":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; checkin_location = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"checkout_location":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; checkout_location = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"kullanici_adi":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; kullanici_adi = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"email":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; email = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; subStr = '"password":"';</div><div>&nbsp; pos1 = Pos(subStr, mesaj);</div><div>&nbsp; if pos1 &gt; 0</div><div>&nbsp; {</div><div>&nbsp; &nbsp; temp = Copy(mesaj, pos1 + Length(subStr), Length(mesaj));</div><div>&nbsp; &nbsp; pos2 = Pos('"', temp);</div><div>&nbsp; &nbsp; password = Copy(temp, 1, pos2 - 1);</div><div>&nbsp; }</div><div><br></div><div>&nbsp; // SQL işlemleri</div><div>&nbsp; if table == 'checkins'</div><div>&nbsp; {</div><div>&nbsp; &nbsp; if action == 'insert'</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; sql = 'INSERT INTO checkins (user_id, checkin_time, checkin_location) VALUES (' +</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QuotedStr(user_id) + ', ' + QuotedStr(checkin_time) + ', ' + QuotedStr(checkin_location) + ')';</div><div>&nbsp; &nbsp; &nbsp; Clomosy.DBSQLiteQuery.Sql.Text = sql;</div><div>&nbsp; &nbsp; &nbsp; Clomosy.DBSQLiteQuery.OpenOrExecute;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; else if action == 'update'</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; sql = 'UPDATE checkins SET checkout_time = ' + QuotedStr(checkout_time) +</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ', checkout_location = ' + QuotedStr(checkout_location) +</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' WHERE id = ' + QuotedStr(id);</div><div>&nbsp; &nbsp; &nbsp; Clomosy.DBSQLiteQuery.Sql.Text = sql;</div><div>&nbsp; &nbsp; &nbsp; Clomosy.DBSQLiteQuery.OpenOrExecute;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; else if action == 'delete'</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; sql = 'DELETE FROM checkins WHERE id = ' + QuotedStr(id);</div><div>&nbsp; &nbsp; &nbsp; Clomosy.DBSQLiteQuery.Sql.Text = sql;</div><div>&nbsp; &nbsp; &nbsp; Clomosy.DBSQLiteQuery.OpenOrExecute;</div><div>&nbsp; &nbsp; }</div><div>&nbsp; }</div><div>&nbsp; else if table == 'users' &amp;&amp; action == 'insert'</div><div>&nbsp; {</div><div>&nbsp; try</div><div>&nbsp; &nbsp; sql = 'INSERT INTO users (kullanici_adi, email, password) VALUES (' +</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QuotedStr(kullanici_adi) + ', ' + QuotedStr(email) + ', ' + QuotedStr(password) + ')';</div><div>&nbsp; &nbsp; Clomosy.DBSQLiteQuery.Sql.Text = sql;</div><div>&nbsp; &nbsp; Clomosy.DBSQLiteQuery.OpenOrExecute;</div><div>&nbsp; &nbsp; ShowMessage('&#091;MQTT&#093; Kullanıcı eklendi: ' + kullanici_adi + ' / ' + email);</div><div>&nbsp; except</div><div>&nbsp; &nbsp; ShowMessage('&#091;MQTT&#093; Kullanıcı eklenemedi: ' + LastExceptionMessage);</div><div>&nbsp; }</div><div>&nbsp; }</div><div>}</div><div>void OnLoginClick;</div><div>{</div><div>&nbsp; Clomosy.RunUnit('uLogin');</div><div>}</div><div><br></div><div>void OnRegisterClick;</div><div>{</div><div>&nbsp; Clomosy.RunUnit('uRegister');</div><div>}</div><div><br></div><div>void OnMembersClick;</div><div>{</div><div>&nbsp; Clomosy.RunUnit('uAdminLog');</div><div>}</div><div><br></div><div>void OnQrOkuyucuClick;</div><div>{</div><div>&nbsp; if (Clomosy.PlatformIsMobile)</div><div>&nbsp; &nbsp; ShowMessage('Yalnızca sorumlu ekranda çıkar');</div><div>&nbsp; else</div><div>&nbsp; &nbsp; Clomosy.RunUnit('uQrKodu');</div><div>}</div><div><br></div><div>void OnMQTTPublishReceived</div><div>{</div><div>&nbsp; if (MQTT1.ReceivedAlright)</div><div>&nbsp; {</div><div>&nbsp; &nbsp; gelenMesaj = MQTT1.ReceivedMessage;</div><div>&nbsp; &nbsp; ShowMessage('MQTT ile gelen mesaj: ' + gelenMesaj);</div><div>&nbsp; &nbsp; ParseAndApplyMQTTMessage;</div><div>&nbsp; }</div><div>}</div><div><br></div><div>{</div><div>&nbsp; anaEkranForm = TclForm.Create(Self);</div><div>&nbsp; anaEkranForm.ClSetCaption('Hoş Geldiniz');</div><div>&nbsp; anaEkranForm.SetFormColor('#e0f7fa', '#a8e063', clGVertical);</div><div><br></div><div><br></div><div>&nbsp; pnlContainer = anaEkranForm.AddNewProPanel(anaEkranForm, 'pnlContainer');</div><div>&nbsp; pnlContainer.Align = alCenter;</div><div>&nbsp; pnlContainer.Width = anaEkranForm.clWidth * 0.8;</div><div>&nbsp; pnlContainer.Height = anaEkranForm.clHeight * 0.6;</div><div>&nbsp; pnlContainer.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFFDD');</div><div>&nbsp; pnlContainer.clProSettings.BorderWidth = 0;</div><div>&nbsp; pnlContainer.clProSettings.RoundWidth = 30;</div><div>&nbsp; pnlContainer.clProSettings.RoundHeight = 30;</div><div>&nbsp; pnlContainer.SetclProSettings(pnlContainer.clProSettings);</div><div>&nbsp;&nbsp;</div><div><br></div><div>&nbsp; MQTT1 = anaEkranForm.AddNewMQTTConnection(pnlContainer,'MQTT1');</div><div>&nbsp; MQTT1.Channel = 'clomosy/qrTakip';</div><div>&nbsp; MQTT1.Connect;</div><div>&nbsp; anaEkranForm.AddNewEvent(MQTT1, tbeOnMQTTPublishReceived, 'OnMQTTPublishReceived');</div><div><br></div><div>&nbsp; lblWelcome = anaEkranForm.AddNewProLabel(pnlContainer, 'lblWelcome', 'Qr Giriş-Çıkış Takip Sistemi');</div><div>&nbsp; lblWelcome.Align = alTop;</div><div>&nbsp; lblWelcome.Height = 60;</div><div>&nbsp; lblWelcome.Margins.Top = 20;</div><div>&nbsp; clComponent.SetupComponent(lblWelcome, '{"TextSize":24,"TextColor":"#388e3c","TextBold":"yes","TextHorizontalAlign":"center"}');</div><div><br></div><div>&nbsp; btnLogin = anaEkranForm.AddNewProButton(pnlContainer, 'btnLogin', 'GİRİŞ YAP');</div><div>&nbsp; btnLogin.Align = alTop;</div><div>&nbsp; btnLogin.Height = 50;</div><div>&nbsp; btnLogin.Margins.Top = 30;</div><div>&nbsp; clComponent.SetupComponent(btnLogin, '{"BackgroundColor":"#ffffff","TextColor":"#43a047","BorderColor":"#43a047","BorderWidth":2,"RoundWidth":20,"RoundHeight":20,"TextSize":16}');</div><div>&nbsp; anaEkranForm.AddNewEvent(btnLogin, tbeOnClick, 'OnLoginClick');</div><div><br></div><div>&nbsp; btnRegister = anaEkranForm.AddNewProButton(pnlContainer, 'btnRegister', 'ÜYE OL');</div><div>&nbsp; btnRegister.Align = alTop;</div><div>&nbsp; btnRegister.Height = 50;</div><div>&nbsp; btnRegister.Margins.Top = 15;</div><div>&nbsp; clComponent.SetupComponent(btnRegister, '{"BackgroundColor":"#ffffff","TextColor":"#43a047","BorderColor":"#43a047","BorderWidth":2,"RoundWidth":20,"RoundHeight":20,"TextSize":16}');</div><div>&nbsp; anaEkranForm.AddNewEvent(btnRegister, tbeOnClick, 'OnRegisterClick');</div><div><br></div><div>&nbsp; btnQrOkuyucu = anaEkranForm.AddNewProButton(pnlContainer, 'btnQrOkuyucu', 'QR KODU');</div><div>&nbsp; btnQrOkuyucu.Align = alTop;</div><div>&nbsp; btnQrOkuyucu.Height = 50;</div><div>&nbsp; btnQrOkuyucu.Margins.Top = 15;</div><div>&nbsp; clComponent.SetupComponent(btnQrOkuyucu, '{"BackgroundColor":"#ffffff","TextColor":"#43a047","BorderColor":"#43a047","BorderWidth":2,"RoundWidth":20,"RoundHeight":20,"TextSize":16}');</div><div>&nbsp; anaEkranForm.AddNewEvent(btnQrOkuyucu, tbeOnClick, 'OnQrOkuyucuClick');</div><div><br></div><div>&nbsp; btnMembers = anaEkranForm.AddNewProButton(pnlContainer, 'btnMembers', 'Personeller');</div><div>&nbsp; btnMembers.Align = alBottom;</div><div>&nbsp; btnMembers.Height = 40;</div><div>&nbsp; btnMembers.Margins.Bottom = 20;</div><div>&nbsp; clComponent.SetupComponent(btnMembers, '{"BackgroundColor":"#ffffff","TextColor":"#43a047","BorderColor":"#43a047","BorderWidth":2,"RoundWidth":20,"RoundHeight":20,"TextSize":16}');</div><div>&nbsp; anaEkranForm.AddNewEvent(btnMembers, tbeOnClick, 'OnMembersClick');</div><div><br></div><div>&nbsp; anaEkranForm.Run;</div><div>}<br><br><br>örneğin bir kullanıcıyı kayıt ettiğimi varsayarak uRegister unitimde üye ekleme prosedürüne eklediğim kod ise :<br><br><div>void uyeEkle</div><div>{</div><div>&nbsp; Clomosy.DBSQLiteQuery.Sql.Text = 'INSERT INTO users (kullanici_adi, email, password) VALUES (' +</div><div>&nbsp; &nbsp; QuotedStr(kullaniciAdiEdit.Text) + ', ' +</div><div>&nbsp; &nbsp; QuotedStr(epostaEdit.Text) + ', ' +</div><div>&nbsp; &nbsp; QuotedStr(sifreEdit.Text) + ')';</div><div>&nbsp; Clomosy.DBSQLiteQuery.openorExecute;</div><div>&nbsp; ShowMessage('Üye Olundu..');</div><div><br></div><div>&nbsp; // MQTT ile diğer cihazlara bildir</div><div>&nbsp; if (MQTT1.Connected)</div><div>&nbsp; {</div><div>&nbsp; &nbsp; jsonMesaj = '{"action":"insert","table":"users",' +</div><div>&nbsp; &nbsp; &nbsp; '"kullanici_adi":"' + kullaniciAdiEdit.Text + '",' +</div><div>&nbsp; &nbsp; &nbsp; '"email":"' + epostaEdit.Text + '",' +</div><div>&nbsp; &nbsp; &nbsp; '"password":"' + sifreEdit.Text + '"}';</div><div>&nbsp; &nbsp; MQTT1.Send(jsonMesaj);</div><div>&nbsp; }</div><br><br><br><br></div>]]>
   </description>
   <pubDate>Tue, 08 Jul 2025 10:35:41 +0000</pubDate>
   <guid isPermaLink="true">https://forum.clomosy.com.tr/forum_posts.asp?TID=1064&amp;PID=2133#2133</guid>
  </item> 
 </channel>
</rss>